Refactor enemy system: enhance EnemyAI with attack cooldown, update Force class to handle damage, and improve EnemyHandler for enemy removal; add OccamsRazor weapon with attack mechanics.
This commit is contained in:
+8
-3
@@ -4,8 +4,13 @@ class Force < Enemy
|
||||
load 'assets/images/force.png', 21, 32, 1.7
|
||||
|
||||
def initialize(x, y)
|
||||
super
|
||||
@w = 20
|
||||
@h = 20
|
||||
super(x, y, 100)
|
||||
|
||||
$bus.on(:occams_razor_attack) do |attack_x, attack_y, range, damage|
|
||||
# Whoa, did'nt know ruby had hypot functions built in!
|
||||
if Math.hypot(@x - attack_x, @y - attack_y) <= range
|
||||
take_damage(damage)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user