lolblach333

Untitled

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