Module: Battle::MoveAnimation
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/05000 MoveAnimation/00000 MoveAnimation.rb
Overview
Module responsive of handling all move animation
All animation will have the following values in their resolver:
- :visual => Battle::Visual object
- :user => BattleUI::PokemonSprite of the user of the move
- :target => BattleUI::PokemonSprite of the target of the move (first if user animation, current if target animation)
- :viewport => Viewport of the user sprite
Class Method Summary collapse
-
.get(move, *animation_reason) ⇒ Array<Yuki::Animation::TimedAnimation>?
Function that retreives the animation for the user & the target depending on the condition.
-
.play(animations, visual, user, targets)
Function that plays an animation.
-
.register_generic_animation(move_kind, move_type, animation_user, animation_target)
Function that stores a generic move animation.
-
.register_specific_animation(move_db_symbol, animation_reason, animation_user, animation_target)
Function that store a specific move animation.
Class Method Details
.get(move, *animation_reason) ⇒ Array<Yuki::Animation::TimedAnimation>?
Function that retreives the animation for the user & the target depending on the condition
41 42 43 44 45 46 47 48 49 50 |
# File 'scripts/01600 Alpha 25 Battle Engine/05000 MoveAnimation/00000 MoveAnimation.rb', line 41 def get(move, *animation_reason) db_symbol = move.db_symbol found_reason = animation_reason.find { |reason| @specific_move_animations.dig(db_symbol, reason) } return Marshal.load(@specific_move_animations.dig(db_symbol, found_reason)) if found_reason generic = @generic_move_animations.dig(move.atk_class, move.type) return Marshal.load(generic) if generic return nil end |
.play(animations, visual, user, targets)
Function that plays an animation
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'scripts/01600 Alpha 25 Battle Engine/05000 MoveAnimation/00000 MoveAnimation.rb', line 57 def play(animations, visual, user, targets) animations = animations.dup # @type [Yuki::Animation::TimedAnimation] user_animation = animations.shift animations << Marshal.load(Marshal.dump(animations.last)) while animations.size > targets.size user_sprite = visual.battler_sprite(user.bank, user.position) target_sprites = targets.map { |target| visual.battler_sprite(target.bank, target.position) } user_animation.resolver = { visual: visual, user: user_sprite, target: target_sprites.first, viewport: user_sprite. }.method(:[]) animations.each_with_index do |animation, index| animation.resolver = { visual: visual, user: user_sprite, target: target_sprites[index], viewport: user_sprite. }.method(:[]) animation.start end user_animation.start visual.animations << user_animation visual.animations.concat(animations) visual.wait_for_animation end |
.register_generic_animation(move_kind, move_type, animation_user, animation_target)
Function that stores a generic move animation
33 34 35 |
# File 'scripts/01600 Alpha 25 Battle Engine/05000 MoveAnimation/00000 MoveAnimation.rb', line 33 def register_generic_animation(move_kind, move_type, animation_user, animation_target) (@generic_move_animations[move_kind] ||= {})[move_type] = Marshal.dump([animation_user, animation_target]) end |
.register_specific_animation(move_db_symbol, animation_reason, animation_user, animation_target)
Function that store a specific move animation
24 25 26 |
# File 'scripts/01600 Alpha 25 Battle Engine/05000 MoveAnimation/00000 MoveAnimation.rb', line 24 def register_specific_animation(move_db_symbol, animation_reason, animation_user, animation_target) (@specific_move_animations[move_db_symbol] ||= {})[animation_reason] = Marshal.dump([animation_user, animation_target]) end |