Beispiel #1
0
 /// <summary>
 /// Initialize the game pause screen by creating all the screens
 /// </summary>
 /// <param name="screenResolution"></param>
 /// <param name="director"></param>
 private void Initialize(Vector2 screenResolution, Director director)
 {
     mGamePauseScreen  = new GamePauseScreen(screenResolution);
     mSaveGameScreen   = new SaveGameScreen(screenResolution);
     mStatisticsScreen = new StatisticsScreen(screenResolution, director);
 }
Beispiel #2
0
        /// <summary>
        /// Updates the state of the pause menu and changes the screen that is currently being displayed
        /// by the stack screen manager.
        /// </summary>
        /// <param name="gametime"></param>
        public void Update(GameTime gametime)
        {
            if (sPausedAgain)
            {
                mScreenManager.AddScreen(mGamePauseScreen);
                sPausedAgain = false;
            }

            if (sSaved)
            {
                mSaveGameScreen = new SaveGameScreen(mScreenResolution)
                {
                    mMenuOpacity = 1f
                };
                sPressed = "Save Game";
                Console.WriteLine("Save Screen Updated");
                sSaved = false;
            }

            switch (mScreenState)
            {
            case EScreen.GameScreen:
                break;

            case EScreen.GamePauseScreen:
                if (sPressed == "Resume")
                {
                    mScreenManager.RemoveScreen();
                    mScreenManager.RemoveScreen();
                    sPressed     = "None";
                    sPausedAgain = true;
                }

                if (sPressed == "Save Game")
                {
                    SwitchScreen(EScreen.SaveGameScreen, mGamePauseScreen, mSaveGameScreen, gametime);
                }

                if (sPressed == "Statistics")
                {
                    SwitchScreen(EScreen.StatisticsScreen, mGamePauseScreen, mStatisticsScreen, gametime);
                }

                if (sPressed == "Main Menu")
                {
                    mDirector.GetStoryManager.Level.GameScreen.Unload();
                    mDirector.GetClock       = new Clock();
                    mDirector.GetIdGenerator = new IdGenerator();
                    mDirector.GetInputManager.RemoveEverythingFromInputManager();
                    mDirector.GetStoryManager = new StoryManager(mDirector);
                    mDirector.GetStoryManager.SetScreenManager(mScreenManager);
                    mDirector.GetPathManager          = new PathManager();
                    mDirector.GetDistributionDirector = new DistributionDirector(mDirector);
                    mDirector.GetMilitaryManager      = new MilitaryManager(mDirector);
                    mDirector.GetDeathManager         = new DeathManager();
                    mDirector.GetActionManager        = new ActionManager();

                    for (var i = 0; i < mScreenManager.GetScreenCount() - 1; i++)
                    {
                        mScreenManager.RemoveScreen();
                    }
                }

                break;

            case EScreen.SaveGameScreen:
                if (sPressed == "Back")
                {
                    SwitchScreen(EScreen.GamePauseScreen, mSaveGameScreen, mGamePauseScreen, gametime);
                }

                if (sPressed == "Save Game")
                {
                    mScreenManager.RemoveScreen();
                    mScreenManager.AddScreen(mSaveGameScreen);
                    // SwitchScreen(EScreen.SaveGameScreen, mSaveGameScreen, mSaveGameScreen, gametime);
                    // SwitchScreen(EScreen.SaveGameScreen, mGamePauseScreen, mSaveGameScreen, gametime);
                    sPressed = "None";
                }

                if (sPressed == "Save1")
                {
                    mGameSaveStrings = XSerializer.GetSaveNames();
                    var path = @"%USERPROFILE%\Saved Games\Singularity\Saves";
                    if (mGameSaveStrings.Length >= 1)
                    {
                        path = Environment.ExpandEnvironmentVariables(path);
                        path = path + @"\" + mGameSaveStrings[0];
                    }

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    SaveGame();
                }

                if (sPressed == "Save2")
                {
                    mGameSaveStrings = XSerializer.GetSaveNames();
                    var path = @"%USERPROFILE%\Saved Games\Singularity\Saves";
                    if (mGameSaveStrings.Length >= 2)
                    {
                        path = Environment.ExpandEnvironmentVariables(path);
                        path = path + @"\" + mGameSaveStrings[1];
                    }

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    SaveGame();
                }

                if (sPressed == "Save3")
                {
                    mGameSaveStrings = XSerializer.GetSaveNames();
                    var path = @"%USERPROFILE%\Saved Games\Singularity\Saves";
                    if (mGameSaveStrings.Length >= 3)
                    {
                        path = Environment.ExpandEnvironmentVariables(path);
                        path = path + @"\" + mGameSaveStrings[2];
                    }

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    SaveGame();
                }

                if (sPressed == "Save4")
                {
                    mGameSaveStrings = XSerializer.GetSaveNames();
                    var path = @"%USERPROFILE%\Saved Games\Singularity\Saves";
                    if (mGameSaveStrings.Length >= 4)
                    {
                        path = Environment.ExpandEnvironmentVariables(path);
                        path = path + @"\" + mGameSaveStrings[3];
                    }

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    SaveGame();
                }

                if (sPressed == "Save5")
                {
                    mGameSaveStrings = XSerializer.GetSaveNames();
                    var path = @"%USERPROFILE%\Saved Games\Singularity\Saves";
                    if (mGameSaveStrings.Length >= 5)
                    {
                        path = Environment.ExpandEnvironmentVariables(path);
                        path = path + @"\" + mGameSaveStrings[4];
                    }

                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    SaveGame();
                }

                break;

            case EScreen.StatisticsScreen:
                if (sPressed == "Back")
                {
                    SwitchScreen(EScreen.GamePauseScreen, mStatisticsScreen, mGamePauseScreen, gametime);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }