public virtual void HandleInput( InputState input ) { if ( input.MuteToggle ) { GameEngine.AudioManager.MuteToggle(); } if ( input.MenuCancel ) { ScreenManager.AddScreen(new MainMenu()); ScreenManager.RemoveScreen( this ); } }
//---------------------------------------------------------------- // Methods //---------------------------------------------------------------- public void HandleInput( InputState input ) { up = input.MoveUp; down = input.MoveDown; left = input.MoveLeft; right = input.MoveRight; if ( input.NinjaPickUp ) m_ninja.m_picking_up = !m_ninja.m_picking_up; throw_obj = input.NinjaThrow; boost = input.NinjaBoost; if ( input.NinjaToggle ) { m_ninja.m_cruise = !m_ninja.m_cruise; //prevent ridiculous acceleration if ( m_ninja.m_cruise ) { m_ninja.m_body.Restitution /= 1.7f; } else { m_ninja.m_body.Restitution *= 1.7f; } } }
public override void HandleInput( InputState input ) { // Move to the previous level? /* if (input.PreviousLevel) { m_current_level--; if (m_current_level < 0) m_current_level = m_worlds.Length - 1; } */ // Move to the next level? //Disables inputs if editor has focus if ( !m_editor_focused ) { if ( input.NextLevel && m_current_world.m_succeeded ) { GameEngine.LevelManager.next_level(); if ( GameEngine.LevelManager.get_current_level().Equals( "end" ) ) { GameEngine.AudioManager.Stop(); ScreenManager.AddScreen( new EndScreen() ); ScreenManager.RemoveScreen( this ); } else { float time = GameEngine.LevelManager.timer_select(); m_timer.set( time ); m_checkpoint_timer = (int)Math.Ceiling( time ); m_current_world = new TestWorld( GameScreen.m_curr_view, editor, GameEngine.LevelManager.get_current_level() ); m_background = GAME_CONTENT.Load<Texture2D>( GameEngine.LevelManager.background_texture ); } } if ( input.PauseGame ) { m_paused = !m_paused; } if ( input.HaltControllers ) { m_halted = !m_halted; } if ( input.ResetLevel ) { float time = GameEngine.LevelManager.timer_select(); m_timer.set( time ); m_paused = false; if ( m_current_world.curr_filename != null && m_current_world.curr_filename != "" ) { try { m_current_world = new TestWorld( GameScreen.m_curr_view, editor, m_current_world.curr_filename, teleport_camera: false ); m_background = GAME_CONTENT.Load<Texture2D>( GameEngine.LevelManager.background_texture ); m_timer.set( m_checkpoint_timer ); } catch { m_current_world = new TestWorld( GameScreen.m_curr_view, editor, GameEngine.LevelManager.get_current_level(), teleport_camera: false); m_background = GAME_CONTENT.Load<Texture2D>( GameEngine.LevelManager.background_texture ); m_checkpoint_timer = (int)Math.Ceiling( time ); Console.WriteLine( "ERROR when loading level. Aborting to the beginning" ); } } else { m_checkpoint_timer = (int)Math.Ceiling( time ); m_current_world = new TestWorld( GameScreen.m_curr_view, editor, GameEngine.LevelManager.get_current_level(), teleport_camera: false); m_background = GAME_CONTENT.Load<Texture2D>( GameEngine.LevelManager.background_texture ); } } if ( input.RestartLevel && m_paused ) { float time = GameEngine.LevelManager.timer_select(); m_checkpoint_timer = (int)Math.Ceiling( time ); m_timer.set( time ); m_paused = false; m_current_world = new TestWorld( GameScreen.m_curr_view, editor, GameEngine.LevelManager.get_current_level() ); m_background = GAME_CONTENT.Load<Texture2D>( GameEngine.LevelManager.background_texture ); } if ( input.ToggleEditMode ) { editor.clearLine(); System.Drawing.Point loc = Form.FromHandle( GameEngine.GameWindow.Handle ).Location; if ( !editor_mode ) { editor.Show(); editor.TopMost = true; } else { FORM_OFFSET = 0; editor.Hide(); } editor_mode = !editor_mode; } if ( editor_mode ) { if ( input.editor_hide_show ) { editor.Visible = !editor.Visible; } //BLAH editor_camera_movement = Vector2.Zero; if ( input.MoveUp ) editor_camera_movement.Y--; if ( input.MoveDown ) editor_camera_movement.Y++; if ( input.MoveLeft ) editor_camera_movement.X--; if ( input.MoveRight ) editor_camera_movement.X++; if ( input.ZoomIn ) m_curr_view.m_camera_zoom = Math.Min( m_curr_view.m_camera_zoom + 0.1f, 0.8f ); if ( input.ZoomOut ) m_curr_view.m_camera_zoom = Math.Max( m_curr_view.m_camera_zoom - 0.1f, 0.15f ); m_curr_view.m_camera_position += editor_camera_movement * 30 / m_curr_view.m_camera_zoom; if ( editor.currentTool == Editor.EditorTool.Selection && editor.current_selector != null ) { if ( input.LeftMouseClick && editor.current_selector.m_body != null && editor.current_selector.m_body.FixtureList != null ) { editor.current_selector.m_body.Position = editor.getMouse(); } } } else { if ( m_current_world != null ) { m_current_world.m_ninja_controller.HandleInput( input ); } } } // Accept or cancel the menu? if ( input.MenuCancel ) { OnCancel(); } base.HandleInput( input ); }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput( InputState input ) { // Move to the previous menu entry? if ( input.MenuUp ) { selectedEntry--; if ( selectedEntry < 0 ) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if ( input.MenuDown ) { selectedEntry++; if ( selectedEntry >= menuEntries.Count ) selectedEntry = 0; } // Accept or cancel the menu? if ( input.MenuSelect ) { OnSelectEntry( selectedEntry ); } else if ( input.MenuCancel ) { OnCancel(); } if ( input.LeftMouseClick ) { for ( int i = 0; i < menuEntries.Count; i++ ) { if ( input.LastMouseState.Y > entryPositions[i].Y && input.LastMouseState.Y < entryPositions[i].Y + menuSpriteFont.LineSpacing ) { OnSelectEntry( i ); } } } for ( int i = 0; i < menuEntries.Count; i++ ) { if ( input.LastMouseState.Y > entryPositions[i].Y && input.LastMouseState.Y < entryPositions[i].Y + menuSpriteFont.LineSpacing ) { selectedEntry = i; } } }