void UpdateInputDebug() { // Prevent user's input if (UseUserInput == false) { return; } // If game is over if (gameManager.IsGameOver) { // Do nothing } else { // UserAction action = GetUserActionByMouse(); UserAction action = GetUserActionByTouch(); if (Input.GetKeyDown(KeyCode.Escape)) { gameManager.PauseResumeGame(); } // If game is paused if (gameManager.IsGamePaused) { // Do nothing } // If game continue else if (gameManager.IsLevelComplete == false) { // If jump to stage in Level 4 if (isJumpToStage) { MoveToStage(); return; } // If holding rope in Level 5 if (isHoldingRope) { transform.position = ropeCs.GetLooseEndPosition() - animationHoldingRopeOffset; if (Input.GetKey(KeyCode.Space) || action == UserAction.Tap || action == UserAction.SwipeLeft || action == UserAction.SwipeRight) { isHoldingRope = false; isJumping = true; transform.rotation = Quaternion.Euler(0, 90, 0); transform.position += (Vector3.forward * animationHoldingRopeOffset.z); jumpingDirection = JumpingDirection.Up; if (action == UserAction.SwipeRight) { jumpingDirection = JumpingDirection.Forward; } else if (action == UserAction.SwipeLeft) { jumpingDirection = JumpingDirection.Backward; } rbPlayer.isKinematic = false; rbPlayer.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); sfxController.PlayJumpSfx(); } if (Input.GetKey(KeyCode.RightArrow) || action == UserAction.TouchRight) { jumpingDirection = JumpingDirection.Forward; } else if (Input.GetKey(KeyCode.LeftArrow) || action == UserAction.TouchLeft) { if (isJumping) { transform.rotation = Quaternion.Euler(0, -90, 0); } jumpingDirection = JumpingDirection.Backward; } } // If jumping else if (isJumping) { if (horse != null) { if (Input.GetKey(KeyCode.LeftArrow) || action == UserAction.TouchLeft) { KeepLowBounce = true; } else { KeepLowBounce = false; } transform.position = new Vector3(horse.transform.position.x, transform.position.y, transform.position.z); } else { if (jumpingDirection == JumpingDirection.Forward) { MoveForward(); } else if (jumpingDirection == JumpingDirection.Backward) { MoveBackward(); } } } // If walk/run normally else { if (Input.GetKeyDown(KeyCode.Space) || action == UserAction.Tap || action == UserAction.SwipeLeft || action == UserAction.SwipeRight) { isJumping = true; jumpingDirection = JumpingDirection.Up; if (action == UserAction.SwipeRight) { jumpingDirection = JumpingDirection.Forward; } else if (action == UserAction.SwipeLeft) { jumpingDirection = JumpingDirection.Backward; } playerAnim.SetBool("Jumping_b", true); UpdateCollider(); rbPlayer.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); sfxController.PlayJumpSfx(); } if (Input.GetKey(KeyCode.RightArrow) || action == UserAction.TouchRight) { if (horse != null) { // Do nothing } else { if (isJumping) { jumpingDirection = JumpingDirection.Forward; } else { playerAnim.SetBool("Running_b", true); playerAnim.SetInteger("Direction_i", 1); MoveForward(); } } } else if (Input.GetKey(KeyCode.LeftArrow) || action == UserAction.TouchLeft) { if (horse != null) { horseCs.ChangeSpeed(false); } else { if (isJumping) { jumpingDirection = JumpingDirection.Backward; } else { playerAnim.SetBool("Running_b", true); playerAnim.SetInteger("Direction_i", -1); MoveBackward(); } } } else { playerAnim.SetBool("Running_b", false); playerAnim.SetInteger("Direction_i", 0); if (horse != null) { horseCs.ChangeSpeed(true); } } } } } }