Example #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();

            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;
            }
            }

            UtilityFunctions.DrawAnimations();

            SwinGame.RefreshScreen();
        }
Example #2
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)
            {
                LoadScores();
            }

            //is it a high score
            if (value > _Scores[_Scores.Count - 1].Value)
            {
                Score s = new Score();
                s.Value = value;

                GameController.AddNewState(GameState.ViewingHighScores);

                int x = 0;
                x = SCORES_LEFT + SwinGame.TextWidth(GameResources.GameFont("Courier"), "Name: ");

                SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP);

                //Read the text from the user
                while (SwinGame.ReadingText())
                {
                    SwinGame.ProcessEvents();

                    UtilityFunctions.DrawBackground();
                    DrawHighScores();
                    SwinGame.DrawText("Name: ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP);
                    SwinGame.RefreshScreen();
                }

                s.Name = SwinGame.TextReadAsASCII();

                if (s.Name.Length < 3)
                {
                    s.Name = s.Name + new string(Convert.ToChar(" "), 3 - s.Name.Length);
                }

                _Scores.RemoveAt(_Scores.Count - 1);
                _Scores.Add(s);
                _Scores.Sort();
                SaveScores();

                //GameController.EndCurrentState();
                GameController.AddNewState(GameState.ViewingHighScores);
            }
        }
        /// <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.Quittingprompt:
                MenuController.DrawQuitMenu();
                break;

            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.ChangingHotkeys:
                MenuController.DrawHotkeysMenu();
                break;
            }

            UtilityFunctions.DrawAnimations();

            SwinGame.RefreshScreen();
        }
        /// <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)
            {
                LoadScores();
            }

            // Return if this score is not a highscore
            if (_scores.Count > 0 && value <= _scores[_scores.Count - 1].value)
            {
                return;
            }

            Score s = new Score {
                value = value
            };

            int x = SCORES_LEFT + SwinGame.TextWidth(GameResources.GetFont("Courier"), "Name: ");

            GameController.AddNewState(GameState.ViewingHighScores);
            SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameResources.GetFont("Courier"), x, ENTRY_TOP);

            // Reads the text from the user
            while (SwinGame.ReadingText())
            {
                SwinGame.ProcessEvents();
                UtilityFunctions.DrawBackground();
                DrawHighScores();
                SwinGame.DrawText("Name: ", Color.White, GameResources.GetFont("Courier"), SCORES_LEFT, ENTRY_TOP);
                SwinGame.RefreshScreen();
            }

            s.name = SwinGame.TextReadAsASCII();

            if (s.name.Length < 3)
            {
                s.name += new string(Convert.ToChar(' '), 3 - s.name.Length);
            }

            //scores.RemoveAt(scores.Count - 1);
            _scores.Add(s);
            _scores.Sort();
            GameController.EndCurrentState();
        }
Example #5
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;
            }

            UtilityFunctions.DrawAnimations();

            //Lowered to 30 frames per second to see the splash and explosion animations
            SwinGame.RefreshScreen(60);
        }
Example #6
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();

            if (CurrentState == GameState.ViewingMainMenu)
            {
                MenuController.DrawMainMenu();
            }
            else if (CurrentState == GameState.ViewingGameMenu)
            {
                MenuController.DrawGameMenu();
            }
            else if (CurrentState == GameState.AlteringSettings)
            {
                MenuController.DrawSettings();
            }
            else if (CurrentState == GameState.Deploying)
            {
                DeploymentController.DrawDeployment();
            }
            else if (CurrentState == GameState.Discovering)
            {
                DiscoveryController.DrawDiscovery();
            }
            else if (CurrentState == GameState.EndingGame)
            {
                EndingGameController.DrawEndOfGame();
            }
            else if (CurrentState == GameState.ViewingHighScores)
            {
                HighScoreController.DrawHighScores();
            }

            UtilityFunctions.DrawAnimations();

            SwinGame.RefreshScreen();
        }