示例#1
0
        /// <summary>
        /// The base update loop calls update loops corresponding to the current game state
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        protected override void Update(GameTime gameTime)
        {
            // Update the game time
            GameTime = gameTime;

            // Switch over the current state
            switch (State)
            {
            // Call the corresponding update functions for each menu
            case GameState.MainMenu:
                MainMenuScreen.Update();
                break;

            case GameState.Instructions:
                InstructionsScreen.Update();
                break;

            case GameState.ModeSelection:
                ModeSelectionScreen.Update();
                break;

            // Game Modes
            case GameState.ClassicGameplay:
                // Create a new gameplay screen if it is null
                if (gameplayScreen == null)
                {
                    gameplayScreen = new GameplayScreen();
                }

                // Update the gameplay screen
                gameplayScreen.Update();
                break;

            // The gameplay screens are identical and differ only in the EnemyManager (what enemies spawn)
            // and PlayerShip (how the player is controlled), meaning GameplayScreen can be used generically
            // in handling all operations regarding drawing and updating gameplay
            case GameState.FreeGameplay:
                if (gameplayScreen == null)
                {
                    gameplayScreen = new GameplayScreen();
                }

                gameplayScreen.Update();
                break;
            }

            // Check to see if the game state is not in gameplay
            if (State != GameState.ClassicGameplay && State != GameState.FreeGameplay)
            {
                // Set the gameplay screen to null since the player ship controls and enemies are agnostic
                // to the current scene. The gameplay screen prevents updates to the player and enemies but
                // will still draw them unless the gameplay screen is reset entirely
                gameplayScreen = null;
            }

            // Update the root update loop
            base.Update(gameTime);
        }
示例#2
0
    IEnumerator ResetUIForGame()
    {
        yield return(new WaitForSeconds(1f));

        opponentDisconnectPopup.SetActive(false);
        ModeSelectionScreen.SetActive(false);
        RulesScreen.SetActive(false);
        OptionsScreen.SetActive(false);
        Loader.SetActive(false);
        WHOTMultiplayerManager.Instance.mainMenu.SetActive(false);
        WHOTMultiplayerManager.Instance.multiplayerOptions.SetActive(false);
        WHOTMultiplayerManager.Instance.gamePlay.SetActive(true);
        WHOTMultiplayerManager.Instance.betSelectionPanel.SetActive(false);
        WHOTMultiplayerManager.Instance.availableRooms.SetActive(false);
        WHOTMultiplayerManager.Instance.SearchOpponentPanel.SetActive(false);
        WHOTMultiplayerManager.Instance.challengeScreen.SetActive(false);
        WHOTMultiplayerManager.Instance.createChallengeDialog.SetActive(false);
        WhotOpponent.instance.UpdateOpponentImage(defaultImage);
        //WHOTMultiplayerManager.instance.opponentName.text = "OPPONENT";
    }
示例#3
0
        /// <summary>
        /// The base draw loop handles drawing all draw loops corresponding to the current game state
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // Switch based on the current scene
            switch (State)
            {
            // Call each corresponding draw method
            case GameState.MainMenu:
                MainMenuScreen.Draw(spriteBatch);
                break;

            case GameState.Instructions:
                InstructionsScreen.Draw(spriteBatch);
                break;

            case GameState.ModeSelection:
                ModeSelectionScreen.Draw(spriteBatch);
                break;

            // If the gameplayScreen is not defined because the state updates asynchronously from
            // the update loop creating a new instance of gameplayScreen, ignore the current frame
            // and wait until the gameplayScreen is defined
            case GameState.ClassicGameplay:
                if (gameplayScreen != null)
                {
                    gameplayScreen.Draw(spriteBatch);
                }
                break;

            case GameState.FreeGameplay:
                if (gameplayScreen != null)
                {
                    gameplayScreen.Draw(spriteBatch);
                }
                break;
            }
        }