Ejemplo n.º 1
0
        public void ReturnToLastState()
        {
            iGameState tempState = currentState;

            this.currentState = lastState;
            this.lastState    = tempState;
        }
Ejemplo n.º 2
0
 public override void Update()
 {
     if (InputHandler.playerSelect())
     {
         next = new RoomViewer();
     }
 }
Ejemplo n.º 3
0
 public MenuState(DodgerX dodgerobj, String[] MenuOptions, iGameState[] MenuStates)
     : this(dodgerobj,MenuOptions,(from p in MenuStates select MenuStateItem.DefaultAdvanceRoutine(p)).ToArray())
 {
 }
Ejemplo n.º 4
0
 public static StateAdvanceRoutine DefaultAdvanceRoutine(iGameState advanceState)
 {
     return new StateAdvanceRoutine((msi, dx) => dx.CurrentState = advanceState);
 }
Ejemplo n.º 5
0
 public MenuStateItem(String pCaption, iGameState pAdvanceState, Vector2 pLocation,SpriteFont usefont)
     : this(pCaption, DefaultAdvanceRoutine(pAdvanceState), pLocation, usefont)
 {
 }
Ejemplo n.º 6
0
        public static MenuState GetPauseState(DodgerX dx, iGameState currentstate)
        {
            String[] pauseItems = new string[] { "Resume Game", "Quit" };
            var copied = currentstate;
            var pausemenu = new MenuState(dx, pauseItems, new Object[] { new MenuStateItem.StateAdvanceRoutine((msi,dxa)=>
                {
                    dxa.CurrentState = copied;
                    if(copied is GameRunningState)
                    {
                        GameRunningState grs = copied as GameRunningState;
                        GameRunningState.TrackCue.Resume();

                    }

                })

                , MenuState.getMainMenu(dx) });

            pausemenu.MenuLogo = pauselogo;
            return pausemenu;
        }
Ejemplo n.º 7
0
        private MenuState getoptionsstate(iGameState returnstate)
        {
            List<MenuStateItem> createmenu = new List<MenuStateItem>();

            createmenu.Add(new MenuStateItem("Return", returnstate, new Vector2(0, 0), null));

            return new MenuState(this, createmenu.ToArray());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (CurrentState != null)
            {

                if ((PlayingCue == null) || ((CurrentState.MusicTrack!=null) && PlayingCue.Name != CurrentState.MusicTrack.Name))
                {
                    if (PlayingCue != null) PlayingCue.Stop(AudioStopOptions.AsAuthored);
                    PlayingCue = CurrentState.MusicTrack;
                    if (PlayingCue != null) try { PlayingCue.Play(); }
                        catch { }

                }

            }

            if (Keyboard.GetState().IsKeyDown(Keys.Pause) && !PrevKeyboardState.IsKeyDown(Keys.Pause))
            {
                if (CurrentState is GameRunningState)
                {
                    //GameRunningState.TrackCue.Pause();
                    CurrentState = MenuState.GetPauseState(this, CurrentState);
                }

            }

            audioEngine.Update();
            if (!ContentLoaded) return;
            if (CurrentState == null)
            {
                MenuState ms = MenuState.getMainMenu(this);

                CurrentState = new IntroState(LogoImage2,new IntroState(LogoImage,new IntroState(LogoImage3, ms)));

            }
            //audioEngine.Update();
            CurrentState.Update(this, gameTime);

            base.Update(gameTime);
            PrevKeyboardState = Keyboard.GetState();
            PrevMouseState = Mouse.GetState();
        }
Ejemplo n.º 9
0
 public void SetState(iGameState state)
 {
     this.lastState    = currentState;
     this.currentState = state;
 }
Ejemplo n.º 10
0
 public Game()
 {
     World        = new World(this);
     currentState = new OverworldState(this);
 }
Ejemplo n.º 11
0
 //given a image and a succeeding state, shows the logo (fade in, fade out on click or after delay) and then proceeds
 //to the indicated state.
 public IntroState(Texture2D pLogoImage,iGameState NextState)
 {
     LogoImage = pLogoImage;
     _NextState = NextState;
 }