Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / item / weapon / shell / ShellCase.cs
@lijincheng lijincheng on 14 Mar 2023 898 bytes 优化代码
  1.  
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 弹壳类
  6. /// </summary>
  7. [RegisterActivity(ActivityIdPrefix.Shell + "0001", ResourcePath.prefab_weapon_shell_ShellCase_tscn)]
  8. public partial class ShellCase : ActivityObject
  9. {
  10. /// <summary>
  11. /// 动画播放器
  12. /// </summary>
  13. public AnimationPlayer AnimationPlayer { get; private set; }
  14. public override void OnInit()
  15. {
  16. base.OnInit();
  17. AnimationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
  18. ShadowOffset = new Vector2(0, 1);
  19. ThrowCollisionSize = new Vector2(5, 5);
  20. }
  21.  
  22. protected override void OnThrowOver()
  23. {
  24. //AwaitDestroy();
  25. MoveController.SetAllForce(Vector2.Zero);
  26. AnimationPlayer.Play("flicker");
  27. }
  28.  
  29. private async void AwaitDestroy()
  30. {
  31. //2秒后销毁
  32. await ToSignal(GetTree().CreateTimer(2), "timeout");
  33. Destroy();
  34. }
  35. }