game: improve enemy-manager
This commit is contained in:
@@ -9,6 +9,7 @@ extends Node2D
|
||||
|
||||
@onready var active_cd_timer: Timer = $ActiveCDTimer
|
||||
|
||||
|
||||
func _on_attack_cd_timer_timeout() -> void:
|
||||
do_attack()
|
||||
|
||||
@@ -16,16 +17,18 @@ func _on_attack_cd_timer_timeout() -> void:
|
||||
func do_attack() -> void:
|
||||
push_error("%s does not implement do_attack" % self)
|
||||
|
||||
|
||||
func do_active() -> void:
|
||||
if not active_cd_timer.is_stopped():
|
||||
return
|
||||
active_cd_timer.start()
|
||||
_do_active()
|
||||
|
||||
|
||||
|
||||
func _do_active() -> void:
|
||||
push_error("%s does not implement do_active" % self)
|
||||
|
||||
|
||||
func find_target_in_radius() -> EnemyBase:
|
||||
var space_state: PhysicsDirectSpaceState2D = get_world_2d().direct_space_state
|
||||
var shape := CircleShape2D.new()
|
||||
|
@@ -27,6 +27,7 @@ func do_attack() -> void:
|
||||
projectile.on_hit_sig = projectile_hit
|
||||
add_child(projectile)
|
||||
|
||||
|
||||
func _do_active() -> void:
|
||||
var radius = targeting_range_shape.shape.radius
|
||||
var count = 15
|
||||
@@ -41,6 +42,7 @@ func _do_active() -> void:
|
||||
projectile.on_hit_sig = projectile_hit
|
||||
add_child(projectile)
|
||||
|
||||
|
||||
func deal_damage(enemy: EnemyBase, damage_mult: float):
|
||||
var crit_chance = _player.player_stats.get_final("crit_chance", _player.modifiers)
|
||||
var damage_dealt = attack_damage * damage_mult
|
||||
|
Reference in New Issue
Block a user