Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BERKYT
- {
- class Program
- {
- static void Main(string[] args)
- {
- Tools tools = new Tools();
- bool checkout = true;
- while (checkout)
- {
- Console.WriteLine("Что Вы хотите сделать?" + "\n");
- Console.WriteLine("1 - Узнать информацию о каждом бойце.");
- Console.WriteLine("2 - Узнать информацию обо всей армии.");
- Console.WriteLine("3 - Атаковать.");
- Console.WriteLine("4 - Выйти из игры." + "\n");
- string entertextuser = Console.ReadLine();
- switch (entertextuser)
- {
- case "1":
- tools.PrintInfoAboutEveryUnit();
- break;
- case "2":
- tools.PrintInfoAboutAllArmy();
- break;
- case "3":
- Console.Write("\n" + "Введите количество атак: ");
- string s_count = Console.ReadLine();
- try
- {
- int count = Convert.ToInt32(s_count);
- tools.Attack(count);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
- break;
- case "4":
- checkout = false;
- break;
- }
- }
- }
- }
- #region Базовый класс и его наследники.
- class Units
- {
- public int Health { get; set; }
- public int Damage { get; set; }
- public string Name { get; set; }
- public virtual void PrintInfo()
- {
- Console.WriteLine("Имя: " + Name + " Здоровье: " + Health + " Урон: " + Damage + " ");
- }
- public Units(int health, int damage, string name)
- {
- Health = health;
- Damage = damage;
- Name = name;
- }
- }
- class Mehs : Units
- {
- public string TypeOfAmmunition { get; set; }
- public string Curse { get; set; }
- public override void PrintInfo()
- {
- base.PrintInfo();
- Console.Write("Тип боеприпаса: " + TypeOfAmmunition + " Проклятье: " + Curse + "\n" + "\n");
- }
- public Mehs(int health, int damage, string name, string typeOfAmmunition, string curse) : base(health, damage, name)
- {
- TypeOfAmmunition = typeOfAmmunition;
- Curse = curse;
- }
- }
- class Animal : Units
- {
- public int Speed { get; set; }
- public override void PrintInfo()
- {
- base.PrintInfo();
- Console.Write("Скорость: " + Speed + "\n" + "\n");
- }
- public Animal(int health, int damage, int speed, string name) : base(health, damage, name)
- {
- Speed = speed;
- }
- }
- class Soldier : Units
- {
- public int Armor { get; set; }
- public string NameOfArmor { get; set; }
- public override void PrintInfo()
- {
- base.PrintInfo();
- Console.Write("Броня: " + Armor + " Название брони: " + NameOfArmor + "\n" + "\n");
- }
- public Soldier(int armor, int health, int damage, string name, string nameofarmor) : base(health, damage, name)
- {
- Armor = armor;
- NameOfArmor = nameofarmor;
- }
- }
- class Rider : Units
- {
- public int Armor { get; set; }
- public int Speed { get; set; }
- public string NameOfArmor { get; set; }
- public override void PrintInfo()
- {
- base.PrintInfo();
- Console.Write("Броня: " + Armor + " Скорость: " + Speed + " Название брони: " + NameOfArmor + "\n" + "\n");
- }
- public Rider(int armor, int health, int damage, int speed, string name, string nameofarmor) : base(health, damage, name)
- {
- Armor = armor;
- NameOfArmor = nameofarmor;
- Speed = speed;
- }
- }
- #endregion
- class Tools
- {
- #region Конструктор класса, поля и массивы классов, а также статистика.
- int alldamage = 0, allhealth = 0, allarmor = 0, countarmy = 6;
- int[] arrayhealth = new int[6];
- Mehs[] mehs = new Mehs[3];
- Rider riders = new Rider(20, 97, 19, 17, "Наез=Druid Жив = Wolf", "Leather Armor");
- Animal wolf = new Animal(28, 5, 17, "Wolf");
- Soldier druid = new Soldier(20, 69, 14, "Druid", "Leather Armor");
- public Tools()
- {
- mehs[0] = new Mehs(875, 15, "Catapult", "Bolt", "Sonic Draconic Bite");
- mehs[1] = new Mehs(716, 15, "Catapult", "Bolt", "Shrieking Ancestral Surge");
- mehs[2] = new Mehs(876, 26, "Catapult", "Bullet", "Astral Sonic Blast");
- allarmor += druid.Armor + riders.Armor;
- arrayhealth[0] = mehs[0].Health;
- arrayhealth[1] = mehs[1].Health;
- arrayhealth[2] = mehs[2].Health;
- arrayhealth[3] = riders.Health;
- arrayhealth[4] = wolf.Health;
- arrayhealth[5] = druid.Health;
- }
- public void Stats()
- {
- alldamage = 0; allhealth = 0;
- for (int i = 0; i < 3; i++)
- {
- alldamage += mehs[i].Damage;
- allhealth += mehs[i].Health;
- if (i == 1)
- {
- alldamage += wolf.Damage + druid.Damage + riders.Damage;
- allhealth += wolf.Health + druid.Health + riders.Health;
- }
- }
- }
- #endregion
- #region Методы вывода на консоль.
- public void PrintInfoAboutEveryUnit()
- {
- for (int i = 0; i < 2; i++)
- {
- mehs[i].PrintInfo();
- if (i == 1)
- {
- wolf.PrintInfo();
- druid.PrintInfo();
- riders.PrintInfo();
- }
- }
- }
- public void PrintInfoAboutAllArmy()
- {
- Stats();
- Console.WriteLine("Общий урон: " + alldamage + " Общая защита: " + allarmor + " Общее здоровье: " + allhealth + " Общая численность: " + countarmy + "\n");
- }
- #endregion
- public void Attack(int count)
- {
- if (countarmy > 0)
- {
- for (int j = 0; j < count; j++)
- {
- for (int i = 0; i < 6; i++)
- {
- Stats();
- if (arrayhealth[i] <= 0)
- continue;
- allarmor -= alldamage;
- if (allarmor < 0)
- {
- alldamage = allarmor * -1;
- allarmor = 0;
- }
- else if (allarmor > 0)
- return;
- arrayhealth[i] -= alldamage;
- if (arrayhealth[i] <= 0)
- {
- alldamage = arrayhealth[i] * -1;
- arrayhealth[i] = 0;
- countarmy--;
- }
- else if (arrayhealth[i] > 0)
- break;
- }
- }
- mehs[0].Health = arrayhealth[0];
- mehs[1].Health = arrayhealth[1];
- mehs[2].Health = arrayhealth[2];
- riders.Health = arrayhealth[3];
- wolf.Health = arrayhealth[4];
- druid.Health = arrayhealth[5];
- }
- else
- Console.WriteLine("\n" + "Вы уничтожили противника!"+ "\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement