public void RefreshAllUINow() { if (unoGamePlayData.currentGameState == UnoGamePlayData.GameState.STATUS_PLAYING) { unoCircleTurn.Show(); StartCoroutine(unoCircleTurn.DoActionSetTurnDirection(unoGamePlayData.turnDirection)); StartCoroutine(unoBackground.DoActionSetColor(unoGamePlayData.currentColor)); } StartCoroutine(unoCircleTurn.DoActionSetColor(unoGamePlayData.currentColor)); RefreshAllPlayerGroupUINow(); RefreshUIButtonSitDown(); SetTableBet(unoGamePlayData.currentBet, true); if (unoGamePlayData.lastCardPut > 0) { CardUnoInfo _cardInfo = null; bool _isThisWildCard = false; if (unoGamePlayData.IsWildCardColor(unoGamePlayData.lastCardPut)) { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(CardUnoInfo.CardType._Special_WildColor); _isThisWildCard = true; } else if (unoGamePlayData.IsWildCardDraw(unoGamePlayData.lastCardPut)) { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(CardUnoInfo.CardType._Special_Draw4Cards); _isThisWildCard = true; } else { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(unoGamePlayData.lastCardPut); } if (_cardInfo == null) { #if TEST Debug.LogError(">>> Không tìm thấy cardInfo (0): " + unoGamePlayData.lastCardPut); #endif return; } PanelCardUnoDetailController _card = LeanPool.Spawn(cardPrefab, Vector3.zero, Quaternion.identity, panelContainGlobalCards).GetComponent <PanelCardUnoDetailController>(); _card.transform.position = panelGlobalCardsHolderCatched.position; Vector3 _rot = panelGlobalCardsHolderCatched.rotation.eulerAngles; _rot.z += Random.Range(-60f, 60f); _card.transform.rotation = Quaternion.Euler(_rot); _card.ResizeAgain(sizeCardDefault.x, sizeCardDefault.y); _card.ShowNow(_cardInfo, unoGamePlayData.lastCardPut); if (_isThisWildCard) { StartCoroutine(_card.DoActionChangeBgColor(unoGamePlayData.currentColor)); } cardsGlobalPoolManager.AddObject(_card); } }
IEnumerator DoActionDealPlayerCard(Uno_PlayerGroup _playerGroup, sbyte _valueCards, float _timeDeal, System.Action _onFinished) { CardUnoInfo _cardInfo = null; if (_valueCards >= 0 && _playerGroup.isMe && unoGamePlayData.CheckIsPlaying(DataManager.instance.userData.sessionId)) { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(_valueCards); } CardHolderController _cardHolder = CreateCardHolder(_playerGroup); PanelCardUnoDetailController _card = LeanPool.Spawn(cardPrefab, Vector3.zero, Quaternion.identity, panelContainAllPlayerCards).GetComponent <PanelCardUnoDetailController>(); _card.transform.position = dealer.position; _card.transform.rotation = dealer.rotation; if (_cardInfo != null) { _card.ShowNow(_cardInfo, _valueCards); } _card.SetCardHolder(_cardHolder); _card.ResizeAgain(sizeCardDefault.x, sizeCardDefault.y); _playerGroup.ownCardPoolManager.AddObject(_card); yield return(Yielders.EndOfFrame); bool _canCompactCard = true; if (_playerGroup.isMe && unoGamePlayData.CheckIsPlaying(DataManager.instance.userData.sessionId)) { _canCompactCard = false; } if (_timeDeal <= 0) { for (int i = 0; i < _playerGroup.ownCardPoolManager.listObjects.Count; i++) { PanelCardUnoDetailController _panelCardDetail = (PanelCardUnoDetailController)_playerGroup.ownCardPoolManager.listObjects[i]; _panelCardDetail.transform.position = _panelCardDetail.cardHolder.transform.position; _panelCardDetail.transform.rotation = _panelCardDetail.cardHolder.transform.rotation; _panelCardDetail.transform.localScale = Vector2.one * _panelCardDetail.cardHolder.ratioScale; } if (_canCompactCard && _playerGroup.ownCardPoolManager.listObjects.Count > numCardsCompact) { for (int i = 0; i < _playerGroup.ownCardPoolManager.listObjects.Count; i++) { PanelCardUnoDetailController _panelCardDetail = (PanelCardUnoDetailController)_playerGroup.ownCardPoolManager.listObjects[i]; _panelCardDetail.transform.position = listPanelContainPlayerCardsCompactHolder[_playerGroup.viewIndex].position; if (i == 0) { _panelCardDetail.SetVisible(); } else { _panelCardDetail.SetInVisible(); } } listTxtPlayerNumberCards[_playerGroup.viewIndex].gameObject.SetActive(true); listTxtPlayerNumberCards[_playerGroup.viewIndex].text = _playerGroup.ownCardPoolManager.listObjects.Count.ToString(); } else { listTxtPlayerNumberCards[_playerGroup.viewIndex].gameObject.SetActive(false); } } else { if (Uno_GamePlay_Manager.instance.CanPlayMusicAndSfx()) { MyAudioManager.instance.PlaySfx(Uno_GamePlay_Manager.instance.myAudioInfo.sfx_DealCard); } if (_canCompactCard && _playerGroup.ownCardPoolManager.listObjects.Count > numCardsCompact) { for (int i = 0; i < _playerGroup.ownCardPoolManager.listObjects.Count - 1; i++) { PanelCardUnoDetailController _panelCardDetail = (PanelCardUnoDetailController)_playerGroup.ownCardPoolManager.listObjects[i]; StartCoroutine(_panelCardDetail.Move(listPanelContainPlayerCardsCompactHolder[_playerGroup.viewIndex].position, _timeDeal / 2f, LeanTweenType.easeOutSine)); } yield return(CoroutineChain.Start .Parallel(_card.Move(listPanelContainPlayerCardsCompactHolder[_playerGroup.viewIndex].position, _timeDeal, LeanTweenType.easeOutSine) , _card.Rotate(_cardHolder.transform.rotation.eulerAngles, _timeDeal) , _card.ScaleTo(Vector2.one * _cardHolder.ratioScale, _timeDeal, LeanTweenType.notUsed))); for (int i = 0; i < _playerGroup.ownCardPoolManager.listObjects.Count; i++) { PanelCardUnoDetailController _panelCardDetail = (PanelCardUnoDetailController)_playerGroup.ownCardPoolManager.listObjects[i]; if (i == 0) { _panelCardDetail.SetVisible(); } else { _panelCardDetail.SetInVisible(); } } listTxtPlayerNumberCards[_playerGroup.viewIndex].gameObject.SetActive(true); listTxtPlayerNumberCards[_playerGroup.viewIndex].text = _playerGroup.ownCardPoolManager.listObjects.Count.ToString(); } else { CoroutineChain.Start .Parallel(_card.MoveToCardHolder(_timeDeal, LeanTweenType.easeOutSine) , _card.Rotate(_cardHolder.transform.rotation.eulerAngles, _timeDeal) , _card.ScaleTo(Vector2.one * _cardHolder.ratioScale, _timeDeal, LeanTweenType.notUsed)); yield return(Yielders.Get(_timeDeal / 2f)); for (int i = 0; i < _playerGroup.ownCardPoolManager.listObjects.Count - 1; i++) { PanelCardUnoDetailController _panelCardDetail = (PanelCardUnoDetailController)_playerGroup.ownCardPoolManager.listObjects[i]; StartCoroutine(_panelCardDetail.MoveToCardHolder(_timeDeal / 2f, LeanTweenType.easeOutSine)); } yield return(Yielders.Get(_timeDeal / 2f)); } } if (_valueCards >= 0 && _playerGroup.isMe && unoGamePlayData.CheckIsPlaying(DataManager.instance.userData.sessionId)) { _card.onPointerDown = _playerGroup.OnFocusCard; } if (_onFinished != null) { _onFinished(); } }
IEnumerator DoActionInitData(UserDataInGame _userData, bool _isWin, long _goldBonus, int _point, List <sbyte> _cardValue) { data = _userData; if (cardPoolManager == null) { cardPoolManager = new MySimplePoolManager(); } if (_isWin) { imgStar.color = Color.white; panelShadow.gameObject.SetActive(false); txtGoldBonus.text = "+" + MyConstant.GetMoneyString(_goldBonus, 9999); txtGoldBonus.color = Color.yellow; txtName.color = Color.yellow; txtPoint.color = Color.yellow; } else { imgStar.color = Color.gray; panelShadow.gameObject.SetActive(true); txtGoldBonus.text = "-" + MyConstant.GetMoneyString(_goldBonus, 9999); txtGoldBonus.color = Color.red; txtName.color = Color.white; txtPoint.color = Color.white; } txtName.text = MyConstant.ConvertString(data.nameShowInGame, maxLengthOfUserName); txtPoint.text = "" + MyConstant.GetMoneyString(_point); imgAvatar.texture = CoreGameManager.instance.gameInfomation.otherInfo.avatarDefault; data.LoadAvatar(this, imgAvatar.rectTransform.rect.width, imgAvatar.rectTransform.rect.height, (_avatar) => { try{ if (_avatar != null) { imgAvatar.texture = _avatar; } }catch {} }); int _totalCards = _cardValue.Count; if (_totalCards > 20) { _totalCards = 20; } List <CardHolderController> _tmpListCardHolder = new List <CardHolderController>(); for (int i = 0; i < _totalCards; i++) { CardHolderController _cardHolder = LeanPool.Spawn(cardHolderPrefab, Vector3.zero, Quaternion.identity, panelCardHolderContainer).GetComponent <CardHolderController>(); _tmpListCardHolder.Add(_cardHolder); } yield return(Yielders.EndOfFrame); for (int i = 0; i < _totalCards; i++) { CardUnoInfo _cardInfo = null; if (Uno_GamePlay_Manager.instance.unoGamePlayData.IsWildCardColor(_cardValue[i])) { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(CardUnoInfo.CardType._Special_WildColor); } else if (Uno_GamePlay_Manager.instance.unoGamePlayData.IsWildCardDraw(_cardValue[i])) { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(CardUnoInfo.CardType._Special_Draw4Cards); } else { _cardInfo = Uno_GamePlay_Manager.instance.GetCardInfo(_cardValue[i]); } if (_cardInfo == null) { #if TEST Debug.LogError(">>> Không tìm thấy cardInfo (0): " + _cardValue[i]); #endif } PanelCardUnoDetailController _card = LeanPool.Spawn(cardPrefab, Vector3.zero, Quaternion.identity, panelCardContainer).GetComponent <PanelCardUnoDetailController>(); cardPoolManager.AddObject(_card); _card.transform.position = _tmpListCardHolder[i].transform.position; _card.transform.rotation = _tmpListCardHolder[i].transform.rotation; _card.ShowNow(_cardInfo, (int)_cardValue[i]); _card.ResizeAgain(Uno_GamePlay_Manager.instance.UIManager.sizeCardDefault.x, Uno_GamePlay_Manager.instance.UIManager.sizeCardDefault.y); _card.transform.localScale = Vector3.one * _tmpListCardHolder[i].ratioScale; } for (int i = 0; i < _tmpListCardHolder.Count; i++) { _tmpListCardHolder[i].SelfDestruction(); } _tmpListCardHolder.Clear(); }