Garloon

3.2

Sep 1st, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CSLight
  8. {
  9.     class Menu
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.CursorVisible = false;
  14.             char[,] map =
  15.             {
  16.                 {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
  17.                 {'#',' ',' ',' ',' ','|',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','#' },
  18.                 {'#',' ',' ','|',' ','|','=','|',' ','|','=','|',' ','|','=','=','|',' ','|',' ','|','=','=','=','|',' ','|','=','=','|','*','#' },
  19.                 {'#',' ',' ','|',' ',' ',' ','|',' ',' ',' ',' ',' ','|','*',' ',' ',' ','|',' ','|',' ',' ',' ','|',' ',' ',' ',' ',' ',' ','#' },
  20.                 {'#',' ',' ','|',' ','|','=','|',' ','|','=','|',' ','|','=','=','|',' ','|',' ','|',' ','|','=','|',' ','|','=','=','|','X','#' },
  21.                 {'#','=','=','|',' ',' ',' ','|',' ','|','X','|',' ',' ',' ',' ','|',' ','|','*','|',' ',' ',' ',' ',' ',' ',' ',' ','|','=','#' },
  22.                 {'#',' ',' ',' ',' ','|',' ','|',' ','|',' ','|','=','=','|',' ','|',' ','|',' ','|',' ','|','=','=','=','=','=','=','|',' ','#' },
  23.                 {'#','*','|','=','=','|',' ','|',' ',' ',' ',' ',' ',' ','|',' ','|',' ','|','=','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  24.                 {'#','=','|',' ',' ',' ',' ','|','=','=','=','=','|',' ','|','=','|',' ',' ',' ',' ',' ','|','=','=','=','=','=','=','|',' ','#' },
  25.                 {'#','X',' ',' ','|',' ',' ',' ',' ',' ',' ',' ','|',' ','|','*',' ',' ','|','=','|',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','#' },
  26.                 {'#','=','=','=','|','=','=','=','=','=','|',' ','|',' ','|','=','=','=','|',' ','|',' ','|','=','=','|',' ','|','=','|',' ','#' },
  27.                 {'#',' ','*',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ','|',' ','|',' ',' ','|','X','|','*',' ',' ','#' },
  28.                 {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' }
  29.             };
  30.  
  31.             char[] bag = new char[0];
  32.             char[] dead = new char[0];
  33.  
  34.             int userX = 4, userY = 2;
  35.  
  36.             while (true)
  37.             {
  38.                 Console.SetCursorPosition(0, 0);
  39.                 for (int i = 0; i < map.GetLength(0); i++)
  40.                 {
  41.                     for (int j = 0; j < map.GetLength(1); j++)
  42.                     {
  43.                         Console.ForegroundColor = ConsoleColor.Cyan;
  44.                         Console.Write(map[i, j]);
  45.                     }
  46.                     Console.WriteLine();
  47.                 }
  48.                 Console.ForegroundColor = ConsoleColor.Red;
  49.  
  50.                 Console.SetCursorPosition(0, 15);
  51.                 Console.Write("Сокровища: ");
  52.                 for (int i = 0; i < bag.Length; i++)
  53.                 {
  54.                     Console.Write(bag[i] + " ");
  55.                 }
  56.                 Console.SetCursorPosition(0, 17);
  57.                 Console.Write("Смерти: ");
  58.                 for (int i = 0; i < dead.Length; i++)
  59.                 {
  60.                     Console.Write(dead[i] + " ");
  61.                 }
  62.  
  63.                 Console.SetCursorPosition(userY, userX);
  64.                 Console.Write('O');
  65.  
  66.                 ConsoleKeyInfo charKey = Console.ReadKey();
  67.  
  68.                 switch (charKey.Key)
  69.                 {
  70.                     case ConsoleKey.UpArrow:
  71.                         if (map[userX - 1, userY] != '#' && map[userX - 1, userY] != '=' && map[userX - 1, userY] != '|')
  72.                             userX--;
  73.                         break;
  74.                     case ConsoleKey.DownArrow:
  75.                         if (map[userX + 1, userY] != '#' && map[userX + 1, userY] != '=' && map[userX + 1, userY] != '|')
  76.                             userX++;
  77.                         break;
  78.                     case ConsoleKey.LeftArrow:
  79.                         if (map[userX, userY - 1] != '#' && map[userX, userY - 1] != '=' && map[userX, userY - 1] != '|')
  80.                             userY--;
  81.                         break;
  82.                     case ConsoleKey.RightArrow:
  83.                         if (map[userX, userY + 1] != '#' && map[userX, userY + 1] != '=' && map[userX, userY + 1] != '|')
  84.                             userY++;
  85.                         break;
  86.                 }
  87.  
  88.                 if (map[userX, userY] == '*')
  89.                 {
  90.                     map[userX, userY] = ' ';
  91.  
  92.                     char[] tempBag = new char[bag.Length + 1];
  93.                     for (int i = 0; i < bag.Length; i++)
  94.                     {
  95.                         tempBag[i] = bag[i];
  96.                     }
  97.                     tempBag[tempBag.Length - 1] = '*';
  98.  
  99.                     bag = tempBag;
  100.                     if(tempBag.Length >= 7)
  101.                     {
  102.                         Console.Clear();
  103.                         Console.SetCursorPosition(0, 0);
  104.                         Console.WriteLine("Вы собрали все сокровища!");
  105.                         Console.ReadKey();
  106.                         break;
  107.  
  108.                     }
  109.                 }
  110.                 if (map[userX, userY] == 'X')
  111.                 {
  112.                     map[userX, userY] = ' ';
  113.  
  114.                     char[] tempDead = new char[dead.Length + 1];
  115.                     for (int i = 0; i < dead.Length; i++)
  116.                     {
  117.                         tempDead[i] = dead[i];
  118.                     }
  119.                     tempDead[tempDead.Length - 1] = 'X';
  120.  
  121.                     dead = tempDead;
  122.                     if (tempDead.Length >= 3)
  123.                     {
  124.                         Console.Clear();
  125.                         Console.SetCursorPosition(0, 0);
  126.                         Console.WriteLine("Вы потратили все жизни!");
  127.                         Console.ReadKey();
  128.                         break;
  129.  
  130.                     }
  131.                 }
  132.             }
  133.         }
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment