void UpdateAnimation() { string newDirection; HanleInput(out newDirection); // continue using the last direction when the character stops moving if (newDirection == DirectionType.None) { newDirection = _lastDirection; } bool sameAction = _lastDirection == newDirection && _lastInput == _newInput; _charAnimator.UpdateAnimationTime(1 / SpeedAnimation); if (!sameAction || Player.CharacterDNA.IsDirty()) { AnimationManager.UpdateDNAForAction(Player.CharacterDNA, Player.AnimationDNA, _newAction, newDirection); _charAnimator.AnimateAction(Player.AnimationDNA, _newAction); } else if (!Input.anyKey && !_isStillMoving) { _charAnimator.ResetAnimation(); } _lastDirection = _newAction.Direction = newDirection; _lastInput = _newInput; }
void UpdateAnimation() { string newDirection = DirectionType.NONE; if (Input.GetKeyDown(KeyCode.W) && _newInput != KeyCode.W) { newDirection = DirectionType.UP; _newAction = new WalkAction(); _newInput = KeyCode.W; } else if (Input.GetKeyDown(KeyCode.A) && _newInput != KeyCode.A) { newDirection = DirectionType.LEFT; _newAction = new WalkAction(); _newInput = KeyCode.A; } else if (Input.GetKeyDown(KeyCode.S) && _newInput != KeyCode.S) { newDirection = DirectionType.DOWN; _newAction = new WalkAction(); _newInput = KeyCode.S; } else if (Input.GetKeyDown(KeyCode.D) && _newInput != KeyCode.D) { newDirection = DirectionType.RIGHT; _newAction = new WalkAction(); _newInput = KeyCode.D; } else if (Input.GetKeyDown(KeyCode.Space)) { newDirection = _lastDirection; _newAction = new SlashAction(); _newInput = KeyCode.Space; } else if (Input.GetKeyDown(KeyCode.F)) { newDirection = _lastDirection; _newAction = new ThrustAction(); _newInput = KeyCode.F; } else if (Input.GetKeyDown(KeyCode.R)) { newDirection = _lastDirection; _newAction = new SpellcastAction(); _newInput = KeyCode.R; } else if (Input.GetKeyDown(KeyCode.E)) { newDirection = _lastDirection; _newAction = new ShootAction(); _newInput = KeyCode.E; } else { _newInput = KeyCode.None; } // continue using the last direction when the character stops moving if (newDirection == DirectionType.NONE) { newDirection = _lastDirection; } bool sameAction = _lastDirection == newDirection && _lastInput == _newInput; if (!sameAction || Player.characterDNA.IsDirty()) { _animationManager.UpdateDNAForAction(Player.characterDNA, Player.animationDNA, _newAction, newDirection); _charAnimator.AnimateAction(Player.animationDNA, _newAction); } else if (!Input.anyKey) { _charAnimator.StopOnFinalFrame(true); } _lastDirection = _newAction.Direction = newDirection; _lastInput = _newInput; }
private void UpdateAnimation() { var newDirection = DirectionType.None; if (Input.GetKeyDown(KeyCode.W) && _newInput != KeyCode.W) { newDirection = DirectionType.Up; _newAction = new WalkAction(); _newInput = KeyCode.W; } else if (Input.GetKeyDown(KeyCode.A) && _newInput != KeyCode.A) { newDirection = DirectionType.Left; _newAction = new WalkAction(); _newInput = KeyCode.A; } else if (Input.GetKeyDown(KeyCode.S) && _newInput != KeyCode.S) { newDirection = DirectionType.Down; _newAction = new WalkAction(); _newInput = KeyCode.S; } else if (Input.GetKeyDown(KeyCode.D) && _newInput != KeyCode.D) { newDirection = DirectionType.Right; _newAction = new WalkAction(); _newInput = KeyCode.D; } else if (Input.GetKeyDown(KeyCode.Space)) { _newAction = new SlashAction(); _newInput = KeyCode.Space; SpeedAnimation = 1.0f; } else if (Input.GetKeyDown(KeyCode.F)) { _newAction = new ThrustAction(); _newInput = KeyCode.F; SpeedAnimation = 1.0f; } else if (Input.GetKeyDown(KeyCode.R)) { _newAction = new SpellcastAction(); _newInput = KeyCode.R; SpeedAnimation = 1.0f; } else if (Input.GetKeyDown(KeyCode.E)) { _newAction = new ShootAction(); _newInput = KeyCode.E; SpeedAnimation = 1.0f; } else if (Input.GetKeyDown(KeyCode.X)) { _newAction = new DeathAction(); _newInput = KeyCode.X; SpeedAnimation = 1.0f; } else { _newInput = KeyCode.None; } // continue using the last direction when the character stops moving if (newDirection == DirectionType.None) { newDirection = _lastDirection; } var sameAction = _lastDirection == newDirection && _lastInput == _newInput; _charAnimator.UpdateAnimationTime(1 / SpeedAnimation); if (!sameAction || Player.CharacterDNA.IsDirty()) { AnimationManager.UpdateDNAForAction(Player.CharacterDNA, Player.AnimationDNA, _newAction, newDirection); _charAnimator.AnimateAction(Player.AnimationDNA, _newAction); } else if (!Input.anyKey && !_isStillMoving) { _charAnimator.ResetAnimation(); } _lastDirection = _newAction.Direction = newDirection; _lastInput = _newInput; }