예제 #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);
        }
        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            CharacterShooter charShooter = this.shooter.GetComponent <CharacterShooter>(target);

            if (charShooter == null)
            {
                Debug.LogError("Target Game Object does not have a CharacterShooter component");
                return(true);
            }

            charShooter.Shoot();
            return(true);
        }