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