Newer
Older
DungeonShooting / DungeonShooting_Godot / src / weapon / shell / ThrowShell.cs
@小李xl 小李xl on 3 Aug 2022 858 bytes 优化投抛节点
  1. using Godot;
  2.  
  3. /// <summary>
  4. /// 弹壳
  5. /// </summary>
  6. public class ThrowShell : ThrowNode
  7. {
  8.  
  9. public override void _Ready()
  10. {
  11. base._Ready();
  12. ZIndex = 2;
  13. }
  14.  
  15. protected override void OnOver()
  16. {
  17. //如果落地高度不够低, 再抛一次
  18. if (StartYSpeed > 1)
  19. {
  20. InitThrow(Size, GlobalPosition, 0, Direction, XSpeed * 0.8f, StartYSpeed * 0.5f, RotateSpeed * 0.5f, null);
  21. }
  22. else
  23. {
  24. base.OnOver();
  25. //等待被销毁
  26. AwaitDestroy();
  27. }
  28. }
  29.  
  30. private async void AwaitDestroy()
  31. {
  32. CollisionShape.Disabled = true;
  33. //60秒后销毁
  34. await ToSignal(GetTree().CreateTimer(60), "timeout");
  35. QueueFree();
  36. }
  37.  
  38. protected override void OnMaxHeight(float height)
  39. {
  40. ZIndex = 0;
  41. }
  42. }