Пример #1
0
        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            CharacterShooter charShooter = this.shooter.GetComponent <CharacterShooter>(target);

            if (charShooter == null || charShooter.currentWeapon == null || charShooter.currentAmmo == null)
            {
                Debug.LogError("Target Game Object does not have a CharacterShooter component");
                yield break;
            }

            int burstCount = Mathf.Min(
                charShooter.GetAmmoInClip(charShooter.currentAmmo.ammoID),
                this.burstAmount.GetInt(target)
                );

            if (burstCount <= 0)
            {
                burstCount = 1;
            }

            float fireRate = charShooter.currentAmmo.fireRate.GetValue(target);

            for (int i = 0; i < burstCount; ++i)
            {
                while (!charShooter.CanShootFireRate(charShooter.currentAmmo.ammoID, fireRate))
                {
                    yield return(null);
                }

                charShooter.Shoot();
            }

            yield return(0);
        }
Пример #2
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));
            }
        }
        public override bool Check(GameObject target)
        {
            CharacterShooter shooter = this.character.GetComponent <CharacterShooter>(target);

            if (shooter == null)
            {
                return(false);
            }
            if (shooter.currentAmmo == null)
            {
                return(false);
            }

            string ammoID = shooter.currentAmmo.ammoID;

            int capacity = shooter.currentAmmo.clipSize;
            int inClip   = shooter.GetAmmoInClip(ammoID);

            switch (this.state)
            {
            case State.IsFull: return(inClip >= capacity);

            case State.IsEmpty: return(inClip <= 0);
            }

            return(false);
        }
Пример #4
0
        public bool Shoot(CharacterShooter shooter, float deviation, CharacterShooter.ShotType shotType)
        {
            if (!this.CanShoot(shooter, shotType, true))
            {
                return(false);
            }
            this.ShootGeneric(shooter, deviation, shotType);

            shooter.eventShoot.Invoke(shooter.currentWeapon, this);

            if (shooter.GetAmmoInClip(this.ammoID) <= 0)
            {
                this.RemoveAmmoPrefab(shooter);
            }

            return(true);
        }
Пример #5
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);
        }