/// <summary> /// 展示自身的牌 /// </summary> public void ShowCards(bool isShow) { if (isShow) { if (_handCard == null) { return; } net_protocol.DdzJSPlayerInfo result = LandlordsModel.Instance.ResultModel.GetResultInfos().Find(p => p.userId.ToString() == _handCard.playerInfo.uid); if (result == null) { return; } for (int i = 0; i < result.poker.Count; i++) { Card card = new Card(result.poker[i], _handCard.playerInfo.uid); CardUI ui = LandlordsPage.MakeSprite(card, false, resultCardsShow); ui.SetCardSize(new Vector2(145, 190)); ui.Card.IsSprite = false; ui.name = (i + 1).ToString(); } } else { for (int i = 0; i < resultCardsShow.childCount; i++) { resultCardsShow.GetChild(i).GetComponent <CardUI>().Destroy(); } } }
//创建牌 void CreateCards(Transform parentTrans, List <Card> cards, bool isSort) { List <Card> temp = cards; if (isSort) { temp.Sort((a, b) => { int a_count = cards.FindAll(p => p.GetCardWeight == a.GetCardWeight).Count; int b_count = cards.FindAll(p => p.GetCardWeight == b.GetCardWeight).Count; if (a_count > b_count) { return(-1); } else if (a_count < b_count) { return(1); } else { return(0); } }); } for (int i = 0; i < temp.Count; i++) { CardUI a = LandlordsPage.MakeSprite(temp[i], false, parentTrans); a.SetCardSize(new Vector2(145, 190)); } ani.Play(); }
// 快速发牌 void QuickDealCard() { for (int i = 0; i < _handCard.CardsCount; i++) { CardUI ui = LandlordsPage.MakeSprite(_handCard[i], false, handCard); if (ui) { ui.SetCardSize(new Vector2(239, 325)); } } StartCoroutine(SpriteSort()); }
/// <summary> /// 显示层发底牌 /// </summary> public void DealDipai(List <Card> cards) { for (int i = 0; i < dipaiDesk.childCount; i++) { dipaiDesk.GetChild(i).GetComponent <CardUI>().Destroy(); } for (int i = 0; i < cards.Count; i++) { CardUI cardUI = LandlordsPage.MakeSprite(cards[i], false, dipaiDesk); cardUI.SetCardSize(new Vector2(56, 76)); } }
// 协程发牌 IEnumerator DelayDealCard() { AudioManager.Instance.PlayTempSound(AudioManager.AudioSoundType.dealCard, PageManager.Instance.CurrentPage.name); for (int i = 0; i < _handCard.CardsCount; i++) { CardUI ui = LandlordsPage.MakeSprite(_handCard[i], false, handCard); if (ui) { ui.SetCardSize(new Vector2(239, 325)); } yield return(new WaitForSecondsRealtime(0.1f)); } StartCoroutine(SpriteSort()); }