예제 #1
0
        /// <summary>
        /// The Method to load the Achievements. The Achievements file has to be at %USERPROFILE%\Saved Games\Singularity\Achievements. If no one like this exists
        /// it will just create a new one.
        /// </summary>
        internal void LoadAchievements()
        {
            var achievements = XSerializer.Load(@"Achievements.xml", true);

            if (achievements.IsPresent())
            {
                mAchievements = (AchievementInstance)achievements.Get();
            }
            else
            {
                mAchievements = new AchievementInstance();
            }

            mAchievements.LoadToStatic();
        }
예제 #2
0
        private void LoadConfig()
        {
            var configuration = XSerializer.Load(@"Config.xml", true);

            if (configuration.IsPresent())
            {
                mInstance = (GlobalVariablesInstance)configuration.Get();
            }
            else
            {
                mInstance = new GlobalVariablesInstance();
            }

            mInstance.LoadToStatic();
        }
        /// <summary>
        /// Updates the state of the LoadGameManager and changes to the game if the conditions are met.
        /// by the stack screen manager
        /// </summary>
        /// <param name="gametime"></param>
        public void Update(GameTime gametime)
        {
            if (mGameLoaded)
            {
                mGameLoaded = false;
            }

            if (sResolutionChanged)
            {
                sResolutionChanged = false;
            }

            switch (sPressed)
            {
            case "None":
                return;

            case "Skirmish":
                mLevel      = new Skirmish(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Skirmish);
                mGameScreen = mLevel.GameScreen;
                mUi         = mLevel.Ui;
                mNewGame    = true;
                break;

            case "TechDemo":
                mLevel      = new TechDemo(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Techdemo);
                mGameScreen = mLevel.GameScreen;
                mUi         = mLevel.Ui;
                mNewGame    = true;
                break;

            case "Tutorial":
                mLevel      = new Tutorial(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Tutorial);
                mGameScreen = mLevel.GameScreen;
                mUi         = mLevel.Ui;
                mNewGame    = true;
                break;

            case "Save1":
                mName = XSerializer.GetSaveNames()[0];
                break;

            case "Save2":
                mName = XSerializer.GetSaveNames()[1];
                break;

            case "Save3":
                mName = XSerializer.GetSaveNames()[2];
                break;

            case "Save4":
                mName = XSerializer.GetSaveNames()[3];
                break;

            case "Save5":
                mName = XSerializer.GetSaveNames()[4];
                break;

            case "ReturnToMainMenu":
                int width;
                int height;
                if (GlobalVariables.IsFullScreen)
                {
                    width  = mGame.mGraphicsAdapter.CurrentDisplayMode.Width;
                    height = mGame.mGraphicsAdapter.CurrentDisplayMode.Height;
                }
                else
                {
                    width  = GlobalVariables.ResolutionList[GlobalVariables.ChosenResolution].Item1;
                    height = GlobalVariables.ResolutionList[GlobalVariables.ChosenResolution].Item2;
                }

                mScreenManager.AddScreen(new MainMenuManagerScreen(screenResolution: new Vector2(width, height),
                                                                   screenManager: mScreenManager,
                                                                   director: ref mDirector,
                                                                   showSplash: false,
                                                                   game: mGame));
                break;

            default:
                throw new InvalidGenericArgumentException(
                          "Somehow the LoadGameManagerScreen was assigned to a button that he should not have been assigned to. Cannot handle" +
                          "this State");
            }

            //This means a save has to be loaded
            if (mName != "")
            {
                var levelToBe = XSerializer.Load(mName, false);
                if (levelToBe.IsPresent())
                {
                    mLevel = (ILevel)levelToBe.Get();
                    mLevel.ReloadContent(mContent, mGraphics, ref mDirector, mScreenManager);
                    mGameScreen = mLevel.GameScreen;
                    mUi         = mLevel.Ui;
                    //Remove all screens above this screen, of course this only works if this screen is really on the bottom of the stack
                    for (var i = mScreenManager.GetScreenCount() - 1; i > 1; i--)
                    {
                        mScreenManager.RemoveScreen();
                    }
                    mScreenManager.AddScreen(mGameScreen);
                    mScreenManager.AddScreen(mUi);
                    mDirector.GetStoryManager.SetScreenManager(mScreenManager);
                    mGameLoaded = true;
                    mName       = "";
                    GlobalVariables.mGameIsPaused = false;
                }
            }

            else if (mNewGame)
            {
                //Remove all screens above this screen, of course this only works if this screen is really on the bottom of the stack
                for (var i = mScreenManager.GetScreenCount() - 1; i > 0; i--)
                {
                    mScreenManager.RemoveScreen();
                }
                mScreenManager.AddScreen(mGameScreen);
                mScreenManager.AddScreen(mUi);

                mGameLoaded = true;
                mNewGame    = false;
                GlobalVariables.mGameIsPaused = false;
            }

            sPressed = "None";
        }