Newer
Older
DungeonShooting / src / weapon / shell / Shell.cs
@小李xl 小李xl on 12 Jun 2022 699 bytes 添加子弹和弹壳阴影效果
using Godot;

/// <summary>
/// 弹壳
/// </summary>
public class Shell : ThrowNode
{
    protected override void OnInit()
    {

    }

    protected override void OnOver()
    {
        //如果落地高度不够低, 再抛一次
        if (StartYSpeed > 1)
        {
            InitThrow(Size, GlobalPosition, 0, Direction, XSpeed * 0.8f, StartYSpeed * 0.5f, RotateSpeed * 0.5f, null);
        }
        else
        {
            //等待被销毁
            AwaitDestroy();
        }
    }

    private async void AwaitDestroy()
    {
        CollisionShape.Disabled = true;
        //20秒后销毁
        await ToSignal(GetTree().CreateTimer(20), "timeout");
        QueueFree();
    }
}