public void Attack(GameObject victim) { attackerStats = owner.GetComponent <FighterStats>(); targetStats = victim.GetComponent <FighterStats>(); if (attackerStats.magic >= magicCost) { float multiplier = Random.Range(minAttackMultiplier, maxAttackMultiplier); damage = multiplier * attackerStats.melee; if (magicAttack) { damage = multiplier * attackerStats.magicRange; } float defenseMultiplier = Random.Range(minDefenseMultiplier, maxDefenseMultiplier); damage = Mathf.Max(0, damage - (defenseMultiplier * targetStats.defense)); owner.GetComponent <Animator>().Play(animationName); targetStats.ReceiveDamage(Mathf.CeilToInt(damage)); attackerStats.UpdateMagicFill(magicCost); } else { Task.Delay(2000); Debug.Log("Turn skipped"); attackerStats.ContinueGame(); } }
public void Attack(GameObject victim) { attackerStats = owner.GetComponent <FighterStats>(); targetStats = victim.GetComponent <FighterStats>(); if (attackerStats.magic >= magicCost) { float multiplier = Random.Range(minAttackMultiplier, maxAttackMultiplier); damage = multiplier * attackerStats.attack; if (magicAttack) { damage = multiplier * attackerStats.intelligence; } float defenseMultiplier = Random.Range(minDefenseMultiplier, maxDefenseMultiplier); damage = targetStats.block - Mathf.Max(0, damage - (defenseMultiplier * targetStats.defense)); if (damage < 0) { damage = 0; } owner.GetComponent <Animator>().Play(animationName); targetStats.ReceiveDamage(Mathf.CeilToInt(damage)); attackerStats.UpdateMagicFill(magicCost); } else { Invoke("SkipTurnContinueGame", 2); } }