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 _1393
- {
- class Program
- {
- static int[,] arraymap = {
- { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 },
- { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 2, 0, 0, 1 },
- { 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0 },
- { 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1 },
- { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0 },
- { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0 }
- };
- static int coins = 0;
- static int n = 10;
- static int m = 15;
- public static void Main(string[] args)
- {
- Console.CursorVisible = false;
- DrawField();
- Console.WriteLine ("Деньжат собрано: " + coins);
- while (true)
- {
- ConsoleKeyInfo input = Console.ReadKey();
- input = Moving(input);
- }
- }
- static void DrawField()
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- if (arraymap[i, j] == 0)
- {
- Console.Write('-');
- }
- else if (arraymap[i, j] == 1)
- {
- Console.Write('$');
- }
- else if (arraymap[i, j] == 2)
- {
- Console.Write('*');
- }
- else if (arraymap[i, j] == 3)
- {
- Console.Write('@');
- }
- }
- Console.WriteLine();
- }
- }
- static void MoveLeft()
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 1; j < m; j++)
- {
- if (arraymap[i, j] == 3)
- {
- if (arraymap[i, j - 1] == 0)
- {
- arraymap[i, j - 1] = 3;
- arraymap[i, j] = 0;
- }
- else if (arraymap[i, j - 1] == 1)
- {
- arraymap[i, j - 1] = 3;
- arraymap[i, j] = 0;
- coins++;
- }
- }
- }
- }
- }
- static void MoveDown()
- {
- for (int i = n-2 ; i >= 0; i--)
- {
- for (int j = 0; j < m; j++)
- {
- if (arraymap[i, j] == 3)
- {
- if (arraymap[i + 1, j] == 0)
- {
- arraymap[i + 1, j] = 3;
- arraymap[i, j] = 0;
- }
- else if (arraymap[i + 1, j] == 1)
- {
- arraymap[i + 1, j] = 3;
- arraymap[i, j] = 0;
- coins++;
- }
- }
- }
- }
- }
- static void MoveRight()
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = m-2; j > -1; j--)
- {
- if (arraymap[i, j] == 3)
- {
- if (arraymap[i, j + 1] == 0)
- {
- arraymap[i, j + 1] = 3;
- arraymap[i, j] = 0;
- }
- else if (arraymap[i, j + 1] == 1)
- {
- arraymap[i, j + 1] = 3;
- arraymap[i, j] = 0;
- coins++;
- }
- }
- }
- }
- }
- static void MoveUp()
- {
- for (int i = 1; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- if (arraymap[i, j] == 3)
- {
- if (arraymap[i - 1, j] == 0)
- {
- arraymap[i - 1, j] = 3;
- arraymap[i, j] = 0;
- }
- else if (arraymap[i - 1, j] == 1)
- {
- arraymap[i, j - 1] = 3;
- arraymap[i, j] = 0;
- coins++;
- }
- }
- }
- }
- }
- private static ConsoleKeyInfo Moving(ConsoleKeyInfo input)
- {
- if (input.Key == ConsoleKey.LeftArrow) MoveLeft();
- if (input.Key == ConsoleKey.RightArrow) MoveRight();
- if (input.Key == ConsoleKey.UpArrow) MoveUp();
- if (input.Key == ConsoleKey.DownArrow) MoveDown();
- Console.Clear();
- DrawField();
- Console.WriteLine("Деньжат собрано: " + coins);
- return input;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement