public override void UseSpecialAttack(Fighter enemyFighter) { BlockDamage(enemyFighter); }
public void BlockDamage(Fighter enemyFighter) { HpCount += enemyFighter.CurrentDamage; }
static void Main(string[] args) { Random random = new Random(); Fighter[] fighterArray = { new FighterTank(), new FighterMage(), new FighterSupport(), new FighterRifleman(), new FighterSwordman() }; Console.WriteLine("Выберите 2 бойцов"); for (int i = 0; i < fighterArray.Length; i++) { Console.Write($"{i + 1})"); fighterArray[i].ShowName(); } int firstFighterIndex = int.Parse(Console.ReadLine()) - 1; int secondFighterIndex = int.Parse(Console.ReadLine()) - 1; Fighter firstFighter = fighterArray[firstFighterIndex]; Fighter secondFighter = fighterArray[secondFighterIndex]; firstFighter.ShowInfo(false); secondFighter.ShowInfo(false); while (firstFighter.HpCount > 0 && secondFighter.HpCount > 0) { Console.ReadKey(); Console.WriteLine(); bool isCryticalDamageFirstFighter = CheckChance(random, firstFighter.CriticalDamageChance); bool isCryticalDamageSecondFighter = CheckChance(random, secondFighter.CriticalDamageChance); bool isSpecialAttackFirstFighter = CheckChance(random, firstFighter.CriticalDamageChance); bool isSpecialAttackSecondFighter = CheckChance(random, secondFighter.CriticalDamageChance); firstFighter.Attack(secondFighter, isCryticalDamageFirstFighter); secondFighter.Attack(firstFighter, isCryticalDamageSecondFighter); if (isSpecialAttackFirstFighter == true) { firstFighter.UseSpecialAttack(secondFighter); } if (isSpecialAttackSecondFighter == true) { secondFighter.UseSpecialAttack(firstFighter); } firstFighter.ShowInfo(isSpecialAttackFirstFighter); secondFighter.ShowInfo(isSpecialAttackSecondFighter); firstFighter.EstablishOriginDamage(); secondFighter.EstablishOriginDamage(); } if (firstFighter.HpCount <= 0 && secondFighter.HpCount <= 0) { Console.WriteLine("Ничья"); } else { if (firstFighter.HpCount <= 0) { Console.WriteLine("Второй игрок победил"); } if (secondFighter.HpCount <= 0) { Console.WriteLine("Первый игрок победил"); } } Console.ReadLine(); }
public abstract void UseSpecialAttack(Fighter enemyFighter);
public void SpellVampirism(Fighter enemyFighter) { CurrentDamage = enemyFighter.HpCount / 5; HpCount += CurrentDamage; Attack(enemyFighter, false); }
public override void UseSpecialAttack(Fighter enemyFighter) { Heal(); }
public override void UseSpecialAttack(Fighter enemyFighter) { SpellVampirism(enemyFighter); }
public void KillEnemyInstantly(Fighter enemyFighter) { CurrentDamage = enemyFighter.HpCount; Attack(enemyFighter, false); }
public override void UseSpecialAttack(Fighter enemyFighter) { KillEnemyInstantly(enemyFighter); }
public void ReflectDamage(Fighter enemyFighter) { CurrentDamage = enemyFighter.CurrentDamage; HpCount += enemyFighter.CurrentDamage; Attack(enemyFighter, false); }
public override void UseSpecialAttack(Fighter enemyFighter) { ReflectDamage(enemyFighter); }