Beispiel #1
0
        public int MakeStep(int enemyHealth)
        {
            bool fixSharp = false;

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.SetCursorPosition(currentCell_X, currentCell_Y);
            Console.Write("@");

            bool choice = false;

            while (!choice)
            {
                GameEngine.ShowInfo(0, message);
                message = null;

                ConsoleKey direction = Console.ReadKey(true).Key;

                if (direction == ConsoleKey.LeftArrow || direction == ConsoleKey.A)
                {
                    if (currentCell_X > 32)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawHiddenEnemyMap();
                        currentCell_X -= 2;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.RightArrow || direction == ConsoleKey.D)
                {
                    if (currentCell_X < 50)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawHiddenEnemyMap();
                        currentCell_X += 2;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.UpArrow || direction == ConsoleKey.W)
                {
                    if (currentCell_Y > 1)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawHiddenEnemyMap();
                        currentCell_Y--;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.DownArrow || direction == ConsoleKey.S)
                {
                    if (currentCell_Y < 9)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawHiddenEnemyMap();
                        currentCell_Y++;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.Enter)
                {
                    if (Board.EnemyField[currentCell_Y][currentCell_X - 30] == '#' && Board.EmtyField[currentCell_Y][currentCell_X - 30] != 'X')
                    {
                        Board.EmtyField[currentCell_Y] = Program.ChengeSymb(currentCell_X - 30, Board.EmtyField[currentCell_Y], 'X');
                        enemyHealth--;
                        choice = true;
                        DrawImpossibleCells(currentCell_X - 30, currentCell_Y);
                    }
                    else if (Board.EmtyField[currentCell_Y][currentCell_X - 30] != '*' && Board.EnemyField[currentCell_Y][currentCell_X - 30] == '.')
                    {
                        Board.EmtyField[currentCell_Y] = Program.ChengeSymb(currentCell_X - 30, Board.EmtyField[currentCell_Y], '*');
                        choice = true;
                    }
                    else
                    {
                        choice  = false;
                        message = "U were already been on this cell";
                    }
                }
            }
            return(enemyHealth);
        }
Beispiel #2
0
        public void CreatingPlayerMap()
        {
            int  currentCell_X = 2, currentCell_Y = 1;
            bool fixSharp = false;

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.SetCursorPosition(currentCell_X, currentCell_Y);
            Console.Write("@");

            int stage = 4;

            while (currentBoats <= 19)
            {
                if (currentBoats >= 4 && currentBoats < 10)
                {
                    stage = 3;
                }
                else if (currentBoats >= 10 && currentBoats < 16)
                {
                    stage = 2;
                }
                else if (currentBoats >= 16)
                {
                    stage = 1;
                }

                GameEngine.ShowInfo(stage, message);
                message = null;

                ConsoleKey direction = Console.ReadKey(true).Key;

                if (direction == ConsoleKey.LeftArrow || direction == ConsoleKey.A)
                {
                    if (currentCell_X > 2)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawPlayerMap();
                        currentCell_X -= 2;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.RightArrow || direction == ConsoleKey.D)
                {
                    if (currentCell_X < 20)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawPlayerMap();
                        currentCell_X += 2;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.UpArrow || direction == ConsoleKey.W)
                {
                    if (currentCell_Y > 1)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawPlayerMap();
                        currentCell_Y--;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.DownArrow || direction == ConsoleKey.S)
                {
                    if (currentCell_Y < 9)
                    {
                        if (!fixSharp)
                        {
                            Console.SetCursorPosition(currentCell_X, currentCell_Y);
                            Console.Write('.');
                        }
                        GameEngine.DrawPlayerMap();
                        currentCell_Y++;
                        Console.SetCursorPosition(currentCell_X, currentCell_Y);
                        Console.Write("@");
                        fixSharp = false;
                    }
                }
                else if (direction == ConsoleKey.Enter)
                {
                    ConsoleKey location = 0;
                    if (stage != 1)
                    {
                        location = Console.ReadKey(true).Key;
                    }

                    SetShip(stage, currentCell_X, currentCell_Y, location);
                    fixSharp = true;
                    GameEngine.DrawPlayerMap();
                }
            }
        }