public override void Update( GameTime gameTime ) { if ( Keyboard.GetState( ).IsKeyDown2( Keys.Enter ) ) { SelectedMenu = new MainMenu( Game ); } }
public override void Update( GameTime gameTime ) { if ( Keyboard.GetState( ).IsKeyDown( Keys.Down ) ) { _targetRectangle.Y -= 10; } else if ( Keyboard.GetState( ).IsKeyDown( Keys.Up ) ) { _targetRectangle.Y += 10; } _targetRectangle.Y = ( int ) MathHelper.Clamp( _targetRectangle.Y, TheStory.GAME_HEIGHT - Assets.WorldMapTexture.Height, 0 ); int prevLocation = _currentLocation; // select location if ( Keyboard.GetState( ).IsKeyDown2( Keys.Left ) ) { --_currentLocation; } else if ( Keyboard.GetState( ).IsKeyDown2( Keys.Right ) ) { ++_currentLocation; } _currentLocation = ( int ) MathHelper.Clamp( _currentLocation, 0, LOCATIONS.Length - 1 ); // if the current location is not visible, scroll it into view Vector2 currentLoc = LOCATIONS[_currentLocation]; float difference = currentLoc.Y - ( Math.Abs( _targetRectangle.Y ) + TheStory.GAME_HEIGHT ) + VIEW_OFFSET; if ( difference > 0 ) { difference = difference / 5; } else { difference = currentLoc.Y - Math.Abs( _targetRectangle.Y ) - VIEW_OFFSET; if ( difference < 0 ) { difference = difference / 5; } else { // nothing difference = 0f; } } _targetRectangle.Y -= ( int ) difference; if ( Keyboard.GetState( ).IsKeyDown2( Keys.Enter ) ) { switch ( _currentLocation ) { case 0: SelectedLevel = new ViridesPuirr( Game, 0 ); break; case 1: SelectedLevel = new Calipuirr( Game, 1 ); break; case 2: SelectedLevel = new EllyuteionLake( Game, 2 ); break; case 3: SelectedLevel = new MirrosHills( Game, 3 ); break; case 4: SelectedLevel = new Pandorashys( Game, 4 ); break; default: break; } } else if ( Keyboard.GetState( ).IsKeyDown2( Keys.Back ) ) { SelectedMenu = new MainMenu( Game ); } }