AmmoWeapon.cs 628 B

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. using System.Collections;
  3. public class AmmoWeapon : Weapon
  4. {
  5. public int ammo;
  6. private int _ammoLeft;
  7. public override void Arm()
  8. {
  9. base.Arm();
  10. _ammoLeft = ammo;
  11. NotificationCenter.Post(NotificationType.UpdateWeaponUpgradeAmmoLeft, _ammoLeft);
  12. }
  13. public override PoolObject Fire()
  14. {
  15. AVDebug.Assert(_ammoLeft > 0, "No ammo left in "+type+" but still trying to fire. Incosistent behaviour");
  16. --_ammoLeft;
  17. NotificationCenter.Post(NotificationType.UpdateWeaponUpgradeAmmoLeft, _ammoLeft);
  18. return base.Fire();
  19. }
  20. public override bool IsEmpty
  21. {
  22. get
  23. {
  24. return _ammoLeft <= 0;
  25. }
  26. }
  27. }