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