Exemple #1
0
        // '' <summary>
        // '' Starts a new game.
        // '' </summary>
        // '' <remarks>
        // '' Creates an AI player based upon the _aiSetting.
        // '' </remarks>
        public static void StartGame()
        {
            if (_theGame != null)
            {
                GameController.EndGame();
            }
            // Create the game
            _theGame = new BattleShipsGame();
            // create the players
            switch (_aiSetting)
            {
                case AIOption.Medium:
                    _ai = new AIMediumPlayer(_theGame);
                    break;
                case AIOption.Hard:
                    _ai = new AIHardPlayer(_theGame);
                    break;
                default:
                    _ai = new AIEasyPlayer(_theGame);
                    break;
            }
            _human = new Player(_theGame);
            // AddHandler _human.PlayerGrid.Changed, AddressOf GridChanged
            _ai.PlayerGrid.Changed += GridChanged;
            _theGame.AttackCompleted += AttackCompleted;
            GameController.AddNewState(GameState.Deploying);

        }
        // Starts a new game, and creates an AI player based upon
        // the _aiSetting currently set
        public static void StartGame()
        {
            if (!(_theGame == null))
            {
                GameController.EndGame();
            }

            // Create the game
            _theGame = new BattleShipsGame();

            if (_playableShips.Count == 0)
            {
                foreach (ShipName name in Enum.GetValues(typeof(ShipName)))
                {
                    if (name != ShipName.None)
                    {
                        _playableShips.Add(name);
                    }
                }
            }

            // create the players
            switch (_aiSetting)
            {
            case AIOption.Easy:
                _ai = new AIEasyPlayer(_theGame, _playableShips);
                Audio.PlaySoundEffect(GameResources.GameSound("Easy"));
                break;

            case AIOption.Medium:
                _ai = new AIMediumPlayer(_theGame, _playableShips);
                Audio.PlaySoundEffect(GameResources.GameSound("Medium"));
                break;

            case AIOption.Hard:
                _ai = new AIHardPlayer(_theGame, _playableShips);
                Audio.PlaySoundEffect(GameResources.GameSound("Hard"));
                break;

            default:
                _ai = new AIMediumPlayer(_theGame, _playableShips);
                Audio.PlaySoundEffect(GameResources.GameSound("Medium"));
                break;
            }
            _human = new Player(_theGame, _playableShips);
            // AddHandler _human.PlayerGrid.Changed, AddressOf GridChanged
            _ai.PlayerGrid.Changed   += GridChanged;
            _theGame.AttackCompleted += AttackCompleted;
            GameController.AddNewState(GameState.Deploying);

            // Stops listening to the old game once a new game has been started
        }
        // '' <summary>
        // '' Starts a new game.
        // '' </summary>
        // '' <remarks>
        // '' Creates an AI player based upon the _aiSetting.
        // '' </remarks>
        public static void StartGame()
        {
            if (!(_theGame == null))
            {
                GameController.EndGame();
            }

            // Create the game
            _theGame = new BattleShipsGame();
            // create the players
            switch (_aiSetting)
            {
            case AIOption.Easy:
                _ai = new AIHardPlayer(_theGame);
                break;

            case AIOption.Medium:
                _ai = new AIMediumPlayer(_theGame);
                break;

            case AIOption.Hard:
                _ai = new AIHardPlayer(_theGame);
                break;

            default:
                _ai = new AIMediumPlayer(_theGame);
                break;
            }
            _human = new Player(_theGame);
            // AddHandler _human.PlayerGrid.Changed, AddressOf GridChanged
            _ai.PlayerGrid.Changed   += GridChanged;
            _theGame.AttackCompleted += AttackCompleted;
            GameController.AddNewState(GameState.Deploying);

            // '' <summary>
            // '' Stops listening to the old game once a new game is started
            // '' </summary>
        }