Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- namespace ConsoleApplication58
- {
- class Program
- {
- private static bool isOpen, isHaveHands, isHaveKey, easyGiant, play; //Задача 1
- private static int number, x, y;
- static void Main(string[] args)
- {
- while (true)
- {
- play = true;
- Settings();
- Loading();
- StartWindow();
- ChooseYourComplication();
- Intro();
- YourChoice();
- Console.Clear();
- }
- }
- private static void Settings()
- {
- Console.SetWindowSize(100, 40);
- Console.Title = "Небольшое приключение";
- }
- private static void Indent()
- {
- for (int i = 0; i < 7; i++)
- {
- Console.WriteLine("\n");
- }
- }
- private static void LoadingBinary()
- {
- Console.ForegroundColor = ConsoleColor.Green;
- for (int i = 0; i < Console.WindowWidth; i++)
- {
- Random r = new Random();
- int randomBinary = r.Next(0, 2);
- Console.Write(randomBinary);
- Thread.Sleep(20);
- }
- }
- private static void LoadingText()
- {
- Console.ResetColor();
- Console.WriteLine();
- Console.WriteLine("█───████─████─████──███─█──█─████".PadLeft(64));
- Thread.Sleep(300);
- Console.WriteLine("█───█──█─█──█─█──██──█──██─█─█ ".PadLeft(64));
- Thread.Sleep(300);
- Console.WriteLine("█───█──█─████─█──██──█──█─██─█─██".PadLeft(64));
- Thread.Sleep(300);
- Console.WriteLine("█───█──█─█──█─█──██──█──█──█─█──█".PadLeft(64));
- Thread.Sleep(300);
- Console.WriteLine("███─████─█──█─████──███─█──█─████".PadLeft(64));
- Console.WriteLine();
- }
- private static void Loading()
- {
- Indent();
- LoadingBinary();
- LoadingText();
- LoadingBinary();
- Console.Clear();
- Console.ResetColor();
- }
- private static void RandomForegroundColor()
- {
- Random r = new Random();
- int randomBinary = r.Next(0, 8);
- Console.Write(randomBinary);
- switch (randomBinary)
- {
- case 0:
- Console.ForegroundColor = ConsoleColor.Blue;
- break;
- case 1:
- Console.ForegroundColor = ConsoleColor.Cyan;
- break;
- case 2:
- Console.ForegroundColor = ConsoleColor.Green;
- break;
- case 3:
- Console.ForegroundColor = ConsoleColor.Red;
- break;
- case 4:
- Console.ForegroundColor = ConsoleColor.Yellow;
- break;
- case 5:
- Console.ForegroundColor = ConsoleColor.Magenta;
- break;
- case 6:
- Console.ForegroundColor = ConsoleColor.White;
- break;
- case 7:
- Console.ResetColor();
- break;
- }
- }
- private static void StartWindow()
- {
- Console.CursorVisible = false;
- ConsoleKeyInfo cki = new ConsoleKeyInfo();
- while (cki.Key != ConsoleKey.Enter)
- {
- RandomForegroundColor();
- Console.Clear();
- Indent();
- Console.WriteLine("████─████─███─███─███ ███─█──█─███─███─████ ███─████ ███─███─████─████─███".PadLeft(88));
- Console.WriteLine("█──█─█──█─█───█───█ █───██─█──█──█───█──█ ─█──█──█ █────█──█──█─█──█──█ ".PadLeft(88));
- Console.WriteLine("████─████─███─███─███ ███─█─██──█──███─████ ─█──█──█ ███──█──████─████──█ ".PadLeft(88));
- Console.WriteLine("█────█─█──█─────█───█ █───█──█──█──█───█─█ ─█──█──█ ──█──█──█──█─█─█───█ ".PadLeft(88));
- Console.WriteLine("█────█─█──███─███─███ ███─█──█──█──███─█─█ ─█──████ ███──█──█──█─█─█───█ ".PadLeft(88));
- Thread.Sleep(700);
- Console.Clear();
- if (Console.KeyAvailable == true)
- {
- cki = Console.ReadKey(true);
- }
- }
- Console.CursorVisible = true;
- }
- private static void Countinue()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.BackgroundColor = ConsoleColor.White;
- Console.WriteLine(" Продолжить>>");
- Console.ResetColor();
- Console.ReadLine();
- Console.Clear();
- }
- private static void ChooseYourComplication()
- {
- Console.ForegroundColor = ConsoleColor.Magenta;
- Console.WriteLine(" Выберите сложность: ");
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("\n 1 - Легкая\n");
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine(" 2 - Средняя\n");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(" 3 - Сложная/Невозможная\n");
- Console.ResetColor();
- СheckedExceptions(1);
- switch (number)
- {
- case 1:
- isOpen = true;
- isHaveHands = true;
- isHaveKey = true;
- easyGiant = true;
- break;
- case 2:
- isOpen = false;
- isHaveHands = true;
- isHaveKey = false;
- easyGiant = true;
- break;
- case 3:
- isOpen = false;
- isHaveHands = true;
- isHaveKey = false;
- easyGiant = false;
- break;
- }
- }
- private static void Intro()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine();
- Console.BackgroundColor = ConsoleColor.White;
- Console.WriteLine(" ".PadLeft(44) + "Предыстория:".PadRight(56)); //Не захотел делать метод под отцентровку
- Console.ResetColor();
- Console.WriteLine("\n Вы проснулись в странной комнате и чувствуете себя скверно.\n Что было вчера не помните.");
- Console.WriteLine("\n Осмотревшись, вы увидели дверь ведущую к выходу из комнаты \n и доброго великана, который идет к вам.\n");
- Countinue();
- }
- private static int СheckedExceptions(int script)
- {
- string str = Console.ReadLine();
- bool isNum = int.TryParse(str, out number);
- if (isNum && (number == 1 || number == 2 || number == 3))
- {
- Countinue();
- }
- else
- {
- Console.WriteLine("\nВы ввели неверное значение. Давайте попробуем еще раз!\n");
- Countinue();
- Console.Clear();
- if (script == 1)
- {
- ChooseYourComplication();
- }
- else if (script == 2)
- {
- YourChoice();
- }
- else
- {
- Talk();
- }
- }
- return number;
- } //Задача 5, 6
- private static void YourChoice()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.BackgroundColor = ConsoleColor.White;
- Console.WriteLine(" У вас есть выбор:\n");
- Console.ResetColor();
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("\n 1 - Подбежать к двери и попробовать сбежать из комнаты");
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("\n 2 - Уболтать великана");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("\n 3 - Сразится с великаном и отобрать у него ключи от двери");
- Console.ResetColor();
- СheckedExceptions(2);
- switch (number)
- {
- case 1:
- OpenDoor();
- break;
- case 2:
- Talk();
- break;
- case 3:
- Fight();
- break;
- }
- }
- private static void OpenDoor()
- {
- if ((isOpen || isHaveHands && isHaveKey) && play) //Задача 2
- {
- Console.WriteLine("Вам удалось открыть дверь и пробраться в лабиринт.");
- Console.ReadKey();
- Labyrinth();
- }
- else
- {
- Console.WriteLine("Вам не удалось открыть дверь. Великану не понравилось то что вы убегаите \nи теперь он будет драться с вами.");
- Console.ReadKey();
- Fight();
- }
- }
- private static void Talk()
- {
- Console.WriteLine("Вы можете что-то сказать великану: ");
- string say = Console.ReadLine();
- Console.WriteLine("Великан страдает глухотой. Сколько раз скажите?: ");
- СheckedExceptions(3);
- for (int i = 1; i <= number; i++) //Задача 3
- {
- Console.WriteLine(say);
- }
- Countinue();
- if (easyGiant)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Великан: ");
- Console.ResetColor();
- Console.WriteLine("I don't understand you.. Argh.. Go away!");
- Console.WriteLine("Великан отпустил вас и вы попали в лабиринт.");
- Console.ReadKey();
- Labyrinth();
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Великан: ");
- Console.ResetColor();
- Console.WriteLine("I don't anderstand you.. Argh.. And I just eat you!");
- Console.ReadKey();
- GameOver();
- }
- }
- private static void Fight()
- {
- if (easyGiant)
- {
- Console.WriteLine("\nВам удалось одолеть великана, забрать ключи от комнаты и уйти в лабиринт.");
- Console.ReadKey();
- Labyrinth();
- }
- else
- {
- Console.WriteLine("Великан оказался слишком сильным. Вы стали основным ингридиентом его супа(");
- Console.ReadKey();
- GameOver();
- }
- }
- private static void LabyrinthMove()
- {
- x = 44;
- y = 15;
- while (play)
- {
- LabyrinthMap();
- Console.SetCursorPosition(x, y);
- Console.Write("◄►");
- Console.ResetColor();
- Thread.Sleep(500);
- ConsoleKey k = Console.ReadKey(true).Key;
- if (k == ConsoleKey.D)
- {
- x += 2;
- if (x > Console.WindowWidth - 1)
- {
- x = Console.WindowWidth - 1;
- }
- }
- if (k == ConsoleKey.A)
- {
- x -= 2;
- if (x < 0)
- {
- x = 0;
- }
- }
- if (k == ConsoleKey.W)
- {
- y -= 1;
- if (y < 0)
- {
- y = 0;
- }
- }
- if (k == ConsoleKey.S)
- {
- y += 1;
- if (y > Console.WindowHeight - 1)
- {
- y = Console.WindowHeight - 1;
- }
- }
- Console.Clear();
- Console.SetCursorPosition(x, y);
- Console.Write("◄►");
- if (x == 48 && y == 30)
- {
- YouWon();
- }
- else
- {
- LabyrinthBorders();
- }
- }
- }
- private static void LabyrinthMap()
- {
- Console.SetCursorPosition(0, 0);
- Indent();
- Console.WriteLine("██████████████▒▒██████████████".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒▒▒██████████████ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒▒▒▒▒ ██".PadLeft(60));
- Console.WriteLine("██████▒▒██████████████████ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒ ██".PadLeft(60));
- Console.WriteLine("██▒▒██████ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒██ ██████████████ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒██ ▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██████████ ▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒██ ▒▒▒▒██ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒██ ██████ ██".PadLeft(60));
- Console.WriteLine("██▒▒▒▒▒▒▒▒ ██".PadLeft(60));
- Console.WriteLine("██████████████████ ██████████".PadLeft(60));
- Console.SetCursorPosition(48, 30);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("██");
- }
- private static void LabyrinthBorders()
- {
- if (y == 30 || x == 30 || x == 58 || y == 14 || (x <= 42 && y <= 20)
- || (x <= 38 && y <= 30) || ((x <= 46 && x >= 42) && (y <= 28 && y >= 24))
- || ((y == 18 || y == 20 || y == 24) && (x >= 42 && x <= 54)))
- {
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("\n Вы погибли");
- Console.ResetColor();
- Console.WriteLine();
- Countinue();
- GameOver();
- }
- }
- private static void Labyrinth()
- {
- Console.Clear();
- Console.CursorVisible = false;
- LabyrinthMove();
- Console.CursorVisible = true;
- } //Задача 7
- private static void GameOver()
- {
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.Red;
- Indent();
- Console.WriteLine("████─████─█───█─███ ████─█─█─███─████".PadLeft(66));
- Console.WriteLine("█────█──█─██─██─█ █──█─█─█─█───█──█".PadLeft(66));
- Console.WriteLine("█─██─████─█─█─█─███ █──█─█─█─███─████".PadLeft(66));
- Console.WriteLine("█──█─█──█─█───█─█ █──█─███─█───█─█ ".PadLeft(66));
- Console.WriteLine("████─█──█─█───█─███ ████──█──███─█─█ ".PadLeft(66));
- PlayAgain();
- }
- private static void YouWon()
- {
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.Green;
- Indent();
- Console.WriteLine("██─██─████─█─█ █───█─████─█──█".PadLeft(65));
- Console.WriteLine("─███──█──█─█─█ █───█─█──█─██─█".PadLeft(65));
- Console.WriteLine("──█───█──█─█─█ █─█─█─█──█─█─██".PadLeft(65));
- Console.WriteLine("──█───█──█─█─█ █████─█──█─█──█".PadLeft(65));
- Console.WriteLine("──█───████─███ ─█─█──████─█──█".PadLeft(65));
- PlayAgain();
- }
- private static void PlayAgain()
- {
- Indent();
- Console.WriteLine("\n Сыграем еще? Y/N"); //Задача 4
- string str = Console.ReadLine();
- string answer = str.ToLower();
- if (answer == "y")
- {
- play = false;
- Console.Clear();
- }
- else if (answer == "n")
- {
- CreatedBy();
- System.Environment.Exit(1);
- }
- else
- {
- Console.WriteLine("Вы ввели неверное значение. Давайте попробуем еще раз!");
- Console.ReadKey();
- Console.Clear();
- PlayAgain();
- }
- }
- private static void CreatedBy()
- {
- Console.Clear();
- Indent();
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.WriteLine("████─████──███─████─████ ████─████─███─███─█───█ █─█─█─█─█─█──█─████─████ ".PadLeft(90));
- Console.WriteLine("█──█─█──██──█──█──█─█──█─█ █──█─█──█──█──█───██─██ █████─█─█─█─█──█──█─█──██".PadLeft(90));
- Console.WriteLine("████─████───█──█──█─████ ████─████──█──███─█─█─█ ─███──███─██───█──█─████ ".PadLeft(90));
- Console.WriteLine("█──█─█──██──█──█──█─█────█ █──█─█─────█──█───█───█ █████───█─█─█──█──█─█──██".PadLeft(90));
- Console.WriteLine("█──█─████───█──████─█ █──█─█─────█──███─█───█ █─█─█─███─█──█─████─████ ".PadLeft(90));
- Thread.Sleep(1500);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment