Newer
Older
DungeonShooting / src / weapon / shell / Shell.cs
@小李xl 小李xl on 12 Jun 2022 699 bytes 添加子弹和弹壳阴影效果
  1. using Godot;
  2.  
  3. /// <summary>
  4. /// 弹壳
  5. /// </summary>
  6. public class Shell : ThrowNode
  7. {
  8. protected override void OnInit()
  9. {
  10.  
  11. }
  12.  
  13. protected override void OnOver()
  14. {
  15. //如果落地高度不够低, 再抛一次
  16. if (StartYSpeed > 1)
  17. {
  18. InitThrow(Size, GlobalPosition, 0, Direction, XSpeed * 0.8f, StartYSpeed * 0.5f, RotateSpeed * 0.5f, null);
  19. }
  20. else
  21. {
  22. //等待被销毁
  23. AwaitDestroy();
  24. }
  25. }
  26.  
  27. private async void AwaitDestroy()
  28. {
  29. CollisionShape.Disabled = true;
  30. //20秒后销毁
  31. await ToSignal(GetTree().CreateTimer(20), "timeout");
  32. QueueFree();
  33. }
  34. }