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;
- namespace FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- int level = 1;
- char[,] map1 =
- {
- {'#','#','#','#','#','#','#','#','#','#','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ','$',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ','$',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#','#','#','#','#','#','#','#','#','#','#' }
- };
- char[,] map2 =
- {
- {'#','#','#','#','#','#','#','#','#','#' },
- {'#',' ',' ','!',' ',' ',' ','!','!','#' },
- {'#','!',' ','!',' ','!','$','!','!','#' },
- {'#','!',' ','!',' ','!','!','!','!','#' },
- {'#','!',' ','!',' ',' ',' ',' ','!','#' },
- {'#','!',' ','!','!','!','!',' ','!','#' },
- {'#','!',' ','!',' ',' ',' ',' ','!','#' },
- {'#','!',' ','!',' ','!','!','!','!','#' },
- {'#',' ',' ','!',' ',' ','$','!','!','#' },
- {'#',' ','!','!','!','!',' ','!','!','#' },
- {'#',' ','!','!','!','!',' ','!','!','#' },
- {'#',' ',' ',' ',' ',' ',' ','!','!','#' },
- {'#','#','#','#','#','#','#','#','#','#' }
- };
- char[,] map3 =
- {
- {'#','#','#','#','#','#','#','#','#','#','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ','!',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ','!',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ','!','$','#' },
- {'#',' ',' ',' ','|','|',' ',' ','!',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ','!',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ','|','|',' ',' ',' ',' ','#' },
- {'#','#','#','#','#','#','#','#','#','#','#' }
- };
- char[] bag = new char[0];
- while (true)
- {
- int userX = 1, userY = 1;
- if (level == 1)
- {
- while (true)
- {
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map1.GetLength(0); i++)
- {
- for (int j = 0; j < map1.GetLength(1); j++)
- {
- Console.Write(map1[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(0, 20);
- Console.WriteLine("Собранные сокровища:");
- for (int i = 0; i < bag.Length; i++)
- {
- Console.Write(bag[i] + ", ");
- }
- Console.SetCursorPosition(userY, userX);
- Console.Write('X');
- ConsoleKeyInfo consoleKey = Console.ReadKey();
- switch (consoleKey.Key)
- {
- case ConsoleKey.LeftArrow:
- if (map1[userX, userY - 1] != '#')
- {
- userY--;
- }
- break;
- case ConsoleKey.RightArrow:
- if (map1[userX, userY + 1] != '#')
- {
- userY++;
- }
- break;
- case ConsoleKey.UpArrow:
- if (map1[userX - 1, userY] != '#')
- {
- userX--;
- }
- break;
- case ConsoleKey.DownArrow:
- if (map1[userX + 1, userY] != '#')
- {
- userX++;
- }
- break;
- }
- if (map1[userX, userY] == '$')
- {
- map1[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 == 2)
- {
- Console.Clear();
- level++;
- break;
- }
- }
- }
- else if (level == 2)
- {
- while (true)
- {
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map2.GetLength(0); i++)
- {
- for (int j = 0; j < map2.GetLength(1); j++)
- {
- Console.Write(map2[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(0, 23);
- Console.WriteLine("Не касайтесь шипов!\n");
- Console.WriteLine("Собранные сокровища:");
- for (int i = 0; i < bag.Length; i++)
- {
- Console.Write(bag[i] + ", ");
- }
- Console.SetCursorPosition(userY, userX);
- Console.Write('X');
- ConsoleKeyInfo consoleKey = Console.ReadKey();
- switch (consoleKey.Key)
- {
- case ConsoleKey.LeftArrow:
- if (map1[userX, userY - 1] != '#')
- {
- userY--;
- }
- break;
- case ConsoleKey.RightArrow:
- if (map1[userX, userY + 1] != '#')
- {
- userY++;
- }
- break;
- case ConsoleKey.UpArrow:
- if (map1[userX - 1, userY] != '#')
- {
- userX--;
- }
- break;
- case ConsoleKey.DownArrow:
- if (map1[userX + 1, userY] != '#')
- {
- userX++;
- }
- break;
- }
- if (map2[userX, userY] == '$')
- {
- map2[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 (map2[userX, userY] == '!')
- {
- Console.Clear();
- Console.WriteLine("Вы проиграли, не касайтесь шипов!");
- Console.ReadKey();
- userX = 1;
- userY = 1;
- Console.Clear();
- continue;
- }
- if (bag.Length == 4)
- {
- Console.Clear();
- level++;
- break;
- }
- }
- }
- else if (level == 3)
- {
- while (true)
- {
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map3.GetLength(0); i++)
- {
- for (int j = 0; j < map3.GetLength(1); j++)
- {
- Console.Write(map3[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(0, 23);
- Console.WriteLine("Что бы перепрыгнуть пропасть - встаньте у края и нажмите Space\n");
- Console.WriteLine("Собранные сокровища:");
- for (int i = 0; i < bag.Length; i++)
- {
- Console.Write(bag[i] + ", ");
- }
- Console.SetCursorPosition(userY, userX);
- Console.Write('X');
- ConsoleKeyInfo consoleKey = Console.ReadKey();
- switch (consoleKey.Key)
- {
- case ConsoleKey.LeftArrow:
- if (map3[userX, userY - 1] != '#')
- {
- userY--;
- }
- break;
- case ConsoleKey.RightArrow:
- if (map3[userX, userY + 1] != '#' && map3[userX, userY + 1] != '|')
- {
- userY++;
- }
- break;
- case ConsoleKey.UpArrow:
- if (map3[userX - 1, userY] != '#')
- {
- userX--;
- }
- break;
- case ConsoleKey.DownArrow:
- if (map3[userX + 1, userY] != '#')
- {
- userX++;
- }
- break;
- case ConsoleKey.Spacebar:
- if (map3[userX, userY + 1] == '|')
- {
- userY += 3;
- }
- break;
- }
- if (map3[userX, userY] == '$')
- {
- map3[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 (map3[userX, userY] == '!')
- {
- Console.Clear();
- Console.WriteLine("Вы проиграли, не касайтесь шипов!");
- Console.ReadKey();
- userX = 1;
- userY = 1;
- Console.Clear();
- continue;
- }
- if (bag.Length == 5)
- {
- Console.Clear();
- level++;
- break;
- }
- }
- if (level == 4)
- {
- Console.WriteLine("Спасибо за то, что играли в демо-версию");
- Console.ReadKey();
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement