protected override void HandleInputActive(Bind bind) { base.HandleInputActive(bind); if (bind.Name.CompareTo("MoveForward") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.MoveForward = true; } else { _Player.MoveForward = false; } } else if (bind.Name.CompareTo("MoveBack") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.MoveBack = true; } else { _Player.MoveBack = false; } } else if (bind.Name.CompareTo("StrafeLeft") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.MoveLeft = true; } else { _Player.MoveLeft = false; } } else if (bind.Name.CompareTo("StrafeRight") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.MoveRight = true; } else { _Player.MoveRight = false; } } else if (bind.Name.CompareTo("MoveMode") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Manager.Input.AbsoluteMovement = !_Manager.Input.AbsoluteMovement; } } else if (bind.Name.CompareTo("FlashLight") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.FlashLight.Active = !_Player.FlashLight.Active; } } else if (bind.Name.CompareTo("PrimaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { isFiring = true; } else { isFiring = false; } } else if (bind.Name.CompareTo("SecondaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (_Player.Disposed) { _Player = new Marine(this); _Player.Geometry.Position.X = TileCols * Tile.TileWidth / 2; _Player.Geometry.Position.Y = TileRows * Tile.TileHeight / 2; } } } else if (bind.Name.CompareTo("Reload") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.Reload(); } } else if (bind.Name.CompareTo("NightVision") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Player.NightVision.Active = !_Player.NightVision.Active; } } else if (bind.Name.CompareTo("FPS") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (_FPSDisplay) { _FPSDisplay = false; _Message = _HelpMessage; } else { _FPSDisplay = true; } } } else if (bind.Name.CompareTo("Editor") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { Screen gui; _Manager.LookupScreen("GUI", out gui); gui.Remove(); Remove(); _Manager.AddScreen(new EditorScreen(_Manager)); _Manager.AddScreen(new GUIEditor(_Manager)); } } else if (bind.Name.CompareTo("Weapon1") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (Player.weaponList.Count > 0) { Player.currentWeapon = Player.weaponList[0]; } } } else if (bind.Name.CompareTo("Weapon2") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (Player.weaponList.Count > 1) { Player.currentWeapon = Player.weaponList[1]; } } } else if (bind.Name.CompareTo("Weapon3") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (Player.weaponList.Count > 2) { Player.currentWeapon = Player.weaponList[2]; } } } else if (bind.Name.CompareTo("Weapon4") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (Player.weaponList.Count > 3) { Player.currentWeapon = Player.weaponList[3]; } } } else if (bind.Name.CompareTo("Weapon5") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (Player.weaponList.Count > 4) { Player.currentWeapon = Player.weaponList[4]; } } } }
private bool ForEachUpdate(Bind bind, object keystate, object p2, object p3) { if (bind.MouseBind) { MouseState state = Mouse.GetState(); if (bind.MouseButton == MouseButtons.LeftButton) { if (state.LeftButton == ButtonState.Pressed && bind.State == KeyState.Up) { bind.State = KeyState.Down; OnStateChanged(bind); } else if (state.LeftButton == ButtonState.Released && bind.State == KeyState.Down) { bind.State = KeyState.Up; OnStateChanged(bind); } } else if (bind.MouseButton == MouseButtons.RightButton) { if (state.RightButton == ButtonState.Pressed && bind.State == KeyState.Up) { bind.State = KeyState.Down; OnStateChanged(bind); } else if (state.RightButton == ButtonState.Released && bind.State == KeyState.Down) { bind.State = KeyState.Up; OnStateChanged(bind); } } else if (bind.MouseButton == MouseButtons.MiddleButton) { if (state.MiddleButton == ButtonState.Pressed && bind.State == KeyState.Up) { bind.State = KeyState.Down; OnStateChanged(bind); } else if (state.MiddleButton == ButtonState.Released && bind.State == KeyState.Down) { bind.State = KeyState.Up; OnStateChanged(bind); } } } else { KeyboardState state = (KeyboardState)keystate; if (state.IsKeyDown(bind.Key) && bind.State == KeyState.Up) { bind.State = KeyState.Down; OnStateChanged(bind); } else if (state.IsKeyUp(bind.Key) && bind.State == KeyState.Down) { bind.State = KeyState.Up; OnStateChanged(bind); } } return(true); }
/// <summary> /// Adds a binding to the list to be monitored. /// </summary> /// <param name="bind">The new key binding to monitor.</param> public virtual void AddBind(Bind bind) { _Binds.Add(bind.Name, bind); }
/// <summary> /// Attempts to find the binding for the given binding name. /// </summary> /// <param name="name">The name of the binding to lookup.</param> /// <param name="bind">The binding where the result will be stored if it finds the bind.</param> /// <returns>True if the binding was found and false otherwise.</returns> public virtual bool LookupBind(String name, out Bind bind) { return(_Binds.TryGetValue(name, out bind)); }
protected override void HandleInputActive(Bind bind) { //base.HandleInputActive(bind); if (bind.Name.CompareTo("PrimaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _SecondaryDragging = false; _Dragging = true; } else { _Dragging = false; } } else if (bind.Name.CompareTo("SecondaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Dragging = false; _SecondaryDragging = true; } else { _SecondaryDragging = false; } } else if (bind.Name.CompareTo("StrafeLeft") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.TargetLocation.X -= ScreenMoveRate; } } else if (bind.Name.CompareTo("StrafeRight") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.TargetLocation.X += ScreenMoveRate; } } else if (bind.Name.CompareTo("MoveForward") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.TargetLocation.Y -= ScreenMoveRate; } } else if (bind.Name.CompareTo("MoveBack") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.TargetLocation.Y += ScreenMoveRate; } } else if (bind.Name.CompareTo("Save") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Message = "Saved map to world.awo"; worker.DoWork += SaveMap; worker.RunWorkerAsync(); } } else if (bind.Name.CompareTo("back") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { Screen gui; _Manager.LookupScreen("GUIEditor", out gui); gui.Remove(); this.Remove(); _Manager.AddScreen(new WorldScreen(_Manager, "world.awo")); _Manager.AddScreen(new GUIScreen(_Manager)); } } else if (bind.Name.CompareTo("Reload") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.TargetLocation = new Vector2(TileCols * Tile.TileWidth / 2, TileRows * Tile.TileHeight / 2); _ViewPort.Size = new Vector2(800, 500); } } else if (bind.Name.CompareTo("ZoomIn") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.Size -= new Vector2(_Manager.Resolution.X / 20, _Manager.Resolution.Y / 20); } } else if (bind.Name.CompareTo("ZoomOut") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _ViewPort.Size += new Vector2(_Manager.Resolution.X / 20, _Manager.Resolution.Y / 20); } } }
public override void HandleInput(Bind bind) { //base.HandleInput(bind); Vector2 mWorldLoc = new Vector2(mState.X / _Manager.Resolution.X * _ViewPort.Size.X + _ViewPort.ActualLocation.X, mState.Y / _Manager.Resolution.Y * _ViewPort.Size.Y + _ViewPort.ActualLocation.Y); Vector2 diff = Vector2.Zero; if (bind.Name.CompareTo("PrimaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { diff = mWorldLoc - _Editor_GuiA.Geometry.Position; if (diff.Length() < _Editor_GuiA.Geometry.CollisionRadius) { _Editor_TextureBox.Hide = false; for (int i = 0; i < 16; i++) { _TextureBoxEntities[i].Hide = false; } } else { diff = mWorldLoc - _Editor_GuiB.Geometry.Position; if (diff.Length() < _Editor_GuiB.Geometry.CollisionRadius) { _Editor_TextureBox.Hide = false; for (int i = 0; i < 16; i++) { _TextureBoxEntities[i].Hide = false; } } } if (_Editor_TextureBox.Hide == false) { for (int i = 0; i < 16; i++) { diff = mWorldLoc - _TextureBoxEntities[i].Geometry.Position; if (diff.Length() < _TextureBoxEntities[i].Geometry.CollisionRadius) { Screen screen; EditorScreen world; _Manager.LookupScreen("Editor", out screen); world = (EditorScreen)screen; world._TileIndex = i % Tile.TileGen.Length; _TemporaryTile = Tile.TileGen[world._TileIndex](this, 1, 1, world._TileIndex); _PreviewEntityA.Dispose(); _PreviewEntityA = new Entity(this); _PreviewEntityA.Animations.AddAnimation(_TemporaryTile.Animations.Current); _PreviewEntityA.Geometry = new Geometry(_PreviewEntityA, new Vector2(554, 397), 30, 30, 0); _PreviewEntityA.Depth = 0.17f; _TemporaryTile.Dispose(); } } } } } if (bind.Name.CompareTo("SecondaryFire") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { if (_Editor_TextureBox.Hide == false) { for (int i = 0; i < 16; i++) { diff = mWorldLoc - _TextureBoxEntities[i].Geometry.Position; if (diff.Length() < _TextureBoxEntities[i].Geometry.CollisionRadius) { Screen screen; EditorScreen world; _Manager.LookupScreen("Editor", out screen); world = (EditorScreen)screen; world._SecondaryIndex = i % Tile.TileGen.Length; _TemporaryTile = Tile.TileGen[world._SecondaryIndex](this, 1, 1, world._SecondaryIndex); _PreviewEntityB.Dispose(); _PreviewEntityB = new Entity(this); _PreviewEntityB.Animations.AddAnimation(_TemporaryTile.Animations.Current); _PreviewEntityB.Geometry = new Geometry(_PreviewEntityB, new Vector2(574, 417), 30, 30, 0); _PreviewEntityB.Depth = 0.18f; _TemporaryTile.Dispose(); } } } } } if (bind.Name.CompareTo("FlashLight") == 0) { if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down) { _Editor_TextureBox.Hide = true; for (int i = 0; i < _TextureBoxEntities.GetLength(0); i++) { _TextureBoxEntities[i].Hide = true; } } } }