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.Xml.Schema;
- namespace FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- char[,] map =
- {
- {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', '$', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '$', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', ' ', '#'},
- {'#', ' ', '$', ' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '$', ' ', ' ', ' ', '#'},
- {'#', ' ', '$', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', ' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', '!', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
- {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'}
- };
- char[] bag = new char[0];
- int userX = 3, userY = 3;
- bool weapon = false;
- int kills = 0, playerMove = 0;
- while (true)
- {
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- Console.Write(map[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(30, 2);
- Console.WriteLine($"У вас осталось {68 - playerMove} ходов");
- Console.SetCursorPosition(30, 3);
- Console.WriteLine($"Поднимите меч(!), убейте всех противников(X) и соберите награды($)");
- Console.SetCursorPosition(30, 5);
- Console.WriteLine($"Осталось противников: {5 - kills}");
- Console.SetCursorPosition(0, 25);
- Console.WriteLine("Собранные сокровища:");
- for (int i = 0; i < bag.Length; i++)
- {
- Console.Write(bag[i] + ", ");
- }
- Console.SetCursorPosition(userY, userX);
- Console.Write('@');
- ConsoleKeyInfo consoleKey = Console.ReadKey();
- switch (consoleKey.Key)
- {
- case ConsoleKey.LeftArrow:
- if (map[userX, userY - 1] != '#')
- {
- userY--;
- }
- break;
- case ConsoleKey.RightArrow:
- if (map[userX, userY + 1] != '#')
- {
- userY++;
- }
- break;
- case ConsoleKey.UpArrow:
- if (map[userX - 1, userY] != '#')
- {
- userX--;
- }
- break;
- case ConsoleKey.DownArrow:
- if (map[userX + 1, userY] != '#')
- {
- userX++;
- }
- break;
- }
- if (map[userX, userY] == '!')
- {
- map[userX, userY] = '.';
- weapon = true;
- }
- if (map[userX, userY] == 'X')
- {
- if (weapon)
- {
- map[userX, userY] = '_';
- kills++;
- }
- else
- {
- Console.Clear();
- Console.WriteLine("\tGame Over");
- Console.ReadKey();
- break;
- }
- }
- if (map[userX, userY] == '$')
- {
- map[userX, userY] = 'o';
- 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;
- }
- if (bag.Length == 5 && kills == 5)
- {
- Console.Clear();
- Console.WriteLine("\tВы победили");
- Console.ReadKey();
- break;
- }
- playerMove++;
- if (playerMove == 68)
- {
- Console.Clear();
- Console.WriteLine("\tGame Over");
- Console.ReadKey();
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement