/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(vxInputManager input) { if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.KeyboardState; // input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.GamePadState; // input.CurrentGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected; /* bool gamePadDisconnected = !gamePadState.IsConnected && * input.GamePadWasConnected[playerIndex];*/ //if (input.IsPauseGame() || gamePadDisconnected) if (input.IsPauseGame()) { ShowPauseScreen(); } else { HandleInputBase(input); } }
/// <summary> /// Handles the input base. /// </summary> /// <param name="input">Input.</param> public override void HandleInputBase(vxInputManager input) { // get all of our input states keyboardState = Keyboard.GetState(); touchState = TouchPanel.GetState(); //gamePadState = virtualGamePad.GetState(touchState, GamePad.GetState(PlayerIndex.One)); accelerometerState = Accelerometer.GetState(); //virtualGamePad.Update(gameTimeBase); // #if !NETFX_CORE // // Exit the game when back is pressed. // if (gamePadState.Buttons.Back == ButtonState.Pressed) // vxEngine.Game.Exit(); // #endif }
/// <summary> /// Loop to handle inpurt /// </summary> /// <param name="input">Input Manager</param> public override void HandleInput(vxInputManager input) { if (input.IsNewMouseButtonPress(MouseButtons.LeftButton)) { if (TimeSinceLastClick < 20) { if (CurrentlySelected == HighlightedItem_Previous) Btn_Ok.Select(); } else { TimeSinceLastClick = 0; } HighlightedItem_Previous = CurrentlySelected; } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(vxInputManager input) { //if (input.CurrentMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && // input.LastMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released) if (input.IsNewMouseButtonPress(MouseButtons.LeftButton)) { if (TimeSinceLastClick < 20) { if (CurrentlySelected == HighlightedItem_Previous) { Btn_Ok.Select(); } } else { TimeSinceLastClick = 0; } HighlightedItem_Previous = CurrentlySelected; } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(vxInputManager input) { // Move to the previous menu entry? if (input.IsMenuUp()) { selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } // Move to the next menu entry? if (input.IsMenuDown()) { selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputHelper helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex = PlayerIndex.One; if (input.IsMenuSelect()) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel()) { OnCancel(playerIndex); } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(vxInputManager input) { if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.KeyboardState; // input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.GamePadState; // input.CurrentGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected; /* bool gamePadDisconnected = !gamePadState.IsConnected && * input.GamePadWasConnected[playerIndex];*/ //if (input.IsPauseGame() || gamePadDisconnected) if (input.IsPauseGame()) { if (SandboxStartGameType != vxEnumSandboxGameType.RunGame && SandboxGameState == vxEnumSandboxGameState.Running) { SimulationStop(); } else { ShowPauseScreen(); } } else if (Camera.CameraType == CameraType.Freeroam) { //Update If In Edit Mode if (SandboxGameState == vxEnumSandboxGameState.EditMode) { //Set the Working Plane Height /****************************************************************************************/ if (GUIManager.DoesGuiHaveFocus == false && vxEngine.InputManager.MouseState.MiddleButton == ButtonState.Released) { if (vxEngine.InputManager.ScrollWheelDelta > 0) { WrkngPln_HeightDelta += 0.5f; } else if (vxEngine.InputManager.ScrollWheelDelta < 0) { WrkngPln_HeightDelta -= 0.5f; } workingPlane.Position = Vector3.Up * WrkngPln_HeightDelta; } } /**********************************************************/ /* Left Button Press */ /**********************************************************/ if (vxEngine.InputManager.IsNewMouseButtonPress(MouseButtons.LeftButton)) { //Only do this if the GUI Manager isn't being used if (GUIManager.DoesGuiHaveFocus == false && Cursor.IsMouseHovering == false) { //If it's in 'AddItem' Mode, then Add the Current Key Item if (MouseClickState == vxEnumSanboxMouseClickState.AddItem) { //Set the Location of the current temp_part being added. if (temp_part != null) { AddSandboxItem(CurrentlySelectedKey, temp_part.World); } } else if (MouseClickState == vxEnumSanboxMouseClickState.SelectItem) { //Clear Addative Selection if (vxEngine.InputManager.KeyboardState.IsKeyDown(Keys.LeftShift) == false && Cursor.SelectionState != vxEnumSelectionState.Hover) { for (int ind = 0; ind < SelectedItems.Count; ind++) { SelectedItems[ind].SelectionState = vxEnumSelectionState.Unseleced; } SelectedItems.Clear(); SetElementIndicies(); } if (Index > 0 && Index < Items.Count) { if (SelectedItems.Contains(Items[Index]) == false) { SelectedItems.Add(Items[Index]); Items[Index].SelectionState = vxEnumSelectionState.Selected; Items[Index].GetProperties(PropertiesControl); // Raise the 'Changed' event. if (ItemSelected != null) { ItemSelected(this, new EventArgs()); } } else { Items[Index].SelectionState = vxEnumSelectionState.Hover; SelectedItems.Remove(Items[Index]); } } } } } /**********************************************************/ /* Right Button Press */ /**********************************************************/ if (vxEngine.InputManager.IsNewMouseButtonPress(MouseButtons.RightButton)) { RightClick(); } /**********************************************************/ /* Process Keys */ /**********************************************************/ //Delete Selected Items if (vxEngine.InputManager.IsNewKeyPress(Keys.Delete)) { foreach (vxSandboxEntity sandboxEntity in SelectedItems) { sandboxEntity.DisposeEntity(); } SelectedItems.Clear(); SetElementIndicies(); } } HandleInputBase(input); }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(vxInputManager input) { }
/// <summary> /// Handles the input base. /// </summary> /// <param name="input">Input.</param> public virtual void HandleInputBase(vxInputManager input) { }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { #if !DEBUG try { #endif #if DEBUG BuildConfigType = vxBuildConfigType.Debug; #else BuildConfigType = vxBuildConfigType.Release; #endif vxConsole.WriteLine(""); vxConsole.WriteLine(""); vxConsole.WriteLine(""); vxConsole.WriteLine("Starting Vertices Engine"); vxEnviroment.Initialize(this); vxConsole.WriteLine("Checking Directories"); //The Android System uses the Isolated Storage for it's GameSaves #if VRTC_PLTFRM_DROID IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null); string settings = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SETTINGS).Value.ToString(); string sandbox = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SANDBOX).Value.ToString(); //First Check, if the Profiles Directory Doesn't Exist, Create It if (isoStore.DirectoryExists(settings) == false) { isoStore.CreateDirectory(settings); } //First Check, if the Sandbox Directory Doesn't Exist, Create It if (isoStore.DirectoryExists(sandbox) == false) { isoStore.CreateDirectory(sandbox); } //First Check, if the Temp Directory Doesn't Exist, Create It if (isoStore.DirectoryExists("Temp/Settings") == false) { isoStore.CreateDirectory("Temp/Settings"); } #else string settings = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SETTINGS).Value.ToString(); string sandbox = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_SANDBOX).Value.ToString(); //First Check, if the Profiles Directory Doesn't Exist, Create It if (Directory.Exists(settings) == false) { Directory.CreateDirectory(settings); } //First Check, if the Sandbox Directory Doesn't Exist, Create It if (Directory.Exists(sandbox) == false) { Directory.CreateDirectory(sandbox); } //First Check, if the Temp Directory Doesn't Exist, Create It if (Directory.Exists("Temp/Settings") == false) { Directory.CreateDirectory("Temp/Settings"); } #endif vxConsole.WriteLine("Starting Content Manager"); // Load content belonging to the screen manager. ContentManager content = Game.Content; EngineContentManager = new ContentManager(Game.Services); // Initialise the Engine Speciality Content Manager. vxContentManager = new vxContentManager(this); //Set Location of Content Specific too Platform EngineContentManager.RootDirectory = vxEnviroment.GetVar(vxEnumEnvVarType.PATH_ENGINE_CONTENT).Value.ToString(); #if VRTC_PLTFRM_DROID Game.Activity.Window.AddFlags(WindowManagerFlags.Fullscreen); Game.Activity.Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen); #endif #if VIRTICES_2D LineBatch = new vxLineBatch(GraphicsDevice); AssetCreator = new vxAssetCreator2D(GraphicsDevice); AssetCreator.LoadContent(_engineContentManager); #endif InputManager = new vxInputManager(this); InputManager.LoadContent(); InputManager.ShowCursor = true; SpriteBatch = new SpriteBatch(GraphicsDevice); //Initialise vxEngine Assets Assets = new vxInternalAssetManager(this); vxGUITheme = new vxGUITheme(this); vxGUITheme.Font = this.Assets.Fonts.MenuFont; #region Initialise Debug Console //Get the vxEngine Version through Reflection EngineVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); // initialize the debug system with the game and the name of the font // we want to use for the debugging DebugSystem = vxDebugSystem.Initialize(this, "Fonts/font_debug"); DebugSystem.TimeRuler.ShowLog = true; //Initialise the Debug Renderer vxDebugShapeRenderer.Initialize(GraphicsDevice); vxConsole.Initialize(this); //Now Setup Settings Managers GraphicsSettingsManager = new vxGraphicsSettingsManager(this); #endregion #if !VRTC_PLTFRM_DROID Model_Sandbox_WorkingPlane = this.Assets.Models.UnitPlane; #endif #if VRTC_INCLDLIB_NET InitialiseMasterServerConnection(); ServerManager = new vxNetworkServerManager(this, 14242); ClientManager = new vxNetworkClientManager(this); #endif #region Load Base Language Languages = new List <vxLanguagePackBase> (); LoadLanguagePacks(); //Default is English this.Language = Languages [0]; #endregion #if VIRTICES_3D //Initialise Renderer Renderer = new vxRenderer(this); Renderer.LoadContent(); #endif //Load in Profile Data Profile.LoadSettings(this); //Once all items are Managers and Engine classes are intitalised, then apply any and all passed cmd line arguments vxEnviroment.ApplyCommandLineArgs(); //Set Initial Graphics Settings GraphicsSettingsManager.Apply(); // Tell each of the screens to load their content. foreach (vxGameBaseScreen screen in screens) { screen.LoadContent(); } #if !DEBUG } catch (Exception ex) { vxCrashHandler.Init(this, ex); } #endif }
private void HandleCamera(vxInputManager input, GameTime gameTime) { Vector2 camMove = Vector2.Zero; if (input.KeyboardState.IsKeyDown(Keys.Up)) { camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (input.KeyboardState.IsKeyDown(Keys.Down)) { camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (input.KeyboardState.IsKeyDown(Keys.Left)) { camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (input.KeyboardState.IsKeyDown(Keys.Right)) { camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (input.KeyboardState.IsKeyDown(Keys.PageUp)) { Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f; } if (input.KeyboardState.IsKeyDown(Keys.PageDown)) { Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f; } #if !VRTC_PLTFRM_XNA //Panning Control if (input.MouseState.MiddleButton == ButtonState.Pressed) { camMove = -Vector2.Subtract(input.MouseState.Position.ToVector2(), input.PreviousMouseState.Position.ToVector2()) / 20; } #else //Panning Control if (input.MouseState.MiddleButton == ButtonState.Pressed) { camMove = -Vector2.Subtract(new Vector2(input.MouseState.X, input.MouseState.Y), new Vector2(input.PreviousMouseState.X, input.PreviousMouseState.Y)) / 20; } #endif float scrollSens = 1; if (input.MouseState.ScrollWheelValue - input.PreviousMouseState.ScrollWheelValue > 0) { Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / scrollSens; } else if (input.MouseState.ScrollWheelValue - input.PreviousMouseState.ScrollWheelValue < 0) { Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / scrollSens; } if (camMove != Vector2.Zero) { Camera.MoveCamera(camMove); } if (input.IsNewKeyPress(Keys.Home)) { Camera.ResetCamera(); } }