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); }
// AUXILIARY PRIVATE METHODS: ------------------------------------------------------- private bool ShootingRequirements(CharacterShooter shooter) { if (!shooter.isAiming) { return(false); } if (!shooter.currentWeapon) { return(false); } if (!shooter.currentAmmo) { return(false); } float fireRateValue = this.fireRate.GetValue(shooter.gameObject); if (!shooter.CanShootFireRate(this.ammoID, fireRateValue)) { return(false); } return(true); }