Advertisement
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.IO;
- using System.Threading;
- namespace Творческое_задание
- {
- class Program
- {
- static bool Fortress = true;//крепость не разрушена
- static bool Max_Fort = false;//достигнут максимальный уровень
- static int Number_Fort = 0;//уровень крепости
- static int Fort = 10;//переменная крепости
- static int Fort_1 = 0;//переменная крепости после первого улучшения
- static int Fort_2 = 0;//переменная крепости после второго улучшения
- static int Fort_3 = 0;//переменная крепости после третьего улучшения
- static bool Sawmill = false;//постройка лесопилки
- static bool Max_Sa = false;//достигнут максимальный уровень
- static int Number_Sa = 0;//уровень крепости
- static int Sa = 0;//переменная добычи дерева
- static int Sa_1 = 0;//переменная добычи дерева после первого улучшения
- static int Sa_2 = 0;//переменная добычи дерева после второго улучшения
- static int Sa_3 = 0;//переменная добычи дерева после третьего улучшения
- static bool Farm = false;//постройка фермы
- static bool Max_Fa = false;//достигнут максимальный уровень
- static int Number_Fa = 0;//уровень крепости
- static int Fa = 0;//переменная добычи еды
- static int Fa_1 = 0;//переменная добычи еды после первого улучшения
- static int Fa_2 = 0;//переменная добычи еды после второго улучшения
- static int Fa_3 = 0;//переменная добычи еды после третьего улучшения
- static bool Stone_quarry = false;//постройка каменолони
- static bool Max_Sq = false;//достигнут максимальный уровень
- static int Number_Sq = 0;//уровень крепости
- static int Sq = 0;//переменная добычи камня
- static int Sq_1 = 0;//переменная добычи камня после первого улучшения
- static int Sq_2 = 0;//переменная добычи камня после второго улучшения
- static int Sq_3 = 0;//переменная добычи камня после третьего улучшения
- static bool House_1 = false;//постройка дома_1
- static bool Max_Ho_1 = false;//достигнут максимальный уровень
- static int Number_Ho_1 = 0;//уровень крепости
- static int Ho_1 = 0;//переменная койко-мест первого дома
- static int Ho_1_1 = 0;//переменная койко-мест первого дома после первого улучшения
- static int Ho_1_2 = 0;//переменная койко-мест первого дома после второго улучшения
- static int Ho_1_3 = 0;//переменная койко-мест первого дома третьего улучшения
- static bool House_2 = false;//постройка дома_2
- static bool Max_Ho_2 = false;//достигнут максимальный уровень
- static int Number_Ho_2 = 0;//уровень крепости
- static int Ho_2 = 0;//переменная койко-мест второго дома
- static int Ho_2_1 = 0;//переменная койко-мест второго дома после первого улучшения
- static int Ho_2_2 = 0;//переменная койко-мест второго дома после второго улучшения
- static int Ho_2_3 = 0;//переменная койко-мест второго дома третьего улучшения
- static bool House_3 = false;//постройка дома_3
- static bool Max_Ho_3 = false;//достигнут максимальный уровень
- static int Number_Ho_3 = 0;//уровень крепости
- static int Ho_3 = 0;//переменная койко-мест третьего дома
- static int Ho_3_1 = 0;//переменная койко-мест третьего дома после первого улучшения
- static int Ho_3_2 = 0;//переменная койко-мест третьего дома после второго улучшения
- static int Ho_3_3 = 0;//переменная койко-мест третьего дома третьего улучшения
- static bool Forge = false;//постройка кузницы
- static bool Max_Fo = false;//достигнут максимальный уровень
- static int Number_Fo = 0;//уровень крепости
- static int Fo = 0;//переменная добычи метала
- static int Fo_1 = 0;//переменная добычи метала после первого улучшения
- static int Fo_2 = 0;//переменная добычи метала после второго улучшения
- static int Fo_3 = 0;//переменная добычи метала третьего улучшения
- static bool Casern = false;//постройка казармы
- static bool Max_Ca = false;//достигнут максимальный уровень
- static int Number_Ca = 0;//уровень крепости
- static int Ca = 0;//переменная силы войск
- static int Ca_1 = 0;//переменная силы войск после первого улучшения
- static int Ca_2 = 0;//переменная силы войск после второго улучшения
- static int Ca_3 = 0;//переменная силы войск третьего улучшения
- static bool Chapel = false;//постройка часовни
- static bool Max_Ch = false;//достигнут максимальный уровень
- static int Number_Ch = 0;//уровень крепости
- static int Ch = 0;//переменная силы веры
- static int Ch_1 = 0;//переменная силы веры после первого улучшения
- static int Ch_2 = 0;//переменная силы веры после второго улучшения
- static int Ch_3 = 0;//переменная силы веры третьего улучшения
- static int Gold = 15;
- static int Tree = 15;
- static int Stone = 0;
- static int Metal = 0;
- static int People = 10;
- static int Food = 10;
- static readonly object locker = new object();
- static void Main(string[] args)
- {
- int Item_Selection = 0;
- new Thread(Resource_count).Start();
- while (true)
- {
- Console.Clear();
- Frame("frame.txt");// если простроено...
- Console.SetCursorPosition(18, 2);
- Console.WriteLine("Золото: " + Gold + " Дерево: " + Tree + " Камень: " + Stone + " Метал: " + Metal + " Крестьяне: " + People + " Еда: " + Food);
- ConsoleKeyInfo key;
- if (Console.KeyAvailable)
- {
- key = Console.ReadKey(true);
- switch (key.Key)
- {
- case ConsoleKey.Escape:
- Console.Clear();
- Menu(ref Item_Selection, "main_menu.txt");
- switch (Item_Selection)
- {
- case 1://создание новых строений
- Console.Clear();
- Menu(ref Item_Selection, "buildings_menu.txt");
- switch (Item_Selection)
- {
- case 1://разобраться с экономикой// строим Лесопилку
- Building(ref Item_Selection, "Sawmill.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Sawmill, 10, 10, 0, 0, 2, 2, ref Sa, 2);
- break;
- case 2://разобраться с экономикой// строим Ферму
- Building(ref Item_Selection, "Farm.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Farm, 15, 35, 0, 0, 2, 4, ref Fa, 3);
- break;
- case 3://разобраться с экономикой// строим Каменоломню
- Building(ref Item_Selection, "Stone_quarry.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Stone_quarry, 20, 50, 0, 0, 3, 10, ref Sq, 2);
- break;
- case 4://разобраться с экономикой// строим Дом_1
- Building(ref Item_Selection, "House_1.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_1, 10, 30, 0, 0, 0, 5, ref Ho_1, 5);
- break;
- case 5://разобраться с экономикой// строим Дом_2
- Building(ref Item_Selection, "House_2.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_2, 20, 30, 15, 0, 0, 10, ref Ho_2, 5);
- break;
- case 6://разобраться с экономикой// строим Дом_3
- Building(ref Item_Selection, "House_3.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_3, 30, 15, 25, 0, 0, 10, ref Ho_3, 5);
- break;
- case 7://разобраться с экономикой// строим Кузницу
- Building(ref Item_Selection, "Forge.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Forge, 30, 45, 50, 0, 5, 20, ref Fo, 1);
- break;
- case 8://разобраться с экономикой// строим Казармы
- Building(ref Item_Selection, "Casern.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Casern, 100, 50, 70, 30, 20, 100, ref Ca, 0);
- break;
- case 9://разобраться с экономикой// строим Часовню
- Building(ref Item_Selection, "Chapel.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Chapel, 50, 50, 30, 20, 10, 30, ref Ch, 9);
- break;
- case 10:
- break;
- }
- break;
- case 2://улучшение строений
- Console.Clear();
- Menu(ref Item_Selection, "improvement_menu.txt");
- switch (Item_Selection)
- {
- case 1:// улучшаем крепость
- Improvement(ref Item_Selection, "Fortress _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Fortress, ref Max_Fort, 50, 50, 50, 5, 10, 50, ref Fort_1, ref Fort_2, ref Fort_3, 2, ref Number_Fort);
- break;
- case 2:// улучшаем лесопилку
- Improvement(ref Item_Selection, "Sawmill _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Sawmill, ref Max_Sa, 10, 10, 10, 1, 1, 10, ref Sa_1, ref Sa_2, ref Sa_3, 3, ref Number_Sa);
- break;
- case 3:// улучшаем ферму
- Improvement(ref Item_Selection, "Farm _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Farm, ref Max_Fa, 15, 15, 15, 1, 1, 15, ref Fa_1, ref Fa_2, ref Fa_3, 5, ref Number_Fa);
- break;
- case 4:// улучшаем каменоломню
- Improvement(ref Item_Selection, "Stone_quarry_improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Stone_quarry, ref Max_Sq, 30, 30, 30, 5, 1, 15, ref Sq_1, ref Sq_2, ref Sq_3, 3, ref Number_Sq);
- break;
- case 5:// улучшаем Дом_1
- Improvement(ref Item_Selection, "House_1_improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_1, ref Max_Ho_1, 20, 20, 20, 1, 0, 15, ref Ho_1_1, ref Ho_1_2, ref Ho_1_3, 2, ref Number_Ho_1);
- break;
- case 6:// улучшаем Дом_2
- Improvement(ref Item_Selection, "House_2_improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_2, ref Max_Ho_2, 20, 20, 20, 1, 0, 15, ref Ho_2_1, ref Ho_2_2, ref Ho_2_3, 2, ref Number_Ho_2);
- break;
- case 7:// улучшаем Дом_3
- Improvement(ref Item_Selection, "House_3_improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref House_3, ref Max_Ho_3, 20, 20, 20, 1, 0, 15, ref Ho_3_1, ref Ho_3_2, ref Ho_3_3, 2, ref Number_Ho_3);
- break;
- case 8:// улучшаем Кузницу
- Improvement(ref Item_Selection, "Forge _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Forge, ref Max_Fo, 50, 50, 50, 5, 5, 25, ref Fo_1, ref Fo_2, ref Fo_3, 3, ref Number_Fo);
- break;
- case 9:// улучшаем Казармы
- Improvement(ref Item_Selection, "Casern _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Casern, ref Max_Ca, 50, 50, 50, 5, 10, 50, ref Ca_1, ref Ca_2, ref Ca_3, 2, ref Number_Ca);
- break;
- case 10:// улучшаем Часовню
- Improvement(ref Item_Selection, "Chapel _improvement.txt", ref Gold, ref Tree, ref Stone, ref Metal, ref People, ref Food, ref Chapel, ref Max_Ch, 100, 20, 20, 2, 1, 15, ref Ch_1, ref Ch_2, ref Ch_3, 2, ref Number_Ch);
- break;
- case 11:
- break;
- }
- break;
- case 3://информация о строениях
- Console.Clear();
- Information(ref Fortress, ref Number_Fort, "Крепость уровня");
- Information(ref Sawmill, ref Number_Sa, "Лесопилка уровня");
- Information(ref Farm, ref Number_Fa, "Ферма уровня");
- Information(ref Stone_quarry, ref Number_Sq, "Каменоломня уровня");
- Information(ref House_1, ref Number_Ho_1, "Дом_1 уровня");
- Information(ref House_2, ref Number_Ho_2, "Дом_2 уровня");
- Information(ref House_3, ref Number_Ho_3, "Дом_3 уровня");
- Information(ref Forge, ref Number_Fo, "Кузница уровня");
- Information(ref Casern, ref Number_Ca, "Казармы уровня");
- Information(ref Chapel, ref Number_Ch, "Часовня уровня");
- Console.ReadKey();
- break;
- case 4:
- Console.WriteLine("Будет чуть позже");
- Console.ReadKey();
- break;
- case 5:
- Console.WriteLine("Будет чуть позже");
- Console.ReadKey();
- break;
- case 6:
- Console.WriteLine("Будет чуть позже");
- Console.ReadKey();
- break;
- case 7:
- Console.WriteLine("Будет чуть позже");
- Console.ReadKey();
- break;
- case 8:
- Console.WriteLine("Будет чуть позже");
- Console.ReadKey();
- break;
- case 9://выход из игры
- Console.Clear();
- Menu(ref Item_Selection, "Exit.txt");
- if (Item_Selection == 1)
- {
- return;
- }
- break;
- case 10://выход из меню
- break;
- }
- break;
- }
- }
- System.Threading.Thread.Sleep(2000);//1секунда = 1000 милисекунд
- }
- }
- static void Resource_count()
- {
- lock (locker)
- {
- while (true)
- {
- System.Threading.Thread.Sleep(30000);
- Gold = Gold + 1 + Fort_1 + Fort_2 + Fort_3 + Ch + Ch_1 + Ch_2 + Ch_3;
- if (Sawmill == true)
- {
- Tree = Tree + Sa + Sa_1 + Sa_2 + Sa_3;
- }
- if (Stone_quarry == true)
- {
- Stone = Stone + Sq + Sq_1 + Sq_2 + Sq_3;
- }
- if (Forge == true)
- {
- Metal = Metal + Fo + Fo_1 + Fo_2 + Fo_3;
- }
- if (People < (Fort + Fort_1 + Fort_2 + Fort_3 + Ho_1 + Ho_1_1 + Ho_1_2 + Ho_1_3 + Ho_2 + Ho_2_1 + Ho_2_2 + Ho_2_3 + Ho_3 + Ho_3_1 + Ho_3_2 + Ho_3_3))
- {
- People += 1;
- }
- Food = Food + 1 + Fort_1 + Fort_2 + Fort_3 + Fa + Fa_1 + Fa_2 + Fa_3;
- }
- }
- }
- static void Frame(string Input_File)
- {
- Console.CursorVisible = false;//прячем мигающий курсор
- string[] Frame = File.ReadAllLines(Input_File, System.Text.Encoding.GetEncoding(1251));//вызывается массив из файла и переводится в Unicode
- char[,] FrameChar = new char[Frame.Length, Frame[1].Length];
- for (int i = 0; i < FrameChar.GetLength(0); i++)
- for (int j = 0; j < FrameChar.GetLength(1); j++)
- FrameChar[i, j] = Frame[i][j];//присвоение всех элементов массива нового файла массиву интерфейса
- for (int i = 0; i < FrameChar.GetLength(0); i++)
- {
- for (int j = 0; j < FrameChar.GetLength(1); j++)
- {
- Console.Write(FrameChar[i, j]);
- }
- Console.WriteLine();
- }
- }
- static void Menu(ref int Item_Selection, string Input_File)
- {
- bool Input = true;//запуск стика
- Item_Selection = 1;//выбираемый элемент
- Console.CursorVisible = false;//прячем мигающий курсор
- string[] newFile = File.ReadAllLines(Input_File, System.Text.Encoding.GetEncoding(1251));//вызывается массив из файла и переводится в Unicode
- char[,] Interface = new char[newFile.Length, newFile[1].Length];
- int CursorX = 0, CursorY = 0;//ввод положения курсора
- int DY = 0;//изминение положение курсора (вертикальное)
- for (int i = 0; i < Interface.GetLength(0); i++)
- for (int j = 0; j < Interface.GetLength(1); j++)
- Interface[i, j] = newFile[i][j];//присвоение всех элементов массива нового файла массиву интерфейса
- for (int i = 0; i < Interface.GetLength(0); i++)
- {
- for (int j = 0; j < Interface.GetLength(1); j++)
- {
- if (Interface[i, j] == 'O')
- {
- CursorX = j;
- CursorY = i;
- Interface[i, j] = ' ';
- }
- Console.Write(Interface[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(4, CursorY - 2);
- Console.Write(' ');//убираем верхний блок
- Console.SetCursorPosition(4, Interface.GetLength(0) - 1);
- Console.Write(' ');//убираем нижний блок
- Console.SetCursorPosition(CursorX, CursorY);
- Console.Write('O');
- ConsoleKeyInfo key;
- while (Input == true)
- {
- key = Console.ReadKey(true);
- switch (key.Key)
- {
- case ConsoleKey.UpArrow:
- DY -= 2;
- if (Interface[CursorY + DY, CursorX] != '#')
- {
- Item_Selection--;
- }
- break;
- case ConsoleKey.DownArrow:
- DY += 2;
- if (Interface[CursorY + DY, CursorX] != '#')
- {
- Item_Selection++;
- }
- break;
- case ConsoleKey.Enter:
- Input = false;
- break;
- }
- //Console.SetCursorPosition(10, 20);
- //Console.Write($"Выбор элемента {Item_Selection}"); //проверка выводимого значения
- if (Interface[CursorY + DY, CursorX] != '#')
- {
- Console.SetCursorPosition(CursorX, CursorY);
- Console.Write(' ');//затираем курсор
- CursorY = CursorY + DY;//передвигаем его на новое положение
- Console.SetCursorPosition(CursorX, CursorY);
- Console.Write('O');//отображаем курсор вновь
- }
- DY = 0;
- }
- }
- static void Building (ref int Item_Selection, string Input_File, ref int Gold, ref int Tree, ref int Stone, ref int Metal, ref int People, ref int Food, ref bool Bu, int Price_Gold, int Price_Tree, int Price_Stone, int Price_Metal, int Price_People, int Price_Food,ref int Bonus, int Number_of_bonuses)
- {
- Console.Clear();
- Menu(ref Item_Selection, Input_File);
- switch (Item_Selection)
- {
- case 1:
- if (Bu == false)
- {
- Console.Clear();
- if (Gold > Price_Gold && Tree > Price_Tree && Stone > Price_Stone && Metal > Price_Metal && People > Price_People && Food > Price_Food)//Price
- {
- Gold = Gold - Price_Gold;
- Tree = Tree - Price_Tree;
- Stone = Stone - Price_Stone;
- Metal = Metal - Price_Metal;
- People = People - Price_People;
- Food = Food - Price_Food;
- Bu = true;
- Bonus = Number_of_bonuses;//Number_of_bonuses
- Console.WriteLine("\n Постройка совершена");//исправить визуализацию
- Console.ReadKey();
- }
- else
- {
- Console.WriteLine("\n Не хватает ресурсов");//исправить визуализацию
- Console.ReadKey();
- }
- }
- else
- {
- Console.Clear();
- Console.WriteLine("\n Постройка уже создана");//исправить визуализацию
- Console.ReadKey();
- }
- break;
- case 2:
- break;
- }
- }
- static void Improvement(ref int Item_Selection, string Input_File, ref int Gold, ref int Tree, ref int Stone, ref int Metal, ref int People, ref int Food, ref bool Bu, ref bool Max, int Price_Gold, int Price_Tree, int Price_Stone, int Price_Metal, int Price_People, int Price_Food, ref int Bonus_1, ref int Bonus_2, ref int Bonus_3, int Number_of_bonuses, ref int Number)
- {
- Console.Clear();
- Menu(ref Item_Selection, Input_File);
- switch (Item_Selection)
- {
- case 1:
- if (Bu == true && Max == false)
- {
- Console.Clear();
- if (Gold > Price_Gold && Tree > Price_Tree && Stone > Price_Stone && Metal > Price_Metal && People > Price_People && Food > Price_Food)//Price
- {
- Gold = Gold - Price_Gold;
- Tree = Tree - Price_Tree;
- Stone = Stone - Price_Stone;
- Metal = Metal - Price_Metal;
- People = People - Price_People;
- Food = Food - Price_Food;
- if (Bonus_1 == 0)
- {
- Bonus_1 = Number_of_bonuses;//Number_of_bonuses
- Number = Number + 1;
- }
- else if (Bonus_2 == 0)
- {
- Bonus_2 = Number_of_bonuses;//Number_of_bonuses
- Number = Number + 1;
- }
- else if (Bonus_3 == 0)
- {
- Bonus_3 = Number_of_bonuses;//Number_of_bonuses
- Number = Number + 1;
- Max = true;
- }
- Console.WriteLine("\n Улучшение совершено");//исправить визуализацию
- Console.ReadKey();
- }
- else if (Bu == true && Max == true)
- {
- Console.WriteLine("\n Максимальное улучшение уже достигнуто");//исправить визуализацию
- Console.ReadKey();
- }
- else
- {
- Console.WriteLine("\n Не хватает ресурсов");//исправить визуализацию
- Console.ReadKey();
- }
- }
- else
- {
- Console.Clear();
- Console.WriteLine("\n Постройка отсутствует");//исправить визуализацию
- Console.ReadKey();
- }
- break;
- case 2:
- break;
- }
- }
- static void Information(ref bool Bu, ref int Number, string Inform_File)
- {
- if (Bu == true)
- {
- Console.WriteLine(Inform_File + "(" + Number + ")\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement