public void ReturnToLastState() { iGameState tempState = currentState; this.currentState = lastState; this.lastState = tempState; }
public override void Update() { if (InputHandler.playerSelect()) { next = new RoomViewer(); } }
public MenuState(DodgerX dodgerobj, String[] MenuOptions, iGameState[] MenuStates) : this(dodgerobj,MenuOptions,(from p in MenuStates select MenuStateItem.DefaultAdvanceRoutine(p)).ToArray()) { }
public static StateAdvanceRoutine DefaultAdvanceRoutine(iGameState advanceState) { return new StateAdvanceRoutine((msi, dx) => dx.CurrentState = advanceState); }
public MenuStateItem(String pCaption, iGameState pAdvanceState, Vector2 pLocation,SpriteFont usefont) : this(pCaption, DefaultAdvanceRoutine(pAdvanceState), pLocation, usefont) { }
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; }
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()); }
/// <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(); }
public void SetState(iGameState state) { this.lastState = currentState; this.currentState = state; }
public Game() { World = new World(this); currentState = new OverworldState(this); }
//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; }