Beispiel #1
0
        public void ChangeAmmo(bool moveUp)
        {
            if (ammoClips.Count == 0)
            {
                return;
            }
            if (delayLeft > 0)
            {
                return;
            }
            currentClipIndex += moveUp ? 1 : -1;
            currentClipIndex  = currentClipIndex % ammoClips.Count;
            while (currentClipIndex < 0)
            {
                currentClipIndex += ammoClips.Count;
            }

            if (currentClip != null)
            {
                currentClip.OnReload -= ReloadHandler;
            }

            currentClip = ammoClips[currentClipIndex];
            if (currentClip.GetAmmoInfo().loaded == 0)
            {
                currentClip.StartReload();
            }
            OnWeaponChange?.Invoke(this);
            currentClip.OnReload += ReloadHandler;
        }
Beispiel #2
0
        public AmmoClip(AmmoClip other)
        {
            ammoType        = other.ammoType;
            this.clipSize   = other.clipSize;
            this.maxAmmo    = other.maxAmmo;
            this.reloadTime = other.reloadTime;

            ammoReserves    = other.ammoReserves;
            currentlyInClip = other.currentlyInClip;
        }
Beispiel #3
0
        public bool RestoreAmmo(Type ammoType, int amount)
        {
            AmmoClip clip = ammoClips.Find(x => x.clip.ammoType == ammoType);

            if (clip == null)
            {
                throw new ApplicationException("restoring unexisting ammo");
            }

            if (clip.IsFull())
            {
                return(false);
            }

            clip.RestoreAmmo(amount);
            OnAmmoChange?.Invoke(this);

            return(true);
        }
Beispiel #4
0
 private void ReloadHandler(AmmoClip clip)
 {
     OnAmmoChange?.Invoke(this);
 }