Ejemplo n.º 1
0
 /// <summary>
 /// Loads any content specific to this screen.
 /// </summary>
 /// <param name="content">Content Manager that should handle the content loading</param>
 public void LoadContent(ContentManager content)
 {
     // Add screen to screen manager
     if (mScreenState == EScreen.GamePauseScreen)
     {
         mScreenManager.AddScreen(mGamePauseScreen);
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            GraphicsUtils.Instance.SpriteBatch = new SpriteBatch(GraphicsDevice);
            GraphicsUtils.Instance.Load(ContentManager);

            ScreenManager.SetScreenTransition(
                new FadeTransition
            {
                Speed = 3f
            }
                );

            ScreenManager.AddScreen(
                new SplashScreen
            {
                BackgroundColor = Color.White
            }
                );

            InputManager.RegisterInputEvent(new KeyInputBinding(Keys.F1),
                                            callback: () =>
            {
                var activeScreen     = ScreenManager.GetActiveScreen();
                activeScreen.IsDebug = !activeScreen.IsDebug;
            });
        }
Ejemplo n.º 3
0
        public override void Update(TimeSpan elapsed)
        {
            if (_screenManager.InputManager.State.KeyPressed == Key.Enter)
            {
                var screen = new GameScreen(_screenManager, _rendererWidth, _rendererHeight);
                _screenManager.AddScreen(screen);
                _screenManager.RemoveScreen(this);

                screen.Show();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            var viewportResolution = new Vector2(GraphicsDevice.Viewport.Width,
                                                 GraphicsDevice.Viewport.Height);

            // Create a new SpriteBatch, which can be used to draw textures.
            mSpriteBatch = new SpriteBatch(GraphicsDevice);

            mLoadGameManager = new LoadGameManagerScreen(mGraphics, ref mDirector, Content, viewportResolution, mScreenManager, this);
            mMainMenuManager = new MainMenuManagerScreen(viewportResolution, mScreenManager, ref mDirector, true, this);

            //ATTENTION: THE INGAME SCREENS ARE HANDLED IN THE LEVELS NOW!
            mScreenManager.AddScreen(mLoadGameManager);
            mScreenManager.AddScreen(mMainMenuManager);

            // TODO: load and play Soundtrack as background music
            // director.GetSoundManager.LoadContent(Content);
            //_mSoundManager.PlaySoundTrack();
            //XSerializer.Save(new Skirmish(mGraphics, ref mDirector, Content, mScreenManager), "SwagSireDrizzle's_Game.xml", false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(IScreenManager screenManager, bool loadingIsSlow,
            PlayerIndex? controllingPlayer,
            params Screen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (Screen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(loadingIsSlow, screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Calls the corresponding handle method, for the levels. These will handle Events etc.
        /// </summary>
        /// <param name="time"></param>
        public void Update(GameTime time)
        {
            if (mLoadTutorialScreen)
            {
                mScreenManager.AddScreen(mTutorialScreen);
                mLoadTutorialScreen = false;
            }

            switch (mLevelType)
            {
            case LevelType.None:
                break;

            case LevelType.Tutorial:
                HandleTutorial();
                break;

            case LevelType.Skirmish:
                //Not sure if theres anything to handle in Skirmish
                //TODO: Make clear whether we want any events or such things in Skirmish
                break;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(IScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex?controllingPlayer,
                                params Screen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (Screen screen in screenManager.GetScreens())
            {
                screen.ExitScreen();
            }

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(loadingIsSlow, screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
        /// <summary>
        /// Loads any content specific to this screen.
        /// </summary>
        /// <param name="content">Content Manager that should handle the content loading</param>
        public void LoadContent(ContentManager content)
        {
            // Add screen to screen manager
            mScreenManager.AddScreen(mMenuBackgroundScreen);

            if (mScreenState == EScreen.SplashScreen)
            {
                mScreenManager.AddScreen(mSplashScreen);
            }
            else if (mScreenState == EScreen.MainMenuScreen)
            {
                mScreenManager.AddScreen(mMainMenuScreen);
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 9
0
        private void CollisionSystem_OnCollisionDetected(CollisionSystem system, ICollidable first, ICollidable second)
        {
            if (first is SnakeBit && second is Food food)
            {
                IncrementScore();

                _foods.Remove(food);
                _snake.GrowSnake();
                _collisionSystem.Remove(food);
            }
            else if (first is SnakeBit bit1 && second is SnakeBit bit2)
            {
                if (!_isGameOver)
                {
                    var screen = new GameOverScreen(_screenManager, _rendererWidth, _rendererHeight, _score);
                    _screenManager.AddScreen(screen);
                    _screenManager.RemoveScreen(this);

                    screen.Show();
                }

                _isGameOver = true;
            }
        }
Ejemplo n.º 10
0
        public void AddScreenToDictionaryByName()
        {
            _screenManager.AddScreen(_screen);

            _screenManager.Screens[_screen.Name].ShouldBe(_screen);
        }
Ejemplo n.º 11
0
        /// <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";
        }
Ejemplo n.º 12
0
 // the pause button opens the pause menu screen
 private void PauseButtonReleased(object sender, EventArgs eventArgs)
 {
     GlobalVariables.mGameIsPaused = true;
     mScreenManager.AddScreen(mGamePauseManagerScreen);
 }