ufo_ast.gd 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. extends UFO
  2. var speed = 200.0
  3. var damage = 0
  4. var timeout: Timer = Timer.new()
  5. var last_vector: Vector2 = Vector2(0, 0)
  6. func fuck():
  7. return true
  8. func _ready():
  9. super()
  10. $NavigationAgent2D.set_target_desired_distance(0)
  11. $NavigationAgent2D.set_avoidance_enabled(false)
  12. timeout.set_wait_time(1000.0)
  13. add_child(timeout)
  14. timeout.start()
  15. timeout.connect("timeout", _on_timeout)
  16. func _physics_process(delta: float):
  17. super(delta)
  18. if target != null:
  19. var dist = target.get_global_position() - get_global_position()
  20. if dist.length() < 60.0:
  21. target.deal_damage(dps, null)
  22. get_parent().remove_child(self)
  23. queue_free()
  24. if dist.length() > 2500:
  25. speed = 2000.0
  26. else:
  27. speed = 200.0
  28. last_vector = dist.normalized()
  29. velocity = last_vector * speed
  30. else:
  31. call_deferred("die")
  32. $Plx/Top.rotate(delta)
  33. move_and_slide()
  34. func _on_timeout():
  35. get_parent().remove_child(self)
  36. queue_free()
  37. func die():
  38. get_parent().remove_child(self)
  39. queue_free()