public Coroutine ChangeView(Uno_PlayerGroup _myPlayerGroup) { if (isChangingView) { return(null); } if (_myPlayerGroup != null) { if (_myPlayerGroup.viewIndex != 2) { actionChangeView = DoActionChangeView(_myPlayerGroup); return(StartCoroutine(actionChangeView)); } else { _myPlayerGroup.ShowButtonStandUp(false); return(null); } } else { if (Uno_GamePlay_Manager.instance.listPlayerGroup[0].realIndex != Uno_GamePlay_Manager.instance.listPlayerGroup[0].viewIndex) { actionChangeView = DoActionChangeView(null); return(StartCoroutine(actionChangeView)); } } return(null); }
IEnumerator DoActionChangeView(Uno_PlayerGroup _myPlayerGroup) // nếu _myViewIndex = -1 tức là mình đã đứng dậy { int _tmpDelta = 0; int _deltaAngleZ = 0; bool _isFinished = false; if (_myPlayerGroup == null) { _tmpDelta = Uno_GamePlay_Manager.instance.listPlayerGroup[0].viewIndex; for (int i = 0; i < Uno_GamePlay_Manager.instance.listPlayerGroup.Count; i++) { int _newIndexView = Uno_GamePlay_Manager.instance.listPlayerGroup[i].realIndex; Uno_GamePlay_Manager.instance.listPlayerGroup[i].viewIndex = _newIndexView; } } else { if (_myPlayerGroup.viewIndex < 2) { _tmpDelta = 2 - _myPlayerGroup.viewIndex; } else if (_myPlayerGroup.viewIndex > 2) { _tmpDelta = 2 + 4 - _myPlayerGroup.viewIndex; } for (int i = 0; i < Uno_GamePlay_Manager.instance.listPlayerGroup.Count; i++) { int _newIndexView = (Uno_GamePlay_Manager.instance.listPlayerGroup[i].viewIndex + _tmpDelta) % 4; Uno_GamePlay_Manager.instance.listPlayerGroup[i].viewIndex = _newIndexView; } } _deltaAngleZ = _tmpDelta * 90; yield return(null); for (int i = 0; i < Uno_GamePlay_Manager.instance.listPlayerGroup.Count; i++) { LeanTween.move(Uno_GamePlay_Manager.instance.listPlayerGroup[i].panelContainerPlayerInfo.gameObject, panelRotate.GetChild(i).position, timeStepChangeView).setEase(LeanTweenType.easeOutSine); } yield return(Yielders.Get(timeStepChangeView)); actionPanelPlayerInfoFollowTmpPanel = DoActionPanelPlayerInfoFollowTmpPanel(); StartCoroutine(actionPanelPlayerInfoFollowTmpPanel); _isFinished = false; // float _z = 0; if (_myPlayerGroup == null) { // _z = 0 - _deltaAngleZ; LeanTween.rotateAround(panelRotate.gameObject, Vector3.forward, _deltaAngleZ, timeStepChangeView).setOnComplete(() => { _isFinished = true; }).setEase(LeanTweenType.easeOutSine); } else { // _z = panelRotate.rotation.eulerAngles.z - _deltaAngleZ; LeanTween.rotateAround(panelRotate.gameObject, Vector3.forward, -_deltaAngleZ, timeStepChangeView).setOnComplete(() => { _isFinished = true; }).setEase(LeanTweenType.easeOutSine); } yield return(new WaitUntil(() => _isFinished)); StopCoroutine(actionPanelPlayerInfoFollowTmpPanel); actionPanelPlayerInfoFollowTmpPanel = null; for (int i = 0; i < Uno_GamePlay_Manager.instance.listPlayerGroup.Count; i++) { LeanTween.move(Uno_GamePlay_Manager.instance.listPlayerGroup[i].panelContainerPlayerInfo.gameObject, listPlaceHolderPanelPlayerInfo_Wating[Uno_GamePlay_Manager.instance.listPlayerGroup[i].viewIndex].transform.position, timeStepChangeView).setEase(LeanTweenType.easeOutSine); } yield return(Yielders.Get(timeStepChangeView)); if (_myPlayerGroup != null) { _myPlayerGroup.ShowButtonStandUp(false); } actionChangeView = null; }