void ChangeDirection(UnoGamePlayData.TurnDirection _turnDirection) { if (_turnDirection == UnoGamePlayData.TurnDirection.ClockWise) { if (tweenRotateAround != null) { LeanTween.cancel(tweenRotateAround.uniqueId); } if (mySprite.transform.localScale.x < 0) { Vector3 _localScale = mySprite.transform.localScale; _localScale.x *= -1; mySprite.transform.localScale = _localScale; } tweenRotateAround = LeanTween.rotateAround(gameObject, Vector3.forward, -360f, rotTime).setLoopCount(-1); } else { if (tweenRotateAround != null) { LeanTween.cancel(tweenRotateAround.uniqueId); } if (mySprite.transform.localScale.x > 0) { Vector3 _localScale = mySprite.transform.localScale; _localScale.x *= -1; mySprite.transform.localScale = _localScale; } tweenRotateAround = LeanTween.rotateAround(gameObject, Vector3.forward, 360f, rotTime).setLoopCount(-1); } }
public Coroutine SetTurnDirection(UnoGamePlayData.TurnDirection _turnDirection, bool _updateNow = true) { if (_updateNow) { ChangeDirection(_turnDirection); } else { return(StartCoroutine(DoActionSetTurnDirection(_turnDirection))); } return(null); }
public IEnumerator DoActionSetTurnDirection(UnoGamePlayData.TurnDirection _turnDirection, bool _updateNow = true) { if (_updateNow) { ChangeDirection(_turnDirection); yield break; } bool _isFinished = false; LeanTween.scale(gameObject, Vector3.zero, tweenTime).setOnComplete(() => { ChangeDirection(_turnDirection); _isFinished = true; }); yield return(new WaitUntil(() => _isFinished)); _isFinished = false; LeanTween.scale(gameObject, Vector3.one, tweenTime).setOnComplete(() => { _isFinished = true; }); yield return(new WaitUntil(() => _isFinished)); }