static void Initialize(Engine engine)
        {
            Sea botSea    = new BootSea(fieldRows, fieldCols);
            Sea playerSea = new PlayerSea(fieldRows, fieldCols);

            engine.ConfigureGameField(botSea as BootSea, shipMaxLength);
            engine.ConfigureGameField(playerSea as PlayerSea, shipMaxLength);
        }
        private void GetPlayerMap()
        {
            PlayerSea playerMapManualInput = null;

            switch (_introducedMethod)
            {
            case MethodShipsBuild.AutoRandom:
                _playerMap = new Sea(10);
                _playerMap.BuildAllTypeOfShips();
                break;

            case MethodShipsBuild.Manual:
                playerMapManualInput = new PlayerSea(10);

                bool        isPossibleSetting;
                int         shipCount = 1;
                TypeOfShips deckCount = TypeOfShips.FourDecker;

                Console.Clear();

                for (int i = 0; i < RandomCoords.COUNT_OF_SHIPS_TYPE; i++)
                {
                    for (int j = 0; j < shipCount; j++)
                    {
                        UserInterface.PrintManualInputShips(playerMapManualInput);
                        Console.SetCursorPosition(0, 0);
                        Direction shipDirection;
                        Position  shipPosition = UserInterface.InputShipPosition(deckCount, out shipDirection);
                        isPossibleSetting = playerMapManualInput.BuildOneTypeOfShips(deckCount,
                                                                                     shipPosition, shipDirection);

                        if (!isPossibleSetting)
                        {
                            UserInterface.ClearBottom(0, 45, 7);
                            UserInterface.ShowMessage(Constants.IMPOSSIBLE_SETTING, 0, 0);
                            System.Threading.Thread.Sleep(3000);
                            j--;
                            continue;
                        }

                        UserInterface.PrintManualInputShips(playerMapManualInput);
                    }

                    deckCount--;
                    shipCount++;
                }

                break;

            default:
                break;
            }

            if (_playerMap == null)
            {
                _playerMap = playerMapManualInput;
            }
        }
Beispiel #3
0
 public FormGame()
 {
     _playerMap                    = null;
     _enemyMap                     = null;
     _isTargetEnemy                = false;
     _isTargetPlayer               = false;
     _isAliveEnemyAfterRigthShot   = false;
     _isAlivePlayerAfterRigthShoot = false;
     _isEasyLevel                  = false;
     _enemysMind                   = null;
     _name = null;
     _playerMapManualInput = new PlayerSea(COUNT_ALL_SHIPS);
     _startShipPosition    = new Position(-1, -1);
 }