private void LaunchProjectile() { ManaManager launcher = GetComponentInParent <ManaManager>(); float chargeNormalized = 1f; if (maxChargeTime != 0f) { chargeNormalized = currentChargeTime / maxChargeTime; } float realManaCost = manaCost * (1 + ManaChargeScale * chargeNormalized); if (CanLaunch(launcher, realManaCost)) { GameObject projectile = Instantiate <GameObject>(projectilePrefab); MagicProjectile magic = projectile.GetComponent <MagicProjectile>(); magic.Launcher = launcher; magic.Power = chargeNormalized; magic.Damage = minDamages + ((maxDamages - minDamages) * chargeNormalized); magic.OnKill = delegate(IDamageable target) { if (OnKill != null) { OnKill(this, new OnKillArgs(target)); } }; launcher.RemoveMana(realManaCost); } }
void RemoveMana(int playerIndex) { manaManager.RemoveMana(playerIndex); players[playerIndex].maxMana--; UpdateMana(); }