void Update() { if (Time.timeScale == 0) { return; } if (GameManager.Instance.gameOver) { if (!isGameOver && !GameManager.Instance.winner) { _skeletonAnimation.AnimationState.AddEmptyAnimation(1, 0, 0); _skeletonAnimation.AnimationState.AddEmptyAnimation(2, 0, 0); _skeletonAnimation.AnimationState.SetAnimation(0, morrer, false); isGameOver = true; } return; } if (!GameManager.Instance.isBossAlive) { StopAllCoroutines(); transform.position = new Vector2(Mathf.Lerp(transform.position.x, -6.7f, 3 * Time.deltaTime), Mathf.Lerp(transform.position.y, -1.37f, 3 * Time.deltaTime)); _skeletonAnimation.AnimationState.AddEmptyAnimation(1, 0, 0); _skeletonAnimation.AnimationState.AddEmptyAnimation(2, 0, 0); _skeletonAnimation.AnimationState.SetAnimation(0, idle, true); return; } //Ler um comando e adicionar e avisar o personagem que deve se mover xMovement = Input.GetAxisRaw("Horizontal"); yMovement = Input.GetAxisRaw("Vertical"); //Checa e faz o movimento if (xMovement != 0 || yMovement != 0) { //Animation routines if (!isMoving && canDoAnimationAgain && !PlayerManager.Instance.attacking) { isMoving = true; StartCoroutine(MovementAnimation()); } else if (PlayerManager.Instance.attacking) { isMoving = false; _skeletonAnimation.AnimationState.AddEmptyAnimation(1, 0f, 0.5f); StopAllCoroutines(); } //Movements routines lastDirectionX = xMovement; lastDirectionY = yMovement; //Faz o motor mover o personagem motor.Movement(xMovement, yMovement); //Se o shift for pressionado, altera a velocidade do som e acelera o personagem if (isPressingShift) { if (xMovement > 0) { GameManager.Instance.UpdateSpeed(); } audioPitch = 1.4f; motor.Accelerate(); } else { GameManager.Instance.SpeedToInit(); audioPitch = 1; } } else { //Para o movimento e desliga _skeletonAnimation.AnimationState.AddEmptyAnimation(1, .5f, 1f); StopAllCoroutines(); canDoAnimationAgain = true; isMoving = false; motor.StopMovement(lastDirectionX, lastDirectionY); //idle animation } //Checa se esta sendo movimento com boost if (Input.GetKey(KeyCode.LeftShift)) { if (!isPressingShift) { isPressingShift = true; } } if (Input.GetKeyUp(KeyCode.LeftShift)) { motor.StopAcceleration(); isPressingShift = false; } //Limita a posição do personagem na tela clampPosition.Set(Mathf.Clamp(transform.position.x, topLeft.position.x, topRight.position.x), Mathf.Clamp(transform.position.y, bottomLeft.position.y, topLeft.position.y)); transform.position = clampPosition; }