Esempio n. 1
0
        //TODO: Delete this method. Should be handled by the BattleManager
        public int Attack(IFighter opponent, double attackMultiplier = 1.0, bool isCrit = false)
        {
            var damage = Strength - opponent.Defense;

            if (isCrit)
            {
                OnCriticalAttack(new CriticalAttackEventArgs());
            }

            damage = (int)(damage * attackMultiplier);

            if (damage < 0)
            {
                damage = 0;
            }

            var damageDealt = opponent.PhysicalDamage(damage);

            OnAttackSuccessful(new AttackSuccessfulEventArgs(opponent, damageDealt));

            if (!opponent.IsAlive())
            {
                OnEnemyKilled(new EnemyKilledEventArgs(opponent));
            }

            return(damageDealt);
        }