Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / prop / active / ActiveProp5001.cs
@小李xl 小李xl on 16 Mar 2024 686 bytes 重构主动道具中

using Godot;

/// <summary>
/// 弹药箱, 使用后补全当前武器备用弹药
/// </summary>
[Tool]
public partial class ActiveProp5001 : ActiveProp
{
    public override void OnInit()
    {
        base.OnInit();
        AutoDestroy = true;
        MaxCount = 10;
    }

    public override bool OnCheckUse()
    {
        return Master.WeaponPack.ActiveItem != null && !Master.WeaponPack.ActiveItem.IsAmmoFull();
    }

    protected override int OnUse()
    {
        var weapon = Master.WeaponPack.ActiveItem;
        if (weapon != null)
        {
            weapon.SetTotalAmmo(weapon.Attribute.MaxAmmoCapacity);
            return 1;
        }

        return 0;
    }
}