Updated CRT enemy facing logic.
This commit is contained in:
parent
c378433086
commit
7c037ed22c
1 changed files with 22 additions and 24 deletions
|
|
@ -47,29 +47,29 @@ func start(pos):
|
|||
func _on_timer_timeout():
|
||||
speed = randf_range(75, 100)
|
||||
$DirectionTimer.start()
|
||||
|
||||
$ShootTimer.stop() # Stop shooting when changing direction
|
||||
func _on_direction_timer_timeout():
|
||||
var move_direction = randi_range(0,2)
|
||||
match move_direction:
|
||||
0:
|
||||
crt.frame = 0
|
||||
crt.frame = 0 # down - facing
|
||||
direction = Vector2(0,1)
|
||||
can_shoot = true
|
||||
vulnerable = true
|
||||
#$DirectionTimer.start()
|
||||
$DirectionTimer.start()
|
||||
$ShootTimer.start()
|
||||
1:
|
||||
crt.frame = 1
|
||||
crt.frame = 1 # right - facing right
|
||||
direction = Vector2(1,0)
|
||||
can_shoot = false
|
||||
vulnerable = false
|
||||
#$DirectionTimer.start()
|
||||
$DirectionTimer.start()
|
||||
2:
|
||||
crt.frame = 2
|
||||
crt.frame = 2 # left - facing left
|
||||
direction = Vector2(-1,0)
|
||||
can_shoot = false
|
||||
vulnerable = false
|
||||
#$DirectionTimer.start()
|
||||
|
||||
$DirectionTimer.start()
|
||||
|
||||
|
||||
|
||||
func _on_shoot_timer_timeout():
|
||||
|
|
@ -80,30 +80,30 @@ func _on_shoot_timer_timeout():
|
|||
b.start(position)
|
||||
#$ShootTimer.wait_time = randf_range(4, 20)
|
||||
$ShootTimer.start()
|
||||
|
||||
else:
|
||||
$ShootTimer.start()
|
||||
|
||||
else:
|
||||
$ShootTimer.stop() # Don't shoot when can_shoot is false - prevents timer race condition
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
|
||||
if stunned == true:
|
||||
return
|
||||
|
||||
if stunned == false:
|
||||
|
||||
if stunned == false:
|
||||
position += direction * speed * delta
|
||||
|
||||
|
||||
#if position.x > screensize.x + 32:
|
||||
#start(start_pos)
|
||||
|
||||
|
||||
if travel == true and position.y > screensize.y + 32 or position.x > screensize.x or position.x < -screensize.x:
|
||||
print("I'm off screen!")
|
||||
start(start_pos)
|
||||
|
||||
|
||||
|
||||
func hit_detection():
|
||||
if exploding: return
|
||||
|
||||
|
||||
if vulnerable == true:
|
||||
exploding = true
|
||||
EventBus.enemy_hit.emit(5)
|
||||
|
|
@ -114,10 +114,10 @@ func hit_detection():
|
|||
await $AnimationPlayer.animation_finished
|
||||
queue_free()
|
||||
EventBus.enemy_died.emit()
|
||||
|
||||
|
||||
if vulnerable == false:
|
||||
block()
|
||||
|
||||
|
||||
func block():
|
||||
#if blocking: return
|
||||
#blocking = true
|
||||
|
|
@ -132,7 +132,5 @@ func block():
|
|||
shader_active = false
|
||||
stunned = false
|
||||
$DirectionTimer.start()
|
||||
$ShootTimer.start() ## Restart shooting after stun period
|
||||
print("CRT Not Stunned!")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue