/// <summary> /// Updates player and frame moving logic /// </summary> /// <param name="gameTime">Snapshot of times</param> public new void Update(GameTime gameTime) { MouseState mouse = Mouse.GetState(); KeyboardState keyboard = Keyboard.GetState(); KeyboardState lastKeyboard = CurrentArea.LastKeyboard; if (keyboard.IsKeyUp(Keys.Escape) && lastKeyboard.IsKeyDown(Keys.Escape)) //toggle main menu with escape key { CurrentArea.AreaMenu.isShowing = !CurrentArea.AreaMenu.isShowing; CurrentArea.Paused = CurrentArea.AreaMenu.isShowing; //inventoryMenu.isShowing = false; } if (lastKeyboard.IsKeyDown(Keys.E) && keyboard.IsKeyUp(Keys.E) && !CurrentArea.AreaMenu.isShowing) { //inventoryMenu.isShowing = !inventoryMenu.isShowing; CurrentArea.Paused = CurrentArea.AreaMenu.isShowing; // || inventoryMenu.isShowing; } RPG.MouseVisible = CurrentArea.AreaMenu.isShowing; // || inventoryMenu.isShowing; //enable mouse if menu is shown if (sprite.State != SpriteState.Die && !CurrentArea.Paused) { Vector2 moveDirection = Vector2.Zero; if (mouse.LeftButton == ButtonState.Pressed) { Attack(); } if (keyboard.IsKeyDown(Keys.F1) && !lastKeyboard.IsKeyDown(Keys.F1)) { RPG.DebugMode = !RPG.DebugMode; } //movement vectors if (keyboard.IsKeyDown(Keys.W)) { Turn(SpriteDirection.North); moveDirection.Y--; } if (keyboard.IsKeyDown(Keys.A)) { Turn(SpriteDirection.West); moveDirection.X--; } if (keyboard.IsKeyDown(Keys.S)) { Turn(SpriteDirection.South); moveDirection.Y++; } if (keyboard.IsKeyDown(Keys.D)) { Turn(SpriteDirection.East); moveDirection.X++; } //keep speed constant moveDirection.Normalize(); moveDirection *= 2; if (keyboard.IsKeyDown(Keys.LeftShift)) { moveDirection *= 3; //sprint or speed key } if (moveDirection.Length() > 0 && CurrentArea.CheckForCollisions(this, moveDirection)) { Move(moveDirection); } else if (moveDirection.Length() > 0 && keyboard.IsKeyDown(Keys.Space) && RPG.DebugMode) { Move(moveDirection); //debug override key } this.Position = new Vector2((int)Position.X, (int)Position.Y); } if (sprite.State == SpriteState.Die && sprite.CurrentFrame == sprite.MaxFrame && deathCooldown == 120) { RPG.LoadNewGame(); } else if (sprite.State == SpriteState.Die && sprite.CurrentFrame == sprite.MaxFrame && deathCooldown < 120) { deathCooldown++; } base.Update(gameTime); //inventoryMenu.Update (gameTime); }