void Update() { if (isCollisionBall) { if (_playerMovement.isMoveRight) { if (typeBall != BALL_ROLL_TYPE.RIGHT) { typeBall = BALL_ROLL_TYPE.RIGHT; countRunTime = 0f; } countRunTime += Time.deltaTime; if (countRunTime < RUN_TIME_TO_PUSH_BOX) { return; } if (_playerMovement.playerRigidbody2D.velocity.x < 10f && Mathf.Abs(_playerMovement.playerRigidbody2D.velocity.y) < 0.2f) { if (transform.position.y < _playerMovement.transform.position.y) { boxRigidBody2D.velocity = new Vector2(-2.5f, 0f); } } } else if (_playerMovement.isMoveLeft) { if (typeBall != BALL_ROLL_TYPE.LEFT) { typeBall = BALL_ROLL_TYPE.LEFT; countRunTime = 0f; } countRunTime += Time.deltaTime; if (countRunTime < RUN_TIME_TO_PUSH_BOX) { return; } if (_playerMovement.playerRigidbody2D.velocity.x > -10f && Mathf.Abs(_playerMovement.playerRigidbody2D.velocity.y) < 0.2f) { if (transform.position.y < _playerMovement.transform.position.y) { boxRigidBody2D.velocity = new Vector2(2.5f, 0f); } } } } //UpdateBallType(); }
public void UpdateBallType() { if (lastTypeBall != typeBall) { lastTypeBall = typeBall; if (typeBall == BALL_ROLL_TYPE.LEFT) { playerAnimation.SetAutoRotate(false); } else if (typeBall == BALL_ROLL_TYPE.RIGHT) { playerAnimation.SetAutoRotate(true); } else { playerAnimation.StopAutoRotate(); } } }