Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Гладиаторские_бои
- {
- class gladiator
- {
- public string name { get; private set; }
- public int health { get; private set;}
- public int uron { get; private set;}
- string kontur1= "\\____/ " + "\n|*_ *|\n ____\n| |\n ____\n/ \\\n";
- string kontur21;
- string kontur22;
- public gladiator(string inputname,int inputhealth, int inputuron,string inputkontur21,string inputkontur22)
- {
- name=inputname;
- health=inputhealth;
- uron=inputuron;
- kontur21= inputkontur21;
- kontur22= inputkontur22;
- }
- public void drawgladiator(int inputX, int inputY,string direction)
- {
- int X = inputX;
- int Y = inputY;
- switch (direction)
- {
- case "right":
- string[] array1 = kontur21.Split("\n"); //разбиваем строку игрока на массив элементов
- for (int i = 0; i < array1.Length; i++)
- {
- Console.SetCursorPosition(X, Y + i);
- Console.Write(array1[i]);
- }
- break;
- case "left":
- string[] array2 = kontur22.Split("\n"); //разбиваем строку игрока на массив элементов
- for (int i = 0; i < array2.Length; i++)
- {
- Console.SetCursorPosition(X, Y + i);
- Console.Write(array2[i]);
- }
- break;
- case "0":
- string[] array = kontur1.Split("\n"); //разбиваем строку игрока на массив элементов
- for (int i = 0; i < array.Length; i++)
- {
- Console.SetCursorPosition(X, Y + i);
- Console.Write(array[i]);
- }
- break;
- default:
- break;
- }
- }
- public void showstats()
- {
- Console.WriteLine("Имя: " + name + "\nHP: " + health + "\nДамаг: " + uron);
- }
- public void suffer(gladiator gladiator)
- {
- health -= gladiator.uron;
- }
- }
- class arena
- {
- gladiator[] gladiators = new gladiator[0];
- //
- public arena(gladiator[] inputgladiators)
- {
- gladiators = new gladiator[inputgladiators.Length];
- for (int i = 0; i < gladiators.Length; i++)
- {
- gladiators[i] = inputgladiators[i];
- }
- }
- public void deletegladiator(int num1)
- {
- gladiator[] temp = new gladiator[gladiators.Length-1];
- for (int i = num1+1; i < temp.Length; i++)
- {
- gladiators[i - 1] = gladiators[i];//после символа с индексом удаления, мы присваиваем предыдущим элементам значение последующих,смещая элементы влево на 1
- }
- for (int i = 0; i < temp.Length; i++)
- {
- temp[i] = gladiators[i]; //и затем, когда нужные элементы умещаются в длину-1, перемещаем их в temp
- }
- gladiators = temp;
- }
- public void bitva()
- {
- gladiator[] igroki = new gladiator[2];
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("Выберите героя: ");
- Console.ForegroundColor = ConsoleColor.White;
- for (int i = 0; i < gladiators.Length; i++)
- {
- Console.Write(i + 1 + ") ");
- gladiators[i].showstats();
- gladiators[i].drawgladiator(25,i*7,"right");
- Console.WriteLine();
- }
- Console.Write("Герой 1: ");
- int num1 = Convert.ToInt32(Console.ReadLine()) - 1;
- igroki[0] = gladiators[num1];
- deletegladiator(num1);
- Console.Clear();
- for (int i = 0; i < gladiators.Length; i++)
- {
- Console.Write(i + 1 + ") ");
- gladiators[i].showstats();
- gladiators[i].drawgladiator(25, i * 7, "right");
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.Write("Герой 2: ");
- igroki[1] = gladiators[Convert.ToInt32(Console.ReadLine()) - 1];
- Console.WriteLine();
- Console.Clear();
- Console.WriteLine("Битва начинается!");
- Console.ReadKey();
- Console.Clear();
- while (igroki[0].health>0 & igroki[1].health > 0)
- {
- igroki[0].showstats();
- igroki[1].showstats();
- igroki[0].drawgladiator(20,20,"0");
- igroki[1].drawgladiator(55, 20, "0");
- Console.ReadKey();
- Console.ForegroundColor = ConsoleColor.Red;
- igroki[0].drawgladiator(20, 20, "right");
- igroki[1].drawgladiator(55, 20, "left");
- Console.ForegroundColor = ConsoleColor.White;
- igroki[0].suffer(igroki[1]);
- igroki[1].suffer(igroki[0]);
- Console.ReadKey();
- Console.Clear();
- }
- if(igroki[0].health> igroki[1].health)
- {
- Console.WriteLine(igroki[0].name + " - Победитель!");
- Console.ForegroundColor = ConsoleColor.Green;
- igroki[0].drawgladiator(0, 5, "right");
- Console.ForegroundColor = ConsoleColor.White;
- }
- if (igroki[1].health > igroki[0].health)
- {
- Console.WriteLine(igroki[1].name + " - Победитель!");
- Console.ForegroundColor = ConsoleColor.Green;
- igroki[1].drawgladiator(0, 5, "right");
- Console.ForegroundColor = ConsoleColor.White;
- }
- if (igroki[1].health == igroki[0].health)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Ничья");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- bool open = true;
- while(open)
- {
- gladiator[] gladiators = {
- new gladiator("Кинжальщик", 100, 5, "\\____/ " + "\n|*_ *|\n ____\n| |____\n ____\n/ \\\n", " \\____/ " + "\n |*_ *|\n ____\n____| |\n ____\n / \\\n"),
- new gladiator("Лучник",100,7, "\\____/ " + "\n|*_ *|\n ____\n| |____\n ____\n/ \\\n", " \\____/ " + "\n |*_ *|\n ____\n____| |\n ____\n / \\\n"),
- new gladiator("Меченосец", 100, 12, "\\____/ " + "\n|*_ *|\n ____\n| |____\n ____\n/ \\\n", " \\____/ " + "\n |*_ *|\n ____\n____| |\n ____\n / \\\n"),
- new gladiator("Рукопашник",100,2, "\\____/ " + "\n|*_ *|\n ____\n| |____\n ____\n/ \\\n", " \\____/ " + "\n |*_ *|\n ____\n____| |\n ____\n / \\\n"),
- new gladiator("Владелец картечи",100,7, "\\____/ " + "\n|*_ *|\n ____\n| |____\n ____\n/ \\\n", " \\____/ " + "\n |*_ *|\n ____\n____| |\n ____\n / \\\n")
- };
- Console.WriteLine("Поиграем?\n1.Да\n2.Выход");
- string sw=Console.ReadLine();
- switch (sw)
- {
- case "1":
- Console.Clear();
- arena arena1 = new arena(gladiators);
- arena1.bitva();
- break;
- case "2":
- open = false;
- break;
- default:
- break;
- }
- Console.ReadLine();
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment