36 lines
711 B
GDScript
36 lines
711 B
GDScript
extends Sprite
|
|
|
|
onready var tank = get_node("/root/Tank")
|
|
onready var spawner = get_node("/root/Tank/HazardSpawner")
|
|
var playingforwards = true
|
|
|
|
|
|
func _ready() -> void:
|
|
$Timer.start()
|
|
|
|
|
|
func _on_Timer_timeout() -> void:
|
|
_reposition()
|
|
yield($Tween, "tween_completed")
|
|
_stab()
|
|
yield($AnimationPlayer, "animation_finished")
|
|
_retract()
|
|
|
|
|
|
func _reposition() -> void:
|
|
var tween_duration = 1
|
|
$Tween.interpolate_property(self, "position:x", position.x, rand_range(400, 2000), tween_duration, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
|
|
$Tween.start()
|
|
|
|
|
|
func _stab() -> void:
|
|
$AnimationPlayer.play("Stab")
|
|
|
|
|
|
func _retract() -> void:
|
|
$AnimationPlayer.play_backwards("Stab")
|
|
|
|
|
|
func destroy() -> void:
|
|
queue_free()
|