Exemple #1
0
        protected virtual void OnChangeAmmo(Ammo ammo)
        {
            if (ammo == null)
            {
                return;
            }
            this.currentAmmoID = ammo.ammoID;

            if (this.ammoMaxClip != null)
            {
                this.ammoMaxClip.text = ammo.clipSize.ToString();
            }
            if (this.ammoName != null)
            {
                this.ammoName.text = ammo.ammoName.GetText();
            }
            if (this.ammoDescription != null)
            {
                this.ammoDescription.text = ammo.ammoDesc.GetText();
            }

            CharacterShooter shooter = this.character.GetComponent <CharacterShooter>(gameObject);

            if (shooter != null)
            {
                this.OnChangeInClip(this.currentAmmoID, shooter.GetAmmoInClip(this.currentAmmoID));
                this.OnChangeInStorage(this.currentAmmoID, shooter.GetAmmoInStorage(this.currentAmmoID));
            }
        }
Exemple #2
0
        private bool ClipRequirements(CharacterShooter shooter, bool subtract)
        {
            if (shooter.GetAmmoInClip(this.ammoID) > 0)
            {
                if (subtract)
                {
                    shooter.AddAmmoToClip(this.ammoID, -1);
                }
                return(true);
            }

            if (shooter.GetAmmoInStorage(this.ammoID) > 0 && this.autoReload)
            {
                shooter.StartCoroutine(shooter.Reload());
            }
            else
            {
                shooter.PlayAudio(this.audioEmpty);
            }

            return(false);
        }