public override void HandleInput(InputState input) { if (input.IsLeftClicked()) { LoadingScreen.Load(ScreenManager, false, PlayerIndex.One, new GameplayScreen(), new PauseMenuScreen()); ExitScreen(); } }
public override void HandleInput(InputState input) { if (ScreenState != ScreenState.Active) return; PlayerIndex playerIndex; // 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 InputState helper returns to us which player // actually provided the input. We pass that through to our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect(ControllingPlayer, out playerIndex) || input.IsLeftClicked()) { // Raise the accepted event, then exit the screen. if (Accepted != null) Accepted(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { // Raise the cancelled event, then exit the screen. if (Cancelled != null) Cancelled(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } }
/// <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.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } bool mouseOver = false; Point mousePos = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y); for (int i = 0; i < menuEntries.Count; i++) { if (menuEntries[i].BoundingRectangle.Contains(mousePos)) { mouseOver = true; selectedEntry = i; } } // 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 InputState 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; if (input.IsMenuSelect(ControllingPlayer, out playerIndex) || (mouseOver && input.IsLeftClicked())) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }
void HandleEquipment(InputState input) { Vector2 m = mousePos * gameContent.scale; Point mp = new Point((int)m.X, (int)m.Y); Equipment mouseOverEq = null; if (mouseEq == null) foreach (Equipment e in equipments) { e.isMouseOver = false; if (mouseOverEq == null && !isMenuEntrySelected && (e.MoveButtonBound.Contains(mp) || e.RotationButtonBound.Contains(mp))) { mouseOverEq = e; e.isMouseOver = true; } } if (input.IsLeftClicked() && mouseOverEq != null) { if (mouseOverEq.MoveButtonBound.Contains(mp) || mouseOverEq.RotationButtonBound.Contains(mp)) { MouseJointDef mjd = new MouseJointDef(); mjd.maxForce = 500; //mjd.frequencyHz = 10f; mjd.dampingRatio = .1f; mjd.target = mousePos; mjd.bodyA = mouseGroundBody; mjd.bodyB = mouseOverEq.body; mouseJoint = (MouseJoint)world.CreateJoint(mjd); mouseEq = mouseOverEq; mouseEq.body.SetAngularDamping(20000); if (mouseOverEq.RotationButtonBound.Contains(mp)) { RevoluteJointDef rjd = new RevoluteJointDef(); rjd.bodyA = mouseGroundBody; rjd.bodyB = mouseOverEq.body; rjd.localAnchorA = mouseOverEq.body.Position; rjd.localAnchorB = Vector2.Zero; pin = world.CreateJoint(rjd); mouseEq.body.SetAngularDamping(20); } if (selectedEq != mouseOverEq) { if (selectedEq != null) { selectedEq.isSelected = false; selectedEq.SetMode(editMode, false); selectedEq = null; } selectedEq = mouseOverEq; selectedEq.isClamped = false; selectedEq.isSelected = true; } mouseEq.SetMode(editMode, true); } } else if (mouseOverEq != null && input.IsRightClicked() || input.CurrentMouseState[0].LeftButton == ButtonState.Released) { if (mouseJoint != null && mouseEq != null) { world.DestroyJoint(mouseJoint); mouseJoint = null; if (pin != null) { world.DestroyJoint(pin); pin = null; } mouseEq.SetMode(editMode, false); mouseEq = null; } if (mouseOverEq != null && input.IsRightClicked()) { selectedEq = null; mouseOverEq.Remove(); equipments.Remove(mouseOverEq); } } // Remove if (!equipmentAdded && (input.IsLeftClicked() || input.IsRightClicked()) && mouseOverEq == null && mouseEq == null && selectedEq != null) { selectedEq.isSelected = false; selectedEq.SetMode(editMode, false); selectedEq = null; } equipmentAdded = false; }
void HandleAtom(InputState input) { Atom mouseOverAtom = null; foreach (Atom a in atoms) { if (mouseAtom == null && !isMenuEntrySelected && a.eye < EyeState.Disappear && a.fixture.TestPoint(mousePos)) mouseOverAtom = a; } // click to add atoms if (mouseOverAtom == null && input.IsLeftClicked() && isLAB && !editMode && !isMenuEntrySelected) atoms.Add(new Atom((Symbol)(gameContent.random.Next(gameContent.symbolCount - 1) + 1), mousePos * gameContent.scale, gameContent, world)); if (input.IsLeftClicked()) { if (mouseOverAtom != null) { MouseJointDef mjd = new MouseJointDef(); mjd.maxForce = 500; //mjd.frequencyHz = 10; //mjd.dampingRatio = .1f; mjd.target = mouseOverAtom.body.Position; mjd.bodyA = mouseGroundBody; mjd.bodyB = mouseOverAtom.body; mouseJoint = (MouseJoint)world.CreateJoint(mjd); mouseAtom = mouseOverAtom; mouseAtom.SetMode(editMode, true); } } else if (mouseJoint != null && mouseAtom != null && (mouseAtom.eye == EyeState.Disappear || input.CurrentMouseState[0].LeftButton == ButtonState.Released)) { if (mouseAtom.eye != EyeState.Disappear) // Disappear has priority over LeftButton Released { world.DestroyJoint(mouseJoint); mouseAtom.SetMode(editMode, false); mouseAtom.CreateBond(); } mouseJoint = null; mouseAtom = null; } if (input.IsRightClicked()) { if (mouseOverAtom != null) { if (mouseOverAtom.bondedAtoms.Count > 0) { Cue cue = gameContent.soundBank.GetCue("detach"); cue.Play(); mouseOverAtom.DestroyBonds(); } else if (isLAB && !editMode && mouseOverAtom.bondedAtoms.Count == 0) { mouseOverAtom.Remove(); atoms.Remove(mouseOverAtom); } } } }
public void HandleInput(InputState input, int playerIndex) { Vector2 mousePosition = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y) / BitSitsGames.PhoneScale; Point mouseP = new Point((int)mousePosition.X, (int)mousePosition.Y); mouseOverArmy = null; for (int i = 0; i < armies.Count; i++) { if (armies[i].MouseBounds.Contains(mouseP) && armies[i].IsAlive && selectedArmy == null && armies[i].Shape == Shape.square) { mouseOverArmy = armies[i]; break; } } if (input.CurrentMouseState.LeftButton == ButtonState.Pressed) { if (input.IsLeftClicked() && mouseOverArmy != null) { selectedArmy = mouseOverArmy; mouseOverArmy = null; selectedArmy.Reset(); } if(selectedArmy!= null) selectedArmy.AddPosition(mousePosition); } if ((selectedArmy != null && input.LastMouseState.LeftButton == ButtonState.Pressed && input.CurrentMouseState.LeftButton == ButtonState.Released) || (selectedArmy != null && !selectedArmy.IsAlive)) selectedArmy = null; }
/// <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.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } isMouseOver = false; Vector2 mousePos = new Vector2(input.CurrentMouseState[0].X, input.CurrentMouseState[0].Y); if (camera != null) { camera.HandleInput(input, ControllingPlayer); mousePos = ((camera.Position - ScreenManager.GameContent.viewportSize / 2 / camera.Scale) + mousePos / camera.Scale); } for (int i = 0; i < menuEntries.Count; i++) { Point m = new Point((int)mousePos.X, (int)mousePos.Y); if (menuEntries[i].BoundingRectangle.Contains(m)) { isMouseOver = true; selectedEntry = i; } } // 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 InputState 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; //if (input.IsMenuSelect(ControllingPlayer, out playerIndex) if(isMouseOver && input.IsLeftClicked()) { OnSelectEntry(selectedEntry, PlayerIndex.One); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }