Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace Delegates
- {
- class Program
- {
- static void Main(string[] args)
- {
- int Health = 1000;
- int Armor = 20;
- string[] arrAttaksString = { "Босс атаковал с немыслимой яростью своими руками", "Босс исполнил новый альбом Ольги Бузовой", "Босс паник и рассказал вам о своём долгом пути и дал пару советов, после выпил ритуальный стопарь боярки" };
- ConsoleColor[] arrAttaksColor = { ConsoleColor.DarkRed, ConsoleColor.DarkMagenta, ConsoleColor.DarkGray };
- int[] arrAttaksDamage = { 100, 140, 80 };
- bool isRandomAttack = (DateTime.Now.Millisecond % 2) == 0;
- int attackNumber = -1;
- showMessage(ConsoleColor.Yellow, "Босс может атаковать в двух режимах: все атаки по очереди и случайной атакой" +
- "\nБосс будет атаковать: " + (isRandomAttack ? "случайно" : "все атаки по очереди"));
- showMessage(ConsoleColor.Green, "Нажмите enter для начала боя");
- Console.ReadLine();
- while (Health > 0)
- {
- Console.Clear();
- showMessage(ConsoleColor.Red, "У вас здоровья: " + Health);
- if (isRandomAttack)
- {
- attackNumber = DateTime.Now.Millisecond % 3;
- }
- else
- {
- attackNumber++;
- if (attackNumber > 2)
- {
- attackNumber = 0;
- }
- }
- showMessage(arrAttaksColor[attackNumber], arrAttaksString[attackNumber], arrAttaksDamage[attackNumber]);
- Thread.Sleep(4000);
- }
- showMessage(ConsoleColor.DarkGray, "Бой закончен, вы погибли");
- Console.ReadKey();
- void showMessage(ConsoleColor consColor, string Message, int Damage = 0)
- {
- ConsoleColor oldColor = Console.ForegroundColor;
- Console.ForegroundColor = consColor;
- Console.WriteLine(Message);
- Console.ForegroundColor = oldColor;
- Health = Health - (Damage - Armor);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement