Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WarriorsBattle
- {
- class Program
- {
- static void Main(string[] args)
- {
- int warriorIndex;
- Warrior[] warriors =
- {
- new Mage ("- Mage - ",250, 70, 15),
- new Rogue ("- Rogue - ", 250, 100, 30),
- new Tank ("- Tank - ", 400, 70, 50),
- new Gladiator ("- Gladiator - ",250, 130, 15),
- new Monk ("- Monk - ",250, 90, 50)
- };
- for (int i = 0; i < warriors.Length; i++)
- {
- Console.Write(i + " ");
- warriors[i].ShowAllStats();
- }
- Console.WriteLine("\n Выберите первого бойца: ");
- warriorIndex = Convert.ToInt32(Console.ReadLine());
- Warrior firstWarrior = warriors[warriorIndex];
- Console.WriteLine(" Вы выбрали - " + firstWarrior.name);
- firstWarrior.ShowAllStats();
- Console.WriteLine(" Выберите второго бойца: ");
- warriorIndex = Convert.ToInt32(Console.ReadLine());
- Warrior secondWarrior = warriors[warriorIndex];
- Console.WriteLine(" Вы выбрали - " + secondWarrior.name);
- secondWarrior.ShowAllStats();
- System.Console.WriteLine("Нажмите любую клавишу чтобы начать бой");
- Console.ReadKey();
- while (firstWarrior.Health > 0 && secondWarrior.Health > 0)
- {
- System.Console.WriteLine(" --- Do Specials --- ");
- firstWarrior.DoSpecial();
- secondWarrior.DoSpecial();
- firstWarrior.ShowAllStats();
- secondWarrior.ShowAllStats();
- System.Console.WriteLine(" --- Do Attack --- ");
- firstWarrior.TakenDamage(secondWarrior.Damage);
- secondWarrior.TakenDamage(firstWarrior.Damage);
- firstWarrior.ShowAllStats();
- secondWarrior.ShowAllStats();
- }
- if (firstWarrior.Health > 0)
- System.Console.WriteLine($"Победил {firstWarrior.name}");
- else if (secondWarrior.Health > 0)
- System.Console.WriteLine($"Победил {secondWarrior.name}");
- }
- }
- class Warrior //Общий класс
- {
- public string name;
- public int Health;
- public int Damage;
- public int Armor;
- public Warrior(string name, int health, int damage, int armor)
- {
- this.name = name;
- Health = health;
- Damage = damage;
- Armor = armor;
- }
- public Warrior(int health, int damage, int armor) //Конструктор
- {
- Health = health;
- Damage = damage;
- Armor = armor;
- }
- public void TakenDamage(int damage)
- {
- Health -= damage - Armor;
- }
- public void ShowAllStats()
- {
- Console.WriteLine(name + "Здоровья " + Health + " Урон " + Damage + " Броня " + Armor);
- }
- public virtual void DoSpecial()
- {
- throw new NotImplementedException();
- }
- }
- class Mage : Warrior
- {
- public Mage(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- {
- }
- public void FireCast()
- {
- Damage += 100;
- Armor -= 5;
- }
- public override void DoSpecial()
- {
- FireCast();
- }
- }
- class Rogue : Warrior
- {
- public Rogue(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- { }
- public void Evade()
- {
- Health -= Damage * 0;
- }
- public override void DoSpecial()
- {
- Evade();
- }
- }
- class Tank : Warrior
- {
- public Tank(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- { }
- public void ShieldsUp()
- {
- Armor += 100;
- }
- public override void DoSpecial()
- {
- ShieldsUp();
- }
- }
- class Gladiator : Warrior
- {
- public Gladiator(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- { }
- public void CriticalBlow()
- {
- Damage *= 2;
- }
- public override void DoSpecial()
- {
- CriticalBlow();
- }
- }
- class Monk : Warrior
- {
- public Monk(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- { }
- public void CriticalBlow()
- {
- Health += 15;
- }
- public override void DoSpecial()
- {
- CriticalBlow();
- }
- }
- }
Add Comment
Please, Sign In to add comment