Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace BossAttack
- {
- class Program
- {
- static void Main(string[] args)
- {
- User Player = new User();
- MessageForUser Message = new MessageForUser();
- Boss Pavel = new Boss();
- int countAttack = 0;
- bool isRandomAttack = (DateTime.Now.Millisecond % 2) == 0;
- while(countAttack < 3)
- {
- Console.Clear();
- Message.PrintTheMessage(ConsoleColor.Yellow, "Босс может атаковать в двух режимах: все атаки по очереди и случайной атакой");
- Message.PrintTheMessage(ConsoleColor.Yellow, "Босс будет атаковать: " + (isRandomAttack ? "случайно" : "все атаки по очереди"));
- Message.PrintTheMessage(ConsoleColor.White, "Перед началом боя необходимо создать три атаки босса со своим текстом, цветом и урном. Приступим:");
- Message.PrintTheMessage(ConsoleColor.Cyan, "Введите название " + (countAttack + 1) + " атаки:");
- string nameAttack = Console.ReadLine();
- Message.PrintTheMessage(ConsoleColor.Cyan, "Введите текст " + (countAttack+1) + " атаки:");
- string textAttack = Console.ReadLine();
- Message.PrintTheMessage(ConsoleColor.Cyan, "Введите урон " + (countAttack +1)+ " атаки:");
- int.TryParse(Console.ReadLine(), out int damageAttack);
- Message.PrintTheMessage(ConsoleColor.Cyan, "Введите цвет текста " + (countAttack+1) + " атаки" +
- "\nДоступные цвета: красный, зеленый, синий, желтый, белый, серый");
- ConsoleColor textColor = ConsoleColor.Yellow;
- string color = Console.ReadLine();
- switch (color.ToLower())
- {
- case "красный":
- textColor = ConsoleColor.Red;
- break;
- case "зеленый":
- textColor = ConsoleColor.Green;
- break;
- case "синий":
- textColor = ConsoleColor.Blue;
- break;
- case "желтый":
- textColor = ConsoleColor.Yellow;
- break;
- case "белый":
- textColor = ConsoleColor.White;
- break;
- case "серый":
- textColor = ConsoleColor.Gray;
- break;
- }
- Pavel.AllAttacks[countAttack] = new Attack(nameAttack, textAttack, damageAttack, textColor);
- countAttack++;
- }
- Message.PrintTheMessage(ConsoleColor.Green, "Нажмите enter для начала боя");
- int attackNumber = 0;
- while (Player.Health > 0)
- {
- Console.Clear();
- Console.WriteLine("Атаки босса:");
- foreach (var element in Pavel.AllAttacks)
- {
- Console.Write(element.NameAttack + "|");
- }
- Console.WriteLine();
- Message.PrintTheMessage(ConsoleColor.Red, "У вас здоровья: " + Player.Health);
- Pavel.NextAttack(ref attackNumber, isRandomAttack, Message, Player);
- Thread.Sleep(3000);
- }
- Message.PrintTheMessage(ConsoleColor.DarkGreen, "Бой окончен, Вы погибли");
- }
- }
- public class MessageForUser
- {
- public void PrintTheMessage(ConsoleColor color, string message)
- {
- ConsoleColor oldColor = Console.ForegroundColor;
- Console.ForegroundColor = color;
- Console.WriteLine(message);
- Console.ForegroundColor = oldColor;
- }
- }
- public class Attack
- {
- public string NameAttack;
- public string TextAttack;
- public int Damage;
- public ConsoleColor Color;
- public Attack(string nameAttack, string textAttack, int damage, ConsoleColor color)
- {
- NameAttack = nameAttack;
- TextAttack = textAttack;
- Damage = damage;
- Color = color;
- }
- public void BossAttacks(User player, int armor, int forceAttack)
- {
- player.Health = player.Health - (forceAttack - armor);
- }
- public void ProcessBossAttackes(int number, MessageForUser message, Attack[] attacks, User player)
- {
- message.PrintTheMessage(attacks[number].Color, attacks[number].TextAttack);
- attacks[number].BossAttacks(player, player.Armor, attacks[number].Damage);
- }
- }
- public class Boss
- {
- public Attack[] AllAttacks = new Attack[3];
- public void NextAttack(ref int number, bool randomAttack, MessageForUser message, User player)
- {
- if (randomAttack)
- {
- int rand = DateTime.Now.Millisecond % 3;
- AllAttacks[rand].ProcessBossAttackes(rand, message, AllAttacks, player);
- }
- else
- {
- AllAttacks[number].ProcessBossAttackes(number, message, AllAttacks, player);
- number += 1;
- if (number > 2)
- {
- number = 0;
- }
- }
- }
- }
- public class User
- {
- public int Health { get; set; } = 1000;
- public int Armor { get; } = 20;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement