WeaponSystem.FireWeaponSystem C# (CSharp) Method

FireWeaponSystem() private method

The actual method that handles the shooting of the currently selected weapon with the currently selected ammo
private FireWeaponSystem ( ) : IEnumerator
return IEnumerator
    private IEnumerator FireWeaponSystem()
    {
        // Call the Current Weapon Fire method with the loaded ammo and the
        // game object to which the weapon system is atached to ( player ship )

        // Calculate modifiers for the Weapon rate of fire :
        var baseAmmo = (AmmoBase)LoadedAmmo.GetComponent(typeof(AmmoBase));
        var weapon = (WeaponBase) CurrentWeapon.GetComponent(typeof (WeaponBase));

        // Get the modifiers from the weapon
        var rateOfFireModifier = baseAmmo.WeaponRateOfFireModifier;

        weapon.Fire(LoadedAmmo, Player);

        canFire = false;

        var timeToNextFire = weapon.RateOfFire / rateOfFireModifier;
        yield return new WaitForSeconds(timeToNextFire);

        canFire = true;
    }