Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / prop / active / ActiveProp5001.cs
@小李xl 小李xl on 17 Nov 2023 693 bytes 还原成老版本的角色继承路线
  1.  
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 弹药箱, 使用后补全当前武器备用弹药
  6. /// </summary>
  7. [Tool]
  8. public partial class ActiveProp5001 : ActiveProp
  9. {
  10. public override void OnInit()
  11. {
  12. Superposition = true;
  13. AutoDestroy = true;
  14. MaxCount = 10;
  15. }
  16.  
  17. public override bool OnCheckUse()
  18. {
  19. return Master.WeaponPack.ActiveItem != null && !Master.WeaponPack.ActiveItem.IsAmmoFull();
  20. }
  21.  
  22. protected override int OnUse()
  23. {
  24. var weapon = Master.WeaponPack.ActiveItem;
  25. if (weapon != null)
  26. {
  27. weapon.SetTotalAmmo(weapon.Attribute.MaxAmmoCapacity);
  28. return 1;
  29. }
  30.  
  31. return 0;
  32. }
  33. }