pol9na

Гладиаторские бои

Mar 31st, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Study
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Spartak spartak = new Spartak(100,5, 50);
  13.             Kriks kriks = new Kriks(100, 1, 20, 20);
  14.             Gannik gannik = new Gannik(75,16, 25);
  15.             Kast kast = new Kast(80, 10, 30);
  16.             Narciss narciss = new Narciss(60, 30, 15);
  17.             string playerSelection;
  18.             Gladiator[] gladiators = { spartak, kriks, gannik, kast, narciss };
  19.             int gladiatorIndex;
  20.             for (int i = 0; i < gladiators.Length; i++)
  21.             {
  22.                 Console.Write(i + " ");
  23.                 gladiators[i].ShowInfo();
  24.             }
  25.             Console.WriteLine("Молитва прибавляет 2 к броне. ВААГХ!-забирает 2 единицы брони. Прибавляет 10 единиц здоровья. Берсерк убирает 2 единицы брони. Прибавляет 5 единиц урона.Аптечка-прибавляет 5 единиц здоровья. Кровавое заклятие забирает 5 единиц здоровья. Прибавляет 5 единиц урона");
  26.             Console.Write("Выберите бойца правых ворот:");
  27.             gladiatorIndex = Convert.ToInt32(Console.ReadLine());
  28.             Gladiator rightGladiator = gladiators[gladiatorIndex];
  29.             Console.Write("Выберите бойца левых ворот:");
  30.             gladiatorIndex = Convert.ToInt32(Console.ReadLine());
  31.             Gladiator leftGladiator = gladiators[gladiatorIndex];
  32.  
  33.             while (leftGladiator.Health > 0 && rightGladiator.Health > 0)
  34.             {
  35.                 Console.WriteLine("Ходит боец  правых ворот. Выберите 1 для простой атаки. Выберите 2 для спецатаки");
  36.  
  37.                 playerSelection = Console.ReadLine();
  38.                 switch (playerSelection)
  39.                 {
  40.                     case "1":
  41.                         leftGladiator.TakeDamage(rightGladiator.Damage);
  42.                         break;
  43.                     case "2":
  44.                         Console.WriteLine("Спецатака");
  45.                         break;
  46.                     default:
  47.                         Console.WriteLine("Выберети команду");
  48.                         break;
  49.                 }
  50.                 leftGladiator.ShowInfo();
  51.                 rightGladiator.ShowInfo();
  52.                 Console.WriteLine("Ходит боец  левых ворот. Выберите 1 для простой атаки. Выберите 2 для спецатаки");
  53.                 playerSelection = Console.ReadLine();
  54.                 switch (playerSelection)
  55.                 {
  56.                     case "1":
  57.                         rightGladiator.TakeDamage(leftGladiator.Damage);
  58.                         break;
  59.                     case "2":
  60.                         Console.WriteLine("Спецатака");
  61.                         break;
  62.                     default:
  63.                         Console.WriteLine("Выберети команду");
  64.                         break;
  65.  
  66.                 }
  67.                
  68.                 leftGladiator.ShowInfo();
  69.                 rightGladiator.ShowInfo();
  70.  
  71.                 if (leftGladiator.Health < 0)
  72.                 {
  73.                     Console.WriteLine("Победил боец правых ворот");
  74.                 }
  75.                 else
  76.                 {
  77.                     Console.WriteLine("Победил боец левых ворот");
  78.                 }
  79.  
  80.             }
  81.         }
  82.     }
  83.     class Gladiator
  84.     {
  85.         protected int _health;
  86.         protected int _armor;
  87.         protected int _damage;
  88.         protected string _name;
  89.         protected string _specialAbility;
  90.         public int Health
  91.         {
  92.             get
  93.             {
  94.                 return _health;
  95.             }
  96.  
  97.         }
  98.         public int Damage
  99.         {
  100.             get
  101.             {
  102.                 return _damage;
  103.             }
  104.         }
  105.  
  106.         public Gladiator(string name,int health, int armor, int damage, string specialAbility)
  107.         {
  108.             _health = health;
  109.             _armor = armor;
  110.             _damage = damage;
  111.             _name = name;
  112.             _specialAbility = specialAbility;
  113.         }
  114.  
  115.         public void TakeDamage(int damage)
  116.         {
  117.             _health -= damage - _armor;
  118.  
  119.         }
  120.         public void ShowInfo()
  121.         {
  122.             Console.WriteLine("Имя " + _name + " Количество жизни " + _health + " Броня " + _armor + " Урон " + _damage + " Спецспособность "+ _specialAbility);
  123.         }
  124.     }
  125.     class Spartak : Gladiator
  126.     {
  127.         public Spartak(int health,int armor, int damage) : base("Spartak", health, armor, damage, "Молитва")
  128.         {
  129.            
  130.         }
  131.         public void Pray()
  132.         {
  133.             _armor += 2;
  134.         }
  135.  
  136.     }
  137.     class Kriks : Gladiator
  138.     {
  139.         public int AttackSpeed;
  140.  
  141.         public Kriks(int health, int armor, int damage, int attackSpeed) : base("Kriks",health, armor, damage * attackSpeed, "ВАААГХ!!")
  142.         {
  143.             AttackSpeed = attackSpeed;
  144.  
  145.         }
  146.         public void specialAbility()
  147.         {
  148.             _armor -= 2;
  149.             _health += 10;
  150.         }
  151.  
  152.  
  153.     }
  154.  
  155.     class Gannik : Gladiator
  156.     {
  157.         public Gannik (int health, int armor, int damage) : base("Gannik",health, armor, damage, "Берсерк")
  158.         {
  159.  
  160.         }
  161.         public void specialAbility()
  162.         {
  163.             _armor -= 2;
  164.             _damage += 5;
  165.         }
  166.     }
  167.     class Kast : Gladiator
  168.     {
  169.         public Kast(int health, int armor, int damage) : base("Kast",health, armor, damage, "Аптечка")
  170.         {
  171.  
  172.         }
  173.         public void specialAbility()
  174.         {
  175.             _health += 5;
  176.         }
  177.     }
  178.  
  179.     class Narciss : Gladiator
  180.     {
  181.         public Narciss(int health, int armor, int damage) : base("Narciss",health, armor, damage,"Кровавое заклятие")
  182.         {
  183.  
  184.         }
  185.         public void specialAbility()
  186.         {
  187.             _damage += 5;
  188.             _health -= 5;
  189.         }
  190.     }
  191. }
Add Comment
Please, Sign In to add comment