protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); KeyboardState keyboard = OpenTK.Input.Keyboard.GetState(); MouseState mouse = OpenTK.Input.Mouse.GetState(); // Se utilizeaza mecanismul de control input oferit de OpenTK (include perifcerice multiple, inclusiv // pentru gaminig - gamepads, joysticks, etc.). if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); return; } else if (keyboard[OpenTK.Input.Key.P] && !keyboard.Equals(lastKeyPress)) { // Ascundere comandată, prin apăsarea unei taste - cu verificare de remanență! Timpul de reacție // uman << calculator. if (showCube) { showCube = false; } else { showCube = true; } } else if (keyboard[OpenTK.Input.Key.Z] && !keyboard.Equals(lastKeyPress)) { trans1 = true; } else if (keyboard[OpenTK.Input.Key.X] && !keyboard.Equals(lastKeyPress)) { trans2 = !trans2; } else if (keyboard[OpenTK.Input.Key.Y] && !keyboard.Equals(lastKeyPress)) { trans3 = !trans3; } lastKeyPress = keyboard; if (mouse[OpenTK.Input.MouseButton.Left]) { // Ascundere comandată, prin clic de mouse - fără testare remanență. if (showCube) { showCube = false; } else { showCube = true; } } }
private void SendFeedback(KeyboardState state) { if (state.Equals(_currentKeyboardFeedback)) { return; } _keyboardConnection.SetLedRgb(KeyboardState.Zone, state.Effect, KeyboardState.Speed, state.Color); _currentKeyboardFeedback = state; }
void Update() { if (keyboardState.Equals(KeyboardState.Process)) { if (Mathf.Round(authSettings.transform.localPosition.y) < regPosition.y) { float distCovered = (Time.time - startTime) * emergenceSpeed; float fracJourney = distCovered / journeyLength; authSettings.transform.localPosition = Vector3.Lerp(authSettings.transform.localPosition, Vector3.up * regPosition.y, fracJourney); } else { keyboard.Init(); keyboard.gameObject.SetActive(true); authSettings.transform.localPosition = regPosition; keyboardState = KeyboardState.Shown; } } }
public void Update() { if (KState.Equals(KState_prev)) { //check inputs & do actions DoCommonInput(); DoShieldToggles(); // DoWeaponInput(); // called from outisde this class KState_prev = KState; MState_prev = MState; } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState currState = Keyboard.GetState(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // Exit the game if the escape key is pressed. if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } if (!currState.Equals(prevState)) { if (Keyboard.GetState().IsKeyDown(Keys.F5)) { // Increment the formation counter. // Set a new formation for the gobling squad whenever F5 is pressed. } // ResetMap(); if (Keyboard.GetState().IsKeyDown(Keys.F6)) { m_bSetTilesToSolid = !m_bSetTilesToSolid; SetTilesToSolid(); } } if (!prevState.Equals(currState)) { /* * if (Keyboard.GetState().IsKeyDown(Keys.Left)) * m_TestLayer.ScrollLeft(); * if (Keyboard.GetState().IsKeyDown(Keys.Right)) * m_TestLayer.ScrollRight(); * if (currState.IsKeyDown(Keys.Up)) * m_TestLayer.ScrollUp(); * if (currState.IsKeyDown(Keys.Down)) * m_TestLayer.ScrollDown(); */ } prevState = currState; MouseState currMouse = Mouse.GetState(); if (!currMouse.Equals(prevMouse)) { m_mousePostion.X = currMouse.X; m_mousePostion.Y = currMouse.Y; if (currMouse.LeftButton == ButtonState.Pressed) { m_sMouseClick.Play(); bool bClicked = false; // Check if a tree was clicked. for (int i = 0; i < m_TreeList.Count; i++) { if (m_TreeList[i].IsTreeClicked(m_mousePostion)) { m_Goblin.MoveDistanceInFrontOfEntity(m_TreeList[i], 0); bClicked = true; break; } } for (int i = 0; i < m_LumberMills.Count; i++) { // Check if a lumber mill was clicked. if (m_LumberMills[i].IsClicked(m_mousePostion)) { m_Goblin.MoveDistanceInFrontOfEntity(m_LumberMills[i], 0); bClicked = true; break; } } // If neither a lumber mill or a tree was clicked and the // click occurred inside the clickable area then it must have // been a tile click. if (!bClicked && !IsClickOutsideClickArea(m_mousePostion)) { // Set the state of the gobling to moving if we click anywhere else // that is not a tree or a lumber mill. ((GoblinLumberjack)m_Goblin).GetStateMachine().ChangeState(GLumberjack_MOVE.GetInstance()); ((GoblinLumberjack)m_Goblin).SetTargetTree(null); int x; int y = currMouse.Y / (int)(64 * 0.25); if (y % 2 == 1) { x = (currMouse.X - 32) / 64; } else { x = (int)currMouse.X / 64; } Vector2 dest = new Vector2(); if (y % 2 == 1) { dest.X = x * 64 + 32; } else { dest.X = x * 64; } dest.Y = y * (int)(64 * 0.25) - (int)(64 * 0.50); if (dest.X >= 0 && dest.X < m_DrawWidth * 64 && dest.Y >= 0 && dest.Y < m_DrawHeight * (int)(64 * 0.25)) { //m_Goblin.MoveTo(dest); //m_goblinSquad.MoveTo(MapHandler.GetInstance().GetTileIndex(dest)); } } } } prevMouse = currMouse; // TODO: Add your update logic here float currentUpdate = (float)gameTime.TotalGameTime.TotalMilliseconds; if (nextUpdate <= currentUpdate) { //tileCounter = (tileCounter+1) % (mapTexture.Width / 64 * mapTexture.Height / 64); //m_TestTile.SetTileID(tileCounter); nextUpdate = currentUpdate + updateDelay; } //m_Goblin.Update(gameTime); for (int i = 0; i < m_GoblinList.Count; i++) { m_GoblinList[i].Update(gameTime); } for (int i = 0; i < m_LumberMills.Count; i++) { m_LumberMills[i].Update(gameTime); } // Update the golbing squad. m_TestLayer.Update(gameTime); base.Update(gameTime); }
public void ProcessInput(float amount, ref Vector3 target, ref Quaternion targetrot) { MouseState currentMouseState = Mouse.GetState(); Quaternion cameraRotation = Quaternion.Identity; if (currentMouseState.RightButton == ButtonState.Pressed && currentMouseState != originalMouseState) { Game.IsMouseVisible = false; float xDifference = currentMouseState.X - originalMouseState.X; float yDifference = currentMouseState.Y - originalMouseState.Y; leftrightRot -= rotationSpeed * xDifference * amount / 7f; updownRot -= rotationSpeed * yDifference * amount / 7f; Mouse.SetPosition(originalMouseState.X, originalMouseState.Y); } else { Game.IsMouseVisible = true; originalMouseState = Mouse.GetState(); } cameraRotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRot) * Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), updownRot); KeyboardState keyState = Keyboard.GetState(); if (!keyState.Equals(new KeyboardState())) { if (keyState.IsKeyDown(Keys.W)) { Vector3 addVector = Vector3.Transform(new Vector3(0, 0, -0.1f), targetrot); target += addVector * amount; targetrot = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRot); } if (keyState.IsKeyDown(Keys.S)) { Vector3 addVector = Vector3.Transform(new Vector3(0, 0, 0.1f), targetrot); target += addVector * amount; targetrot = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRot); } if (keyState.IsKeyDown(Keys.A)) { Vector3 addVector = Vector3.Transform(new Vector3(-0.1f, 0, 0), targetrot); target += addVector * amount; targetrot = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRot); } if (keyState.IsKeyDown(Keys.D)) { Vector3 addVector = Vector3.Transform(new Vector3(0.1f, 0, 0), targetrot); target += addVector * amount; targetrot = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRot); } if (keyState.IsKeyDown(Keys.Space)) { Vector3 addVector = Vector3.Transform(new Vector3(0, 0.1f, 0), targetrot); target += addVector * amount; } if (keyState.IsKeyDown(Keys.LeftControl)) { Vector3 addVector = Vector3.Transform(new Vector3(0, -0.1f, 0), targetrot); target += addVector * amount; } } TPS_UpdateViewMatrix(target, cameraRotation); }
public void ProcessInput(float amount) { MouseState currentMouseState = Mouse.GetState(); if (currentMouseState.RightButton == ButtonState.Pressed && currentMouseState != originalMouseState) { Game.IsMouseVisible = false; float xDifference = currentMouseState.X - originalMouseState.X; float yDifference = currentMouseState.Y - originalMouseState.Y; leftrightRot -= rotationSpeed * xDifference * amount; updownRot -= rotationSpeed * yDifference * amount; Mouse.SetPosition(originalMouseState.X, originalMouseState.Y); FPS_UpdateViewMatrix(); } else { Game.IsMouseVisible = true; originalMouseState = Mouse.GetState(); } Vector3 moveVector = new Vector3(0, 0, 0); KeyboardState keyState = Keyboard.GetState(); if (!keyState.Equals(new KeyboardState())) { if (keyState.IsKeyDown(Keys.W)) { moveVector += new Vector3(0, 0, -1); } if (keyState.IsKeyDown(Keys.S)) { moveVector += new Vector3(0, 0, 1); } if (keyState.IsKeyDown(Keys.D)) { moveVector += new Vector3(1, 0, 0); } if (keyState.IsKeyDown(Keys.A)) { moveVector += new Vector3(-1, 0, 0); } if (keyState.IsKeyDown(Keys.Space)) { moveVector += new Vector3(0, 1, 0); } if (keyState.IsKeyDown(Keys.LeftControl)) { moveVector += new Vector3(0, -1, 0); } if (keyState.IsKeyDown(Keys.LeftShift)) { moveSpeed = 20; } else if (keyState.IsKeyUp(Keys.LeftShift)) { moveSpeed = 2; } } AddToCameraPosition(moveVector * amount); FPS_UpdateViewMatrix(); /* * if (currentMouseState.LeftButton == ButtonState.Pressed) * { * shEye = cameraPosition; * shadowViewMatrix = viewMatrix; * }*/ }
void inputUpdate() { //if (meleeBlocked) //{ // meleeTimer++; // if (meleeTimer > 100) // { // meleeBlocked = false; // } //} KeyboardState newState = Keyboard.GetState(); MouseState mouseState = Mouse.GetState(); if (newState.Equals(new KeyboardState())) { //No keys are pressed. if (playerState != 9) { playerState = 0; } if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } if (hasJumped) { float i = 1; velocity.Y += 0.15f * i; position.Y += velocity.Y; } oldAnimatedSprite = myAnimatedSprite; } if (newState.IsKeyDown(Keys.Right) || newState.IsKeyDown(Keys.D)) { idleTimer = 0; direction = 1; if (newState.IsKeyDown(Keys.X)) { meleeTimer = 0; meleeBlocked = true; playerState = 3; position.X += 30; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } oldAnimatedSprite = myAnimatedSprite; } else if ((newState.IsKeyDown(Keys.C) || mouseState.RightButton == ButtonState.Pressed) && ammoLeft > 0) { playerState = 5; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } shootBullet(); if (position.X < 6415) //Extend Level { velocity.X = speed; position += velocity; } oldAnimatedSprite = myAnimatedSprite; } else { playerState = 1; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } if (position.X < 6800) //Extend Level { velocity.X = speed; position += velocity; } oldAnimatedSprite = myAnimatedSprite; } } else if (newState.IsKeyDown(Keys.Left) || newState.IsKeyDown(Keys.A)) { idleTimer = 0; direction = -1; if (newState.IsKeyDown(Keys.X) || mouseState.LeftButton == ButtonState.Pressed) { meleeTimer = 0; meleeBlocked = true; playerState = 3; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } position.X -= 30; oldAnimatedSprite = myAnimatedSprite; } else if (newState.IsKeyDown(Keys.C) && ammoLeft > 0) { playerState = 5; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } shootBullet(); if (position.X > -630) { velocity.X = -speed; position += velocity; } oldAnimatedSprite = myAnimatedSprite; } else { playerState = 1; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } if (position.X > -630) { velocity.X = -speed; position += velocity; } oldAnimatedSprite = myAnimatedSprite; } } else if (newState.IsKeyDown(Keys.Down) || newState.IsKeyDown(Keys.S)) { playerState = 7; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } oldAnimatedSprite = myAnimatedSprite; } else if (newState.IsKeyDown(Keys.E)) { playerState = 8; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } for (int i = 0; i < 100; i++) { if (myGame1.enemyRectangle[i].Intersects(myGame1.charRectangle)) { if (myGame1.AIPool[i].isFallen) { myGame1.AIPool[i].isCuffed = true; myGame1.AIPool[i].isFallen = false; myGame1.enemyRectangle[i].X = 20000; myGame1.enemyRectangle[i].Y = 20000; if (myGame1.AIPool[i].myAiOrientation == AI.aiOrientation.Bad) { myGame1.Score += 100; myGame1.numbersBad = true; } if (myGame1.AIPool[i].myAiOrientation == AI.aiOrientation.Good) { myGame1.Score -= 200; myGame1.numbersGood = true; } } } } oldAnimatedSprite = myAnimatedSprite; } else if (newState.IsKeyDown(Keys.Space)) { if (hitTimer > 60) { sndHit.Play(); //#sound hitTimer = 0; } playerState = 6; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } for (int i = 0; i < 100; i++) { if (myGame1.enemyRectangle[i].Intersects(myGame1.charRectangle)) { if (myGame1.AIPool[i].isFallen) { myGame1.AIPool[i].isDead = true; myGame1.AIPool[i].isFallen = false; myGame1.brutality = true; myGame1.enemyRectangle[i].X = 20000; myGame1.enemyRectangle[i].Y = 20000; } } } oldAnimatedSprite = myAnimatedSprite; } else { velocity.X = 0; if (newState.IsKeyDown(Keys.X)) { meleeTimer = 0; meleeBlocked = true; playerState = 2; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } if (direction == -1) { position.X -= 30; } else { position.X += 30; } idleTimer = 0; oldAnimatedSprite = myAnimatedSprite; } else if (newState.IsKeyDown(Keys.C) && ammoLeft > 0) { playerState = 4; if (previousState != playerState) { myAnimatedSprite.currentFrame = 0; myAnimatedSprite.animComplete = false; previousState = playerState; } shootBullet(); idleTimer = 0; oldAnimatedSprite = myAnimatedSprite; } } hitTimer++; /*if ((newState.IsKeyDown(Keys.Up) || newState.IsKeyDown(Keys.Space)) && hasJumped == false) * { * position.Y -= 10f; * velocity.Y = -5f; * hasJumped = true; * idleTimer = 0; * }*/ }
/// <summary> /// Checks if any keys have been pressed, or released, since the last update /// </summary> /// <returns>True if a key has been pressed/released, otherwise false</returns> public bool IsStateChanged() { return(!newState.Equals(oldState)); //false if no change, otherwise true }
/// <summary> /// Get input for commands /// </summary> private void UpdateInput() { KeyboardState newState = Keyboard.GetState(); MouseState newMouseState = Mouse.GetState(); //Checks if the same key has been held for a period of time. if (newState.Equals(oldState)) { if (!held) { oldtime = time; held = true; } else { if (!repeat && time.TotalMilliseconds - oldtime.TotalMilliseconds > 250) { repeat = true; } } } else { held = false; repeat = false; } // Is the SPACE key down? if (newState.IsKeyDown(Keys.Space)) { if (!oldState.IsKeyDown(Keys.Space)) { dungeon.Clear(); level = new Dungeon(npcDicationary); dungeon.Add(level); npcs = level.npcs; currentdngn_floor = 0; player = new Player(level.upStairs); fov = new FOV(level.grid, player.location); fov.GetVisibility(); Log.Write("New floor generated."); playerActed = false; } } if (newState.IsKeyDown(Keys.Left) || newState.IsKeyDown(Keys.NumPad4)) { if (!oldState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.NumPad4) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X - 1, (int)player.location.Y]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(-1, 0), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.NumPad7)) { if (!oldState.IsKeyDown(Keys.NumPad7) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X - 1, (int)player.location.Y - 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(-1, -1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.Up) || newState.IsKeyDown(Keys.NumPad8)) { if (!oldState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.NumPad8) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X, (int)player.location.Y - 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(0, -1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.NumPad9)) { if (!oldState.IsKeyDown(Keys.NumPad9) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X + 1, (int)player.location.Y - 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(1, -1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.Right) || newState.IsKeyDown(Keys.NumPad6)) { if (!oldState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.NumPad6) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X + 1, (int)player.location.Y]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(1, 0), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.NumPad3)) { if (!oldState.IsKeyDown(Keys.NumPad3) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X + 1, (int)player.location.Y + 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(1, 1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.Down) || newState.IsKeyDown(Keys.NumPad2)) { if (!oldState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.NumPad2) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X, (int)player.location.Y + 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(0, 1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.NumPad1)) { if (!oldState.IsKeyDown(Keys.NumPad1) || repeat) { if (doorWait != "none") { doorTile = level.grid[(int)player.location.X - 1, (int)player.location.Y + 1]; switch (doorWait) { case ("close"): playerActed = doorTile.CloseDoor(); break; case ("open"): playerActed = doorTile.OpenDoor(); break; } doorWait = "none"; } else { moveToList = player.Movement(new Vector2(-1, 1), level.grid, moveType, moveToList); moveType = "one"; } fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } if (newState.IsKeyDown(Keys.OemPeriod)) { if (!oldState.IsKeyDown(Keys.OemPeriod)) { if (player.MoveDown(level.grid)) { if (currentdngn_floor == dungeon.Count - 1) { level = new Dungeon(npcDicationary); dungeon.Add(level); npcs = level.npcs; currentdngn_floor++; } else { currentdngn_floor++; level = dungeon[currentdngn_floor]; } player.location = level.upStairs.tilePos; fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } } if (newState.IsKeyDown(Keys.OemComma)) { if (!oldState.IsKeyDown(Keys.OemComma)) { if (currentdngn_floor > 0) { if (player.MoveUp(level.grid)) { currentdngn_floor--; level = dungeon[currentdngn_floor]; npcs = level.npcs; player.location = level.downStairs.tilePos; fov = new FOV(level.grid, player.location); fov.GetVisibility(); } } } } if (newState.IsKeyDown(Keys.C)) { if (!oldState.IsKeyDown(Keys.C)) { doorWait = "close"; Log.Write("Close which door?"); } } if (newState.IsKeyDown(Keys.O)) { if (!oldState.IsKeyDown(Keys.O)) { doorWait = "open"; Log.Write("Open which door?"); } } if (newState.IsKeyDown(Keys.Divide)) { if (!oldState.IsKeyDown(Keys.Divide)) { moveType = "five"; } } if (newState.IsKeyDown(Keys.Multiply)) { if (!oldState.IsKeyDown(Keys.Multiply)) { moveType = "end"; } } if (newState.IsKeyDown(Keys.I)) { if (!oldState.IsKeyDown(Keys.I)) { menu = !menu; } } /*if (newState.IsKeyDown(Keys.X)) * { * if (!oldState.IsKeyDown(Keys.X)) * { * moveToList = Pathing.FindPath(new Vector2(12,12),level.grid); * } * }*/ if (newState.IsKeyDown(Keys.Escape)) { if (!oldState.IsKeyDown(Keys.Escape)) { Exit(); } } if (newState.IsKeyDown(Keys.Enter)) { if (!oldState.IsKeyDown(Keys.Enter)) { Log.Write("Test message!"); } } if (newState.IsKeyDown(Keys.F10)) { if (!oldState.IsKeyDown(Keys.F10)) { for (int x = 0; x < 50; x++) { for (int y = 0; y < 50; y++) { level.grid[x, y].visible = true; } } } } if (newMouseState.LeftButton == ButtonState.Pressed) { if (oldMouseState.LeftButton != ButtonState.Pressed && GraphicsDevice.Viewport.Bounds.Contains(new Point((int)newMouseState.X, (int)newMouseState.Y))) { Vector2 clickedTile = new Vector2(); Vector2 moveToTile = new Vector2(); clickedTile.X = newMouseState.X / 32; //Get on screen tile coords clickedTile.Y = newMouseState.Y / 32; if (clickedTile.X >= 0 && clickedTile.X < 25 && clickedTile.Y >= 0 && clickedTile.Y < 25) { moveToTile = viewport.GetTile(clickedTile); //Get whole dungeon tile coords if (level.grid[(int)moveToTile.X, (int)moveToTile.Y].seen || level.grid[(int)moveToTile.X, (int)moveToTile.Y].visible) { moveToList = Pathing.FindPath(moveToTile, player.location, level.grid); } } } } // Update saved state. oldState = newState; oldMouseState = newMouseState; }