Example #1
0
        /// <summary>
        /// This method is self explanitory, it asks for the class name you wish to add to the screenstack and pushes
        /// it onto the top.
        /// </summary>
        /// <param name="screenName"></param>
        public void Add(string screenName)
        {
            //Halt the sound manager
            Locator.Instance.getService <SoundManager>().Stop();
            //Create the new requested screen and initialize it
            BaseScreen myScreen = (BaseScreen)Activator.CreateInstance(Type.GetType("Engine." + screenName));

            myScreen.Initialize();
            //Push the initialized screen onto the screenstack
            screenStack.Push(myScreen);
            //Call the screen change method for subscribers
            onScreenChange(myScreen);
        }
Example #2
0
        /// <summary>
        /// Removes the top screen from the stack. Should be used in situations such as if
        /// the
        /// er has lost all of his lives and the state should be reverted back to the menu screen
        /// this will be your god. It basically goes back one screen :)
        /// </summary>
        public void RemoveTopScreen()
        {
            IScreen screen = screenStack.Peek();

            screen.Unload();
            screenStack.Pop();
            Locator.Instance.getService <CameraManager>().getCam().reset();

            BaseScreen myScreen = screenStack.Peek();


            onScreenChange(myScreen);
        }
Example #3
0
        /// <summary>
        /// This is probably the worst way of going about it but this method checks the top screen and updates it
        /// Although this will not be relevant soon since screen updates will be decided through ENUMS.
        /// </summary>
        /// <param name="gameTime"></param>

        public void UpdateTopScreen(GameTime gameTime)
        {
            BaseScreen updateScreen = screenStack.Peek();

            updateScreen.Update(gameTime);
        }
Example #4
0
/// <summary>
/// Currently draws the topmost screen, needs to be improved to support things such as pop ups
/// It'll be a simple fix to check to see which screens are requesting to be drawn
/// and draw them in the order of the stack.
/// </summary>
/// <param name="spriteBatch"></param>
        public void Draw(SpriteBatch spriteBatch)
        {
            BaseScreen DrawScreen = screenStack.Peek();

            DrawScreen.Draw(spriteBatch);
        }