Class: UI::MiningGame::Hit_Counter_Stack
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::MiningGame::Hit_Counter_Stack
- Defined in:
- scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00005 Hit_Counter_Stack.rb
Overview
Class that describes the SpriteStack containing all the Hit_Counter_Sprite
Constant Summary collapse
- COORD_X =
X Coordinates of first and second Hit_Counter_Sprite
[206, 182]
- SPACE_BETWEEN_CRACKS =
The X space between all Hit_Counter_Sprite (except first and second)
24
- COORD_Y =
Y Coordinates of first and every other Hit_Counter_Sprite
[0, 2]
- NUMBER_OF_CRACKS =
Max number of Cracks
10
- MAX_NB_HIT =
Max number of hits the wall can take
61
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#nb_hit ⇒ Integer
The current number of hit.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#initialize(viewport) ⇒ Hit_Counter_Stack
constructor
Create the Hit_Counter_Stack.
-
#max_cracks? ⇒ Boolean
Check if the current number of hits is equal the max amount of hit.
-
#send_hit(reason)
Method that send the correct number of hits.
Methods inherited from 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, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport) ⇒ Hit_Counter_Stack
Create the Hit_Counter_Stack
21 22 23 24 25 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00005 Hit_Counter_Stack.rb', line 21 def initialize() super(, 0, 0) @nb_hit = 0 NUMBER_OF_CRACKS.times { |i| add_sprite(get_x(i), get_y(i), nil, i == 0 ? :first : :not_first, type: Hit_Counter_Sprite) } end |
Instance Attribute Details
#nb_hit ⇒ Integer
Returns the current number of hit.
17 18 19 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00005 Hit_Counter_Stack.rb', line 17 def nb_hit @nb_hit end |
Instance Method Details
#max_cracks? ⇒ Boolean
Check if the current number of hits is equal the max amount of hit
49 50 51 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00005 Hit_Counter_Stack.rb', line 49 def max_cracks? return @nb_hit == MAX_NB_HIT end |
#send_hit(reason)
Method that send the correct number of hits
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00005 Hit_Counter_Stack.rb', line 29 def send_hit(reason) hit = send(reason) stack.each_with_index do |crack, index| next if crack.state == crack.number_of_image_y - 1 break if hit == 0 break if @nb_hit == MAX_NB_HIT until crack.state == crack.number_of_image_y - 1 crack.change_state stack[index + 1]&.change_state if crack.state == crack.number_of_image_y - 1 && index != 0 hit -= 1 @nb_hit += 1 break if hit == 0 break if @nb_hit == MAX_NB_HIT end end end |