Advertisement
Emerald_

Untitled

Jul 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp4
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Console.CursorVisible = false;
  10. char[,] map1 =
  11. {
  12. {'#','#','#','#','#','#','#','#','#','#' },
  13. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  14. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  15. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  16. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  17. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  18. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  19. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  20. {'#',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  21. {'#','#','#','#','#','#','#','#','#','#' }
  22.  
  23. };
  24.  
  25. char[,] map3 =
  26. {
  27. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
  28. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  29. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  30. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  31. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  32. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  33. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  34. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  35. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  36. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  37. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  38. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  39. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  40. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  41. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  42. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  43. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  44. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  45. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  46. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  47. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  48. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  49. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  50. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  51. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  52. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  53. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  54. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  55. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  56. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' }
  57.  
  58. };
  59.  
  60. char[,] map2 =
  61. {
  62. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
  63. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  64. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  65. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  66. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  67. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  68. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  69. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  70. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  71. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  72. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  73. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  74. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  75. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  76. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  77. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  78. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  79. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  80. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  81. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' }
  82.  
  83. };
  84.  
  85. string[] MenuItems = { "10 на 10", "20 на 20", "30 на 30" };
  86. int MenuPos = 0;
  87.  
  88. Console.WriteLine("Это классическая змейка");
  89.  
  90. Menu(MenuItems, MenuPos);
  91. PickOut(MenuPos, MenuItems, ref map2, ref map3, ref map1);
  92.  
  93.  
  94. }
  95. static void Menu(string[] MenuItems, int MenuPos)
  96. {
  97. Console.Clear();
  98.  
  99. for (int i = 0; i < MenuItems.Length; i++)
  100. {
  101. if (i == MenuPos)
  102. {
  103. Console.ForegroundColor = ConsoleColor.Red;
  104. Console.WriteLine(MenuItems[i]);
  105. Console.ForegroundColor = ConsoleColor.White;
  106. }
  107. else
  108. Console.WriteLine(MenuItems[i]);
  109. }
  110. }
  111. static void Switch(int MenuPos, ref char[,] map2, ref char[,] map3, ref char[,] map1)
  112. {
  113. switch (MenuPos)
  114. {
  115. case 0:
  116. Ten(ref map3);
  117. break;
  118. case 1:
  119. Twenty(ref map2);
  120. break;
  121. case 2:
  122. Thirty(ref map1);
  123. break;
  124. default:
  125. Switch(MenuPos, ref map2, ref map3, ref map1);
  126. break;
  127. }
  128. }
  129. static void PickOut(int MenuPos, string[] MenuItems, ref char[,] map2, ref char[,] map1, ref char[,] map3)
  130. {
  131. while (true)
  132. {
  133. var key = Console.ReadKey().Key;
  134. switch (key)
  135. {
  136. case ConsoleKey.UpArrow:
  137. if (MenuPos > 0)
  138. {
  139. MenuPos--;
  140. Menu(MenuItems, MenuPos);
  141. }
  142. break;
  143. case ConsoleKey.DownArrow:
  144. if (MenuPos < MenuItems.Length - 1)
  145. {
  146. MenuPos++;
  147. Menu(MenuItems, MenuPos);
  148. }
  149. break;
  150. case ConsoleKey.Enter:
  151. {
  152. Switch(MenuPos, ref map2, ref map3, ref map1);
  153. break;
  154. }
  155. default:
  156. Menu(MenuItems, MenuPos);
  157. break;
  158. }
  159. Console.SetCursorPosition(0, 3);
  160. }
  161. }
  162. static void Twenty(ref char[,] map2)
  163. {
  164. Console.Clear();
  165. int userY = 6, userX = 6;
  166. map2[userX, userY] = '@';
  167. int k = 0;
  168. int m = 0;
  169. int n = 0;
  170. int WIN = 0;
  171. link1:
  172. for (int i = 0; i < map2.GetLength(0); i++)
  173. {
  174. for (int j = 0; j < map2.GetLength(1); j++)
  175. {
  176. Random rnd = new Random();
  177. int a = rnd.Next(50);
  178. if (a == 16 && k == 0 && map2[i, j] != '#')
  179. {
  180. n = i;
  181. m = j;
  182. map2[i, j] = '*';
  183. Console.Write(map2[i, j]);
  184. k++;
  185. }
  186. else
  187. Console.Write(map2[i, j]);
  188. }
  189. Console.WriteLine();
  190. }
  191. if (k == 0)
  192. {
  193. Console.Clear();
  194. goto link1;
  195. }
  196. while (WIN != 1)
  197. {
  198.  
  199. Console.SetCursorPosition(userY, userX);
  200. Console.Write('@');
  201. ConsoleKeyInfo charKey = Console.ReadKey();
  202.  
  203. switch (charKey.Key)
  204. {
  205. case ConsoleKey.UpArrow:
  206. if (map2[userX - 1, userY] != '#' && map2[userX - 1, userY] != '@')
  207. {
  208. userX--;
  209. map2[userX, userY] = '@';
  210. }
  211. break;
  212. case ConsoleKey.DownArrow:
  213. if (map2[userX + 1, userY] != '#' && map2[userX + 1, userY] != '@')
  214. userX++;
  215. map2[userX, userY] = '@';
  216. break;
  217. case ConsoleKey.LeftArrow:
  218. if (map2[userX, userY - 1] != '#' && map2[userX, userY - 1] != '@')
  219. userY--;
  220. map2[userX, userY] = '@';
  221. break;
  222. case ConsoleKey.RightArrow:
  223. if (map2[userX, userY + 1] != '#' && map2[userX, userY + 1] != '@')
  224. userY++;
  225. map2[userX, userY] = '@';
  226. break;
  227. }
  228.  
  229. int g = 0;
  230. Console.SetCursorPosition(0, 0);
  231. link2:
  232. if (map2[n, m] == map2[userX, userY] && k == 1)
  233. {
  234. for (int i = 0; i < map2.GetLength(0); i++)
  235. {
  236. for (int j = 0; j < map2.GetLength(1); j++)
  237. {
  238. Random rnd = new Random();
  239. int a = rnd.Next(50);
  240. if (a == 0 && k == 1 && map2[i, j] != '#' && map2[i, j] != '@' && g >= 0)
  241. {
  242. n = i;
  243. m = j;
  244. map2[i, j] = '*';
  245. Console.Write(map2[i, j]);
  246. k++;
  247. g++;
  248.  
  249. }
  250. else
  251. Console.Write(map2[i, j]);
  252. }
  253. Console.WriteLine();
  254. }
  255.  
  256. if (k == 1)
  257. {
  258. Console.Clear();
  259. goto link2;
  260. }
  261. }
  262. link3:
  263. if (map2[n, m] == map2[userX, userY] && k == 2)
  264. {
  265. g = 1;
  266. for (int i = 0; i < map2.GetLength(0); i++)
  267. {
  268. for (int j = 0; j < map2.GetLength(1); j++)
  269. {
  270. Random rnd = new Random();
  271. int a = rnd.Next(50);
  272. if (a == 0 && k == 2 && map2[i, j] != '#' && map2[i, j] != '@' && g >= 0)
  273. {
  274. n = i;
  275. m = j;
  276. map2[i, j] = '*';
  277. Console.Write(map2[i, j]);
  278. k++;
  279. g++;
  280.  
  281. }
  282. else
  283. Console.Write(map2[i, j]);
  284. }
  285. Console.WriteLine();
  286. }
  287. if (k == 2 )
  288. {
  289. Console.Clear();
  290. goto link3;
  291. }
  292. if (k == 3 && g == 2 && map2[n, m] == map2[userX, userY])
  293. WIN++;
  294.  
  295. }
  296.  
  297. Console.SetCursorPosition(0, 0);
  298. for (int i = 0; i < map2.GetLength(0); i++)
  299. {
  300. for (int j = 0; j < map2.GetLength(1); j++)
  301. {
  302. Console.Write(map2[i, j]);
  303. }
  304. Console.WriteLine();
  305. }
  306.  
  307.  
  308. }
  309. Console.WriteLine("Ты выйграл в змейку.");
  310. }
  311. static void Ten(ref char[,] map3)
  312. {
  313. Console.Clear();
  314. int userY = 6, userX = 6;
  315. map3[userX, userY] = '@';
  316. int k = 0;
  317. int m = 0;
  318. int n = 0;
  319. int WIN = 0;
  320. link1:
  321. for (int i = 0; i < map3.GetLength(0); i++)
  322. {
  323. for (int j = 0; j < map3.GetLength(1); j++)
  324. {
  325. Random rnd = new Random();
  326. int a = rnd.Next(50);
  327. if (a == 16 && k == 0 && map3[i, j] != '#')
  328. {
  329. n = i;
  330. m = j;
  331. map3[i, j] = '*';
  332. Console.Write(map3[i, j]);
  333. k++;
  334. }
  335. else
  336. Console.Write(map3[i, j]);
  337. }
  338. Console.WriteLine();
  339. }
  340. if (k == 0)
  341. {
  342. Console.Clear();
  343. goto link1;
  344. }
  345. while (WIN != 1)
  346. {
  347.  
  348. Console.SetCursorPosition(userY, userX);
  349. Console.Write('@');
  350. ConsoleKeyInfo charKey = Console.ReadKey();
  351.  
  352. switch (charKey.Key)
  353. {
  354. case ConsoleKey.UpArrow:
  355. if (map3[userX - 1, userY] != '#' && map3[userX - 1, userY] != '@')
  356. {
  357. userX--;
  358. map3[userX, userY] = '@';
  359. }
  360. break;
  361. case ConsoleKey.DownArrow:
  362. if (map3[userX + 1, userY] != '#' && map3[userX +1, userY] != '@')
  363. userX++;
  364. map3[userX, userY] = '@';
  365. break;
  366. case ConsoleKey.LeftArrow:
  367. if (map3[userX, userY - 1] != '#' && map3[userX, userY - 1] != '@')
  368. userY--;
  369. map3[userX, userY] = '@';
  370. break;
  371. case ConsoleKey.RightArrow:
  372. if (map3[userX, userY + 1] != '#' && map3[userX, userY + 1] != '@')
  373. userY++;
  374. map3[userX, userY] = '@';
  375. break;
  376. }
  377.  
  378. int g = 0;
  379. Console.SetCursorPosition(0, 0);
  380. link2:
  381. if (map3[n, m] == map3[userX, userY] && k == 1)
  382. {
  383. for (int i = 0; i < map3.GetLength(0); i++)
  384. {
  385. for (int j = 0; j < map3.GetLength(1); j++)
  386. {
  387. Random rnd = new Random();
  388. int a = rnd.Next(50);
  389. if (a == 0 && k == 1 && map3[i, j] != '#' && map3[i, j] != '@' && g >= 0)
  390. {
  391. n = i;
  392. m = j;
  393. map3[i, j] = '*';
  394. Console.Write(map3[i, j]);
  395. k++;
  396. g++;
  397.  
  398. }
  399. else
  400. Console.Write(map3[i, j]);
  401. }
  402. Console.WriteLine();
  403. }
  404.  
  405. if (k == 1)
  406. {
  407. Console.Clear();
  408. goto link2;
  409. }
  410. }
  411. link3:
  412. if (map3[n, m] == map3[userX, userY] && k == 2)
  413. {
  414. g = 1;
  415. for (int i = 0; i < map3.GetLength(0); i++)
  416. {
  417. for (int j = 0; j < map3.GetLength(1); j++)
  418. {
  419. Random rnd = new Random();
  420. int a = rnd.Next(50);
  421. if (a == 0 && k == 2 && map3[i, j] != '#' && map3[i, j] != '@' && g >= 0)
  422. {
  423. n = i;
  424. m = j;
  425. map3[i, j] = '*';
  426. Console.Write(map3[i, j]);
  427. k++;
  428. WIN++;
  429.  
  430. }
  431. else
  432. Console.Write(map3[i, j]);
  433. }
  434. Console.WriteLine();
  435. }
  436. if (k == 2)
  437. {
  438. Console.Clear();
  439. goto link3;
  440. }
  441.  
  442. }
  443.  
  444. Console.SetCursorPosition(0, 0);
  445. for (int i = 0; i < map3.GetLength(0); i++)
  446. {
  447. for (int j = 0; j < map3.GetLength(1); j++)
  448. {
  449. Console.Write(map3[i, j]);
  450. }
  451. Console.WriteLine();
  452. }
  453.  
  454. if (g == 3 && k == 3)
  455. WIN = 1;
  456. }
  457. Console.WriteLine("Ты выйграл в змейку.");
  458.  
  459. }
  460. static void Thirty(ref char[,] map1)
  461. {
  462. Console.Clear();
  463. int userY = 6, userX = 6;
  464. map1[userX, userY] = '@';
  465. int k = 0;
  466. int m = 0;
  467. int n = 0;
  468. int WIN = 0;
  469. link1:
  470. for (int i = 0; i < map1.GetLength(0); i++)
  471. {
  472. for (int j = 0; j < map1.GetLength(1); j++)
  473. {
  474. Random rnd = new Random();
  475. int a = rnd.Next(50);
  476. if (a == 16 && k == 0 && map1[i, j] != '#')
  477. {
  478. n = i;
  479. m = j;
  480. map1[i, j] = '*';
  481. Console.Write(map1[i, j]);
  482. k++;
  483. }
  484. else
  485. Console.Write(map1[i, j]);
  486. }
  487. Console.WriteLine();
  488. }
  489. if (k == 0)
  490. {
  491. Console.Clear();
  492. goto link1;
  493. }
  494. while (WIN != 1)
  495. {
  496.  
  497. Console.SetCursorPosition(userY, userX);
  498. Console.Write('@');
  499. ConsoleKeyInfo charKey = Console.ReadKey();
  500.  
  501. switch (charKey.Key)
  502. {
  503. case ConsoleKey.UpArrow:
  504. if (map1[userX - 1, userY] != '#' && map1[userX - 1, userY] != '@')
  505. {
  506. userX--;
  507. map1[userX, userY] = '@';
  508. }
  509. break;
  510. case ConsoleKey.DownArrow:
  511. if (map1[userX + 1, userY] != '#' && map1[userX + 1, userY] != '@')
  512. userX++;
  513. map1[userX, userY] = '@';
  514. break;
  515. case ConsoleKey.LeftArrow:
  516. if (map1[userX, userY - 1] != '#' && map1[userX, userY - 1] != '@')
  517. userY--;
  518. map1[userX, userY] = '@';
  519. break;
  520. case ConsoleKey.RightArrow:
  521. if (map1[userX, userY + 1] != '#' && map1[userX, userY + 1] != '@')
  522. userY++;
  523. map1[userX, userY] = '@';
  524. break;
  525. }
  526.  
  527. int g = 0;
  528. Console.SetCursorPosition(0, 0);
  529. link2:
  530. if (map1[n, m] == map1[userX, userY] && k == 1)
  531. {
  532. for (int i = 0; i < map1.GetLength(0); i++)
  533. {
  534. for (int j = 0; j < map1.GetLength(1); j++)
  535. {
  536. Random rnd = new Random();
  537. int a = rnd.Next(50);
  538. if (a == 0 && k == 1 && map1[i, j] != '#' && map1[i, j] != '@' && g >= 0)
  539. {
  540. n = i;
  541. m = j;
  542. map1[i, j] = '*';
  543. Console.Write(map1[i, j]);
  544. k++;
  545. g++;
  546.  
  547. }
  548. else
  549. Console.Write(map1[i, j]);
  550. }
  551. Console.WriteLine();
  552. }
  553.  
  554. if (k == 1)
  555. {
  556. Console.Clear();
  557. goto link2;
  558. }
  559. }
  560. link3:
  561. if (map1[n, m] == map1[userX, userY] && k == 2)
  562. {
  563. g = 1;
  564. for (int i = 0; i < map1.GetLength(0); i++)
  565. {
  566. for (int j = 0; j < map1.GetLength(1); j++)
  567. {
  568. Random rnd = new Random();
  569. int a = rnd.Next(50);
  570. if (a == 0 && k == 2 && map1[i, j] != '#' && map1[i, j] != '@' && g >= 0)
  571. {
  572. n = i;
  573. m = j;
  574. map1[i, j] = '*';
  575. Console.Write(map1[i, j]);
  576. k++;
  577. WIN++;
  578.  
  579. }
  580. else
  581. Console.Write(map1[i, j]);
  582. }
  583. Console.WriteLine();
  584. }
  585. if (k == 2)
  586. {
  587. Console.Clear();
  588. goto link3;
  589. }
  590.  
  591. }
  592.  
  593. Console.SetCursorPosition(0, 0);
  594. for (int i = 0; i < map1.GetLength(0); i++)
  595. {
  596. for (int j = 0; j < map1.GetLength(1); j++)
  597. {
  598. Console.Write(map1[i, j]);
  599. }
  600. Console.WriteLine();
  601. }
  602.  
  603. if (g == 3 && k == 3)
  604. WIN = 1;
  605. }
  606. Console.WriteLine("Ты выйграл в змейку.");
  607. }
  608. }
  609. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement