Exemplo n.º 1
0
        public void DrawField(ref int locationBY, ref int locationBX)
        {
            for (int j = 0; j < size; j++)
            {
                field[j, size - 1] = '\u2503';
                field[j, 0]        = '\u2503';
                field[size - 1, j] = '\u2501';
            }
            field[size - 1, 0]        = '\u2517';
            field[size - 1, size - 1] = '\u251b';

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    Console.Write(field[i, j]);
                }
                Console.Write("\n");
            }
            Console.SetCursorPosition(31, 0);
            Console.Write("Счет:");
            Console.SetCursorPosition(0, 29);
            Console.Write("Управление на WASD, выход ESC");
            AddBonus.Bonus(ref locationBY, ref locationBX);
        }
Exemplo n.º 2
0
        public bool GetInput(ref int locationBY, ref int locationBX)
        {
            Console.SetCursorPosition(36, 0);
            Console.Write(account);
            ConsoleKey key = ConsoleKey.Enter;

            if (Console.KeyAvailable)
            {
                key = Console.ReadKey(true).Key;
            }

            switch (key)
            {
            case ConsoleKey.W:
                if (userInput != direction.down)
                {
                    userInput = direction.up;
                }
                break;

            case ConsoleKey.S:
                if (userInput != direction.up)
                {
                    userInput = direction.down;
                }
                break;

            case ConsoleKey.A:
                if (userInput != direction.right)
                {
                    userInput = direction.left;
                }
                break;

            case ConsoleKey.D:
                if (userInput != direction.left)
                {
                    userInput = direction.right;
                }
                break;

            case ConsoleKey.Escape:
                return(true);

            default:
                break;
            }

            if (locationX == locationBY && locationY == locationBX)
            {
                account++;
                if (speed > 150)
                {
                    speed = speed - (account * 3);
                }
                else if (speed <= 150 && speed > 75)
                {
                    speed = speed - 10;
                }
                AddBonus.Bonus(ref locationBY, ref locationBX);
            }

            AutoMove(userInput);

            if (account >= 4)
            {
                int count = bodySnace.Count;
                for (int i = 0; i < count - 2; i = i + 2)
                {
                    if (locationX == bodySnace[i] && locationY == bodySnace[i + 1])
                    {
                        return(true);
                    }
                }
            }
            if (account == lightBody)
            {
                int left = lengthSnace.Dequeue(), right = lengthSnace.Dequeue();
                Console.SetCursorPosition(left, right);
                Console.Write("\0");
                bodySnace.RemoveAt(1);
                bodySnace.RemoveAt(0);
            }
            lightBody = account;

            return(false);
        }