class TankStuckState
Attributes
stuck_at[RW]
Public Class Methods
new(object, vision, gun)
click to toggle source
Calls superclass method
TankMotionState::new
# File lib/entities/components/ai/tank_stuck_state.rb, line 3 def initialize(object, vision, gun) super(object, vision) @object = object @vision = vision @gun = gun end
Public Instance Methods
change_direction()
click to toggle source
# File lib/entities/components/ai/tank_stuck_state.rb, line 15 def change_direction closest_free_path = @vision.closest_free_path_away_from( @stuck_at) if closest_free_path @object.physics.change_direction( Utils.angle_between( @object.x, @object.y, *closest_free_path)) else if @object.health.health > 50 && rand > 0.9 @object.shoot(*Utils.point_at_distance( *@object.location, @object.gun_angle, 150)) end end @changed_direction_at = Gosu.milliseconds @will_keep_direction_for = turn_time end
drive_time()
click to toggle source
# File lib/entities/components/ai/tank_stuck_state.rb, line 38 def drive_time rand(1000..2000) end
turn_time()
click to toggle source
# File lib/entities/components/ai/tank_stuck_state.rb, line 42 def turn_time rand(1000..2000) end
update()
click to toggle source
# File lib/entities/components/ai/tank_stuck_state.rb, line 10 def update change_direction if should_change_direction? drive end
wait_time()
click to toggle source
# File lib/entities/components/ai/tank_stuck_state.rb, line 34 def wait_time rand(10..100) end