public override void Update(GameTime gameTime) { mouseInputState = CONTENT_MANAGER.inputState.mouseState; lastMouseInputState = CONTENT_MANAGER.lastInputState.mouseState; keyboardInputState = CONTENT_MANAGER.inputState.keyboardState; lastKeyboardInputState = CONTENT_MANAGER.lastInputState.keyboardState; selectedMapCell = Utility.HelperFunction.TranslateMousePosToMapCellPos(mouseInputState.Position, camera, map.Width, map.Height); if (HelperFunction.IsKeyPress(Keys.OemTilde)) { console.IsVisible = !console.IsVisible; } #region change unit and animation if (console.IsVisible) //suck all input in to the input box { console.Update(CONTENT_MANAGER.inputState, CONTENT_MANAGER.lastInputState); } else //accept input { //cylce through unit if (HelperFunction.IsKeyPress(Keys.Left)) { if (currentUnit == UnitType.Soldier) { currentUnit = UnitType.Battleship; } else { currentUnit = currentUnit.Previous(); } } if (HelperFunction.IsKeyPress(Keys.Right)) { if (currentUnit == UnitType.Battleship) { currentUnit = UnitType.Soldier; } else { currentUnit = currentUnit.Next(); } } //cycle through animation if (HelperFunction.IsKeyPress(Keys.Up)) { if (currentAnimation == AnimationName.idle) { currentAnimation = AnimationName.done; } else { currentAnimation = currentAnimation.Previous(); } } if (HelperFunction.IsKeyPress(Keys.Down)) { if (currentAnimation == AnimationName.done) { currentAnimation = AnimationName.idle; } else { currentAnimation = currentAnimation.Next(); } } //cycle through color if (HelperFunction.IsKeyPress(Keys.E)) { if (currentColor == GameData.Owner.Yellow) { currentColor = GameData.Owner.Red; } else { currentColor = currentColor.Next(); } } if (HelperFunction.IsKeyPress(Keys.Q)) { if (currentColor == GameData.Owner.Red) { currentColor = GameData.Owner.Yellow; } else { currentColor = currentColor.Previous(); } } } Unit unit = map[position].unit; UnitType nextUnit = unit.UnitType; GameData.Owner nextOwner = unit.Owner; AnimationName nextAnimation = unit.Animation.CurntAnimationName.ToEnum <AnimationName>(); bool isChanged = false; if (nextUnit != currentUnit) { isChanged = true; } if (nextOwner != currentColor) { isChanged = true; } if (nextAnimation != currentAnimation) { isChanged = true; } if (isChanged) { map[position].unit = UnitCreationHelper.Create(currentUnit, currentColor, startingAnimation: currentAnimation); } map[position].unit.Animation.Update(gameTime); #endregion if (mouseInputState.LeftButton == ButtonState.Released && lastMouseInputState.LeftButton == ButtonState.Pressed) { SelectUnit(); } //if (isMovingUnitAnimPlaying) //{ // UpdateMovingUnit(gameTime); //} //calculate movepath if (isMovePathCalculated) { if (movementRange.Contains(selectedMapCell) && selectedMapCell != lastSelectedMapCell) { //update movement path movementPath = DijkstraHelper.FindPath(dijkstarGraph, selectedMapCell); dirarrowRenderer.UpdatePath(movementPath); lastSelectedMapCell = selectedMapCell; } } base.Update(gameTime); }