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(); } }