Class: Battle::Scene
- Inherits:
-
GamePlay::Base
- Object
- GamePlay::Base
- Battle::Scene
- Includes:
- Hooks
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb,
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/01000 Message.rb,
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00104 Scene Event.rb,
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00101 Scene Choice.rb,
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00102 Scene AI trigger.rb,
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00103 Scene Battle Phase.rb
Overview
Base classe of all the battle scene
Defined Under Namespace
Classes: Message
Constant Summary
Constants inherited from GamePlay::Base
GamePlay::Base::DEFAULT_TRANSITION, GamePlay::Base::DEFAULT_TRANSITION_PARAMETER
Constants included from Input
Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE
Constants included from GamePlay::DisplayMessage
GamePlay::DisplayMessage::MESSAGE_ERROR, GamePlay::DisplayMessage::MESSAGE_PROCESS_ERROR
Class Attribute Summary collapse
-
.current ⇒ Battle::Scene
writeonly
Set the current battle scene.
Instance Attribute Summary collapse
- #artificial_intelligences ⇒ Array<AI::Base> readonly
- #battle_info ⇒ Battle::Logic::BattleInfo readonly
- #logic ⇒ Battle::Logic readonly
- #message_window ⇒ UI::Message::Window readonly
-
#next_update ⇒ Symbol
Set the next update from outside (flee).
- #player_actions ⇒ Array readonly
- #visual ⇒ Battle::Visual readonly
Attributes inherited from GamePlay::Base
#__last_scene, #__result_process, #running, #viewport
Class Method Summary collapse
-
.register_event(name, &block)
Register an event for the battle.
Instance Method Summary collapse
-
#dispose
Dispose the battle scene.
-
#force_ia_switch? ⇒ Boolean
Tell if the ia should force a switch in case of no foe alive.
-
#initialize(battle_info) ⇒ Scene
constructor
Create a new Battle Scene.
-
#main_begin
Disable the Graphics.transition.
-
#next_update_process
Process the next update method.
-
#snap_to_bitmap ⇒ Texture
Take a snapshot of the scene.
-
#to_s
(also: #inspect)
Safe to_s & inspect.
-
#update
Update the scene.
Methods included from Hooks
#exec_hooks, #force_return, included, register, remove, remove_without_name
Methods inherited from GamePlay::Base
#add_disposable, #call_scene, #find_parent, #main, #return_to_scene, #visible, #visible=
Methods included from Input
dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?
Methods included from GamePlay::DisplayMessage
#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_processing?, #message_visible, #message_visible=
Constructor Details
#initialize(battle_info) ⇒ Scene
This method create the banks, the AI, the pokemon battlers and the battle logic It should call the logic_init event
Create a new Battle Scene
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 26 def initialize(battle_info) # Call the initialize of GamePlay::Base (show message box at z index 10001) super(false, 10_001) @battle_info = battle_info $game_temp.vs_type = battle_info.vs_type $game_temp.trainer_battle = battle_info.trainer_battle? $game_temp.in_battle = true @logic = create_logic @logic.load_rng @logic.load_battlers @visual = create_visual @artificial_intelligences = create_ais # Next method called in update @next_update = :pre_transition # List of the player actions # @type [Array<Actions::Base>] @player_actions = [] # Battle result @battle_result = -1 # All the event procs @battle_events = {} # Skip the next frame to go faster in the next update @skip_frame = false @viewport = @visual. # Create the message proc # Init & call first event load_events(logic.battle_info.battle_id) call_event(:logic_init) end |
Class Attribute Details
.current=(value) ⇒ Battle::Scene (writeonly)
Set the current battle scene
6 7 8 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00104 Scene Event.rb', line 6 def current=(value) @current = value end |
Instance Attribute Details
#artificial_intelligences ⇒ Array<AI::Base> (readonly)
17 18 19 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 17 def artificial_intelligences @artificial_intelligences end |
#battle_info ⇒ Battle::Logic::BattleInfo (readonly)
11 12 13 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 11 def battle_info @battle_info end |
#logic ⇒ Battle::Logic (readonly)
9 10 11 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 9 def logic @logic end |
#message_window ⇒ UI::Message::Window (readonly)
13 14 15 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 13 def @message_window end |
#next_update ⇒ Symbol
Set the next update from outside (flee)
20 21 22 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 20 def next_update @next_update end |
#player_actions ⇒ Array (readonly)
15 16 17 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 15 def player_actions @player_actions end |
#visual ⇒ Battle::Visual (readonly)
7 8 9 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 7 def visual @visual end |
Class Method Details
.register_event(name, &block)
Register an event for the battle
11 12 13 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00104 Scene Event.rb', line 11 def register_event(name, &block) @current.send(:register_event, name, &block) end |
Instance Method Details
#dispose
Dispose the battle scene
88 89 90 91 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 88 def dispose super @visual.dispose end |
#force_ia_switch? ⇒ Boolean
Tell if the ia should force a switch in case of no foe alive
5 6 7 8 9 10 11 12 13 14 15 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00101 Scene Choice.rb', line 5 def force_ia_switch? return if logic.actions.empty? @logic.bank_count.times do |bank| next if @logic.alive_battlers(bank).any?(&:from_party?) alive_foes = (@logic.alive_battlers_without_check(bank).select { |p| p if p.position == -1 }).compact return true if @logic.battler_count(bank).zero? && alive_foes.any? end return false end |
#main_begin
Disable the Graphics.transition
64 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 64 def main_begin() end |
#next_update_process
Process the next update method
77 78 79 80 81 82 83 84 85 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 77 def next_update_process @skip_frame = true # Force the next update to be called if a frame skip was requested while @skip_frame @skip_frame = false log_debug("Calling #{@next_update} phase") send(@next_update) end end |
#snap_to_bitmap ⇒ Texture
You have to dispose the bitmap you got from this function
Take a snapshot of the scene
96 97 98 99 100 101 102 103 104 105 106 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 96 def snap_to_bitmap temp_view = Viewport.create(:main) # Snapshot of spriteset bitmaps = @visual.snap_to_bitmaps bitmaps.map { |bmp| Sprite.new(temp_view).set_bitmap(bmp) } result = temp_view.snap_to_bitmap bitmaps.each(&:dispose) temp_view.dispose # Return actual snapshot return result end |
#to_s Also known as: inspect
Safe to_s & inspect
58 59 60 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 58 def to_s format('#<%<class>s:%<id>08X visual=%<visual>s logic=%<logic>s>', class: self.class, id: __id__, visual: @visual.inspect, logic: @logic.inspect) end |
#update
Update the scene
67 68 69 70 71 72 73 74 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00100 Scene.rb', line 67 def update # Update the visuals @visual.update # Prevent update if a message is showing return unless super && !@visual.locking? # Call the next method next_update_process end |