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;
- namespace Lesson2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- char[,] map =
- {
- { '█','█','█','█','█','█','█','█','█','█','█'},
- { '█',' ',' ',' ',' ',' ',' ',' ',' ',' ','█'},
- { '█',' ',' ','╬',' ','█',' ','█',' ',' ','█'},
- { '█',' ','█',' ',' ',' ','╬',' ',' ',' ','█'},
- { '█',' ',' ','█',' ',' ',' ',' ',' ',' ','█'},
- { '█',' ',' ','╬',' ',' ',' ','╬','█',' ','█'},
- { '█',' ',' ',' ',' ',' ',' ',' ',' ',' ','█'},
- { '█',' ','█',' ',' ',' ','╬','█',' ',' ','█'},
- { '█',' ',' ',' ',' ','█',' ',' ',' ',' ','█'},
- { '█',' ',' ',' ',' ',' ',' ',' ',' ',' ','█'},
- { '█','█','█','█','█','█','█','█','█','█','█'}
- };
- Console.Write("\n Вам всего-то нужно собрать все 5 крестов.");
- Console.Write("\n Если застряли, попробуйте заново.");
- char[] bag = new char[0];
- int userX = 5, userY = 5;
- while (true)
- {
- MapDraw(map);
- Console.SetCursorPosition(11, 0);
- Console.Write("Сумка: ");
- for (int i = 0; i < bag.Length; i++)
- Console.Write(bag[i] + " | ");
- Console.BackgroundColor = ConsoleColor.Blue;
- Console.SetCursorPosition(userY, userX);
- Console.Write('@');
- ConsoleKeyInfo charKey = Console.ReadKey();
- switch (charKey.Key)
- {
- case ConsoleKey.UpArrow:
- while (map[userX - 1, userY] != '█')
- {
- userX--;
- if (map[userX, userY] == '╬')
- {
- map[userX, userY] = ' ';
- char[] tempBag = new char[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = '╬';
- bag = tempBag;
- }
- }
- break;
- case ConsoleKey.DownArrow:
- while (map[userX + 1, userY] != '█')
- {
- userX++;
- if (map[userX, userY] == '╬')
- {
- map[userX, userY] = ' ';
- char[] tempBag = new char[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = '╬';
- bag = tempBag;
- }
- }
- break;
- case ConsoleKey.LeftArrow:
- while (map[userX, userY - 1] != '█')
- {
- userY--;
- if (map[userX, userY] == '╬')
- {
- map[userX, userY] = ' ';
- char[] tempBag = new char[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = '╬';
- bag = tempBag;
- }
- }
- break;
- case ConsoleKey.RightArrow:
- while (map[userX, userY + 1] != '█')
- {
- userY++;
- if (map[userX, userY] == '╬')
- {
- map[userX, userY] = ' ';
- char[] tempBag = new char[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = '╬';
- bag = tempBag;
- }
- }
- break;
- }
- Console.BackgroundColor = ConsoleColor.Black;
- if (bag.Length == 5)
- {
- Console.Clear();
- Console.WriteLine("Вам удалось собрать все кресты, поздравляю!!!\nПопробуйте еще раз)");
- break;
- }
- }
- }
- static void MapDraw(char[,] arr)
- {
- Console.BackgroundColor = ConsoleColor.Blue;
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write(arr[i, j]);
- }
- Console.WriteLine();
- }
- Console.BackgroundColor = ConsoleColor.Black;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement