lolblach333

Untitled

Apr 15th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3.  
  4. namespace CsLight
  5. {
  6. class Program
  7. {
  8.  
  9.  
  10. static void Main(string[] args)
  11. {
  12. char[,] map =
  13. {
  14. {'#','#','#','#','#','#','#','#','#','#','#','#' },//0
  15. {'#',' ','|',' ',' ',' ',' ',' ',' ',' ',' ','#' },//1
  16. {'#',' ','|',' ',' ',' ',' ',' ',' ',' ',' ','#' },//2
  17. {'#',' ','|',' ','_','_','_',' ',' ',' ','X','#' },//3
  18. {'#',' ','|','X','|','$','|',' ',' ',' ',' ','#' },//4
  19. {'#',' ','|',' ','|',' ','|',' ',' ',' ',' ','#' },
  20. {'#',' ','|',' ','|',' ','|',' ',' ',' ',' ','#' },
  21. {'#',' ','|',' ','|',' ','|',' ','X',' ',' ','#' },
  22. {'#',' ','|','_','_','_','_','_',' ','_','_','#' },
  23. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  24. {'#',' ','|',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  25. {'#',' ','|',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  26. {'#',' ','|',' ','X',' ',' ',' ',' ',' ',' ','#' },
  27. {'#','#','#','#','#','#','#','#','#','#','#','#' }
  28.  
  29. };
  30. Console.CursorVisible = false;
  31.  
  32.  
  33.  
  34. int userY = 1, userX = 1;
  35. char[] bag = new char[0];
  36.  
  37.  
  38. while (true)
  39. {
  40. Console.SetCursorPosition(20, 0);
  41. Console.Write("Сумка: ");
  42. for (int i = 0; i < bag.Length; i++)
  43. Console.Write(bag[i] + " | ");
  44. Console.SetCursorPosition(0, 0);
  45. for (int i = 0; i < map.GetLength(0); i++)
  46. {
  47. for (int j = 0; j < map.GetLength(1); j++)
  48. {
  49. Console.Write(map[i, j]);
  50. }
  51. Console.WriteLine();
  52. }
  53.  
  54. Console.SetCursorPosition(userY, userX);
  55. Console.Write('@');
  56. ConsoleKeyInfo charKey = Console.ReadKey();
  57.  
  58. switch (charKey.Key)
  59. {
  60. case ConsoleKey.UpArrow:
  61. if (map[userX - 1, userY] != '#')
  62. userX--;
  63. break;
  64. case ConsoleKey.DownArrow:
  65. if (map[userX + 1, userY] != '#')
  66. userX++;
  67. break;
  68. case ConsoleKey.LeftArrow:
  69. if (map[userX, userY - 1] != '#')
  70. userY--;
  71. break;
  72. case ConsoleKey.RightArrow:
  73. if (map[userX, userY + 1] != '#')
  74. userY++;
  75. break;
  76. }
  77.  
  78. if (map[userX, userY] == 'X')
  79. {
  80. map[userX, userY] = 'O';
  81.  
  82. char[] tempBag = new char[bag.Length + 1];
  83.  
  84. for (int i = 0; i < bag.Length; i++)
  85. {
  86. tempBag[i] = bag[i];
  87. }
  88. tempBag[tempBag.Length - 1] = 'X';
  89. bag = tempBag;
  90.  
  91. }
  92. if (bag.Length >= 4)
  93. {
  94. map[4,6] = ' ';
  95. }
  96. if (map[userX, userY] == '|')
  97. {
  98. Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\nОбосрался малой");
  99. break;
  100. }
  101. if (map[userX, userY] == '_')
  102. {
  103. Console.WriteLine("\n\n\n\n\n\nОбосрался малой");
  104. break;
  105. }
  106. if (map[userX, userY] == '$')
  107. {
  108. Console.WriteLine("\n\n\n\n\n\n\n\n\n\nТы выиграл");
  109. break;
  110. }
  111. }
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment