Exemplo n.º 1
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();

            switch (CurrentState)
            {
            case GameState.ViewingMainMenu:
            {
                MenuController.HandleMainMenuInput();
                break;
            }

            case GameState.ViewingGameMenu:
            {
                MenuController.HandleGameMenuInput();
                break;
            }

            case GameState.AlteringSettings:
            {
                MenuController.HandleSetupMenuInput();
                break;
            }

            case GameState.Deploying:
            {
                DeploymentController.HandleDeploymentInput();
                break;
            }

            case GameState.Discovering:
            {
                DiscoveryController.HandleDiscoveryInput();
                break;
            }

            case GameState.EndingGame:
            {
                EndingGameController.HandleEndOfGameInput();
                break;
            }

            case GameState.ViewingHighScores:
            {
                HighScoreController.HandleHighScoreInput();
                break;
            }
            }

            UtilityFunctions.UpdateAnimations();
        }
Exemplo n.º 2
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();

            switch (CurrentState)
            {
            case GameState.ViewingMainMenu: {
                MenuController.DrawMainMenu();
                break;
            }

            case GameState.ViewingGameMenu: {
                MenuController.DrawGameMenu();
                break;
            }

            case GameState.AlteringSettings: {
                MenuController.DrawSettings();
                break;
            }

            case GameState.Deploying: {
                DeploymentController.DrawDeployment();
                break;
            }

            case GameState.Discovering: {
                DiscoveryController.DrawDiscovery();
                break;
            }

            case GameState.EndingGame: {
                EndingGameController.DrawEndOfGame();
                break;
            }

            case GameState.ViewingHighScores: {
                HighScoreController.DrawHighScores();
                break;
            }

            case GameState.Guide: {
                MenuController.DrawGuideMenu();
                break;
            }
            }

            UtilityFunctions.DrawAnimations();

            SwinGame.RefreshScreen();
        }
Exemplo n.º 3
0
        // '' <summary>
        // '' Read the user's name for their highsSwinGame.
        // '' </summary>
        // '' <param name="value">the player's sSwinGame.</param>
        // '' <remarks>
        // '' This verifies if the score is a highsSwinGame.
        // '' </remarks>
        public static void ReadHighScore(int value)
        {
            const int ENTRY_TOP = 500;

            if ((_Scores.Count == 0))
            {
                HighScoreController.LoadScores();
            }

            // is it a high score
            if ((value > _Scores.Item[(_Scores.Count - 1)].Value))
            {
                Score s = new Score();
                s.Value = value;
                AddNewState(GameState.ViewingHighScores);
                int x;
                x = (SCORES_LEFT + SwinGame.TextWidth(GameFont("Courier"), "Name: "));
                SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameFont("Courier"), x, ENTRY_TOP);
                // Read the text from the user
                while (SwinGame.ReadingText())
                {
                    SwinGame.ProcessEvents();
                    DrawBackground();
                    HighScoreController.DrawHighScores();
                    SwinGame.DrawText("Name: ", Color.White, GameFont("Courier"), SCORES_LEFT, ENTRY_TOP);
                    SwinGame.RefreshScreen();
                }

                s.Name = SwinGame.TextReadAsASCII();
                if ((s.Name.Length < 3))
                {
                    s.Name = (s.Name + new string(((char)(" ")), (3 - s.Name.Length)));
                }

                _Scores.RemoveAt((_Scores.Count - 1));
                _Scores.Add(s);
                _Scores.Sort();
                EndCurrentState();
            }
        }
Exemplo n.º 4
0
        // '' <summary>
        // '' Draws the high scores to the screen.
        // '' </summary>
        public static void DrawHighScores()
        {
            const int SCORES_HEADING = 40;
            const int SCORES_TOP     = 80;
            const int SCORE_GAP      = 30;

            if ((_Scores.Count == 0))
            {
                HighScoreController.LoadScores();
            }

            SwinGame.DrawText("   High Scores   ", Color.White, GameFont("Courier"), SCORES_LEFT, SCORES_HEADING);
            // For all of the scores
            int i;

            for (i = 0; (i
                         <= (_Scores.Count - 1)); i++)
            {
                Score s;
                s = _Scores.Item[i];
                // for scores 1 - 9 use 01 - 09
                if ((i < 9))
                {
                    SwinGame.DrawText((" "
                                       + ((i + 1) + (":   "
                                                     + (s.Name + ("   " + s.Value))))), Color.White, GameFont("Courier"), SCORES_LEFT, (SCORES_TOP
                                                                                                                                        + (i * SCORE_GAP)));
                }
                else
                {
                    SwinGame.DrawText(((i + 1) + (":   "
                                                  + (s.Name + ("   " + s.Value)))), Color.White, GameFont("Courier"), SCORES_LEFT, (SCORES_TOP
                                                                                                                                    + (i * SCORE_GAP)));
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draws the current state of the game to the screen.
        /// <remarks>
        /// What is drawn depends upon the state of the game.
        /// </remarks>
        /// </summary>
        public static void DrawScreen()
        {
            UtilityFunctions.DrawBackground();

            switch (CurrentState)
            {
            case GameState.ViewingMainMenu:
            {
                MenuController.DrawMainMenu();
                break;
            }

            case GameState.ViewingGameMenu:
            {
                MenuController.DrawGameMenu();
                break;
            }

            case GameState.AlteringSettings:
            {
                MenuController.DrawSettings();
                break;
            }

            case GameState.Rules:
            {
                MenuController.drawRules();
                break;
            }

            case GameState.Controls:
            {
                MenuController.drawControls();
                break;
            }

            case GameState.AlteringVolume:
            {
                if (_state.Skip(1).First() == GameState.ViewingGameMenu)
                {
                    MenuController.DrawVolumeSettings(1);
                }
                else if (_state.Skip(1).First() == GameState.ViewingMainMenu)
                {
                    MenuController.DrawVolumeSettings(0);
                }
                break;
            }

            case GameState.Deploying:
            {
                DeploymentController.DrawDeployment();
                break;
            }

            case GameState.Discovering:
            {
                DiscoveryController.DrawDiscovery();
                break;
            }

            case GameState.EndingGame:
            {
                EndingGameController.DrawEndOfGame();
                break;
            }

            case GameState.ViewingHighScores:
            {
                HighScoreController.DrawHighScores();
                break;
            }
            }

            UtilityFunctions.DrawAnimations();

            SwinGame.RefreshScreen(60);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the user's input.
        /// <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>
        /// </summary>
        public static void HandleUserInput()
        {
            // Read incoming input events.
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped(KeyCode.EqualsKey) || SwinGame.KeyTyped(KeyCode.PlusKey))
            {
                UtilityFunctions.VolumeLevel += 0.1f;
                Audio.SetMusicVolume(UtilityFunctions.VolumeLevel);
            }
            else if (SwinGame.KeyTyped(KeyCode.UnderscoreKey) || SwinGame.KeyTyped(KeyCode.MinusKey))
            {
                UtilityFunctions.VolumeLevel -= 0.1f;
                Audio.SetMusicVolume(UtilityFunctions.VolumeLevel);
            }

            // Switch through themes
            if (SwinGame.KeyTyped(KeyCode.TKey))
            {
                GameResources.GameTheme++;
                if (!Enum.IsDefined(typeof(Theme), GameResources.GameTheme))
                {
                    GameResources.GameTheme = 0;
                }
            }

            switch (CurrentState)
            {
            case GameState.ViewingMainMenu:
            {
                MenuController.HandleMainMenuInput();
                break;
            }

            case GameState.ViewingGameMenu:
            {
                MenuController.HandleGameMenuInput();
                break;
            }

            case GameState.AlteringSettings:
            {
                MenuController.HandleSetupMenuInput();
                break;
            }

            case GameState.Rules:
            {
                HighScoreController.HandleHighScoreInput();
                break;
            }

            case GameState.Controls:
            {
                MenuController.HandleControlersMenu();
                break;
            }

            case GameState.AlteringVolume:
            {
                if (_state.Skip(1).First() == GameState.ViewingGameMenu)
                {
                    MenuController.HandleVolumeMenuInput(1);
                }
                else if (_state.Skip(1).First() == GameState.ViewingMainMenu)
                {
                    MenuController.HandleVolumeMenuInput(0);
                }
                break;
            }

            case GameState.Deploying:
            {
                DeploymentController.HandleDeploymentInput();
                break;
            }

            case GameState.Discovering:
            {
                DiscoveryController.HandleDiscoveryInput();
                break;
            }

            case GameState.EndingGame:
            {
                EndingGameController.HandleEndOfGameInput();
                break;
            }

            case GameState.ViewingHighScores:
            {
                HighScoreController.HandleHighScoreInput();
                break;
            }
            }

            UtilityFunctions.UpdateAnimations();
        }