Advertisement
dmitryzenevich

Untitled

Dec 29th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Delegates
  5. {
  6.     class Program
  7.     {
  8.         static ConsoleColor oldColor = Console.ForegroundColor;
  9.         static int Health = 1000;
  10.         static int Armor = 20;
  11.         static void ShowMessage(ConsoleColor color, string message)
  12.         {
  13.             oldColor = Console.ForegroundColor;
  14.             Console.ForegroundColor = color;
  15.             Console.WriteLine(message);
  16.             Console.ForegroundColor = oldColor;
  17.         }
  18.         static void SetDamage(int damage)
  19.         {
  20.             Health = Health - (damage - Armor);
  21.         }
  22.         static void Main(string[] args)
  23.         {
  24.             ShowMessage(ConsoleColor.Yellow, "Босс может атаковать в двух режимах: все атаки по очереди и случайной атакой");
  25.             bool isRandomAttack = (DateTime.Now.Millisecond % 2) == 0;
  26.             ShowMessage(ConsoleColor.Yellow, "Босс будет атаковать: " + (isRandomAttack ? "случайно" : "все атаки по очереди"));
  27.             Console.ReadLine();
  28.             int attackNumber = 0;
  29.             while (Health > 0)
  30.             {
  31.                 Console.Clear();
  32.                 ShowMessage(ConsoleColor.Red, "У вас здоровья: " + Health);
  33.                 int value = isRandomAttack ? DateTime.Now.Millisecond % 3 : attackNumber;
  34.                 switch (value)
  35.                 {
  36.                     case 0:
  37.                         ShowMessage(ConsoleColor.DarkRed, "Босс атаковал с немыслимой яростью своими руками");
  38.                         SetDamage(100);
  39.                         break;
  40.                     case 1:
  41.                         ShowMessage(ConsoleColor.DarkMagenta, "Босс исполнил новый альбом Ольги бузовой");
  42.                         SetDamage(140);
  43.                         break;
  44.                     case 2:
  45.                         ShowMessage(ConsoleColor.DarkGray, "Босс приуныл и рассказал вам о своём долгом пути и дал пару советов, после выпил ритуальный стопарь боярки");
  46.                         SetDamage(80);
  47.                         break;
  48.                     default:
  49.                         break;
  50.                 }
  51.                 if (!isRandomAttack)
  52.                     attackNumber = attackNumber > 2 ? 0 : attackNumber++;
  53.                 Thread.Sleep(4000);
  54.             }
  55.             Console.Clear();
  56.             ShowMessage(ConsoleColor.DarkGray, "Бой закончен, вы погибли");
  57.             Console.ReadKey();
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement