コード例 #1
0
        /// <summary>
        /// Draws the current state of the game to the screen.
        /// </summary>
        /// <remarks>
        /// What is drawn depends upon the state of the game.
        /// </remarks>
        public static void DrawScreen()
        {
            UtilityFunctions.DrawBackground();
            var switchExpr = CurrentState;

            switch (switchExpr)
            {
            case var @case when @case == GameState.ViewingMainMenu:
            {
                MenuController.DrawMainMenu();
                break;
            }

            case var case1 when case1 == GameState.ViewingGameMenu:
            {
                MenuController.DrawGameMenu();
                break;
            }

            case var case2 when case2 == GameState.AlteringSettings:
            {
                MenuController.DrawSettings();
                break;
            }

            case var case3 when case3 == GameState.Deploying:
            {
                DeploymentController.DrawDeployment();
                break;
            }

            case var case4 when case4 == GameState.Discovering:
            {
                DiscoveryController.DrawDiscovery();
                break;
            }

            case var case5 when case5 == GameState.EndingGame:
            {
                EndingGameController.DrawEndOfGame();
                break;
            }

            case var case6 when case6 == GameState.ViewingHighScores:
            {
                HighScoreController.DrawHighScores();
                break;
            }
            }

            UtilityFunctions.DrawAnimations();
            SwinGame.RefreshScreen();
        }
コード例 #2
0
        /// <summary>
        /// Handles the user SwinGame.
        /// </summary>
        /// <remarks>
        /// Reads key and mouse input and converts these into
        /// actions for the game to perform. The actions
        /// performed depend upon the state of the game.
        /// </remarks>
        public static void HandleUserInput()
        {
            // Read incoming input events
            SwinGame.ProcessEvents();
            var switchExpr = CurrentState;

            switch (switchExpr)
            {
            case var @case when @case == GameState.ViewingMainMenu:
            {
                MenuController.HandleMainMenuInput();
                SwinGame.ResetTimer(gameTimer);
                break;
            }

            case var case1 when case1 == GameState.ViewingGameMenu:
            {
                MenuController.HandleGameMenuInput();
                SwinGame.StopTimer(gameTimer);
                break;
            }

            case var case2 when case2 == GameState.AlteringSettings:
            {
                MenuController.HandleSetupMenuInput();
                SwinGame.StopTimer(gameTimer);
                break;
            }

            case var case3 when case3 == GameState.Deploying:
            {
                DeploymentController.HandleDeploymentInput();
                SwinGame.ResetTimer(gameTimer);
                break;
            }

            case var case4 when case4 == GameState.Discovering:
            {
                DiscoveryController.HandleDiscoveryInput();
                if (SwinGame.TimerTicks(gameTimer) == 0)
                {
                    SwinGame.StartTimer(gameTimer);
                }
                break;
            }

            case var case5 when case5 == GameState.EndingGame:
            {
                EndingGameController.HandleEndOfGameInput();
                SwinGame.ResetTimer(gameTimer);
                break;
            }

            case var case6 when case6 == GameState.ViewingHighScores:
            {
                HighScoreController.HandleHighScoreInput();
                break;
            }

            case var case7 when case7 == GameState.ViewingGuide:
            {
                GuideController.HandleInstructionsInput();
                break;
            }
            }

            UtilityFunctions.UpdateAnimations();
        }