Class: BattleUI::ExpDistribution

Inherits:
UI::SpriteStack show all
Includes:
ExpDistributionAbstraction, UI
Defined in:
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00500 ExpDistribution.rb

Overview

UI element showing the exp distribution

Defined Under Namespace

Classes: PokemonInfo, Statistics

Constant Summary

Constants inherited from UI::SpriteStack

UI::SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary

Attributes included from ExpDistributionAbstraction

#scene

Attributes inherited from UI::SpriteStack

#animated, #data, #moving, #stack, #viewport, #x, #y

Instance Method Summary collapse

Methods inherited from UI::SpriteStack

#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=

Constructor Details

#initialize(viewport, scene, exp_data) ⇒ ExpDistribution

Create a new exp distribution

Parameters:



11
12
13
14
15
16
17
18
19
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00500 ExpDistribution.rb', line 11

def initialize(viewport, scene, exp_data)
  super(viewport)
  @scene = scene
  @pokemon = find_expable_pokemon
  @originals = map_to_original_with_forms(@pokemon)
  @exp_data = exp_data.dup
  @done = false
  create_sprites
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00500 ExpDistribution.rb', line 30

def done?
  return @done
end

#start_animation



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00500 ExpDistribution.rb', line 34

def start_animation
  animations = @exp_data.map do |pokemon, exp|
    create_exp_animation_for(pokemon, exp)
  end.compact
  return restore_form_to_originals.then { align_exp(@pokemon) } if (@done = animations.empty?)

  # @type [Yuki::Animation::TimedAnimation]
  @animation = Yuki::Animation.se_play('exp_sound')
  animations.each { |(animation, _)| @animation.parallel_add(animation) }
  @animation.play_before(Yuki::Animation.send_command_to(Audio, :se_stop))
  animations.each do |(_, pokemon)|
    @animation.play_before(Yuki::Animation.send_command_to(self, :show_level_up, pokemon)) if pokemon
  end
  @animation.play_before(Yuki::Animation.send_command_to(self, :start_animation))
  @animation.start
  @animation.update
end

#update



21
22
23
24
25
26
27
28
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00500 ExpDistribution.rb', line 21

def update
  if @statistics
    update_statistics
  else
    @animation.update
  end
  @bars.each(&:update)
end