/// <summary> /// 开始发牌 /// </summary> public IEnumerator DealCards() { //进入发牌阶段 cardManagerState = CardManagerStates.DealCards; termCurrentIndex = termStartIndex; yield return(DealHeapCards(false)); }
IEnumerator DealCards() { //进入发牌阶段 cardManagerState = CardManagerStates.DealCards; termCurrentPlayer = RoomManager.Instance.Self.Value; if (termCurrentPlayer == null) { Log.Error("开始发牌的玩家不存在"); } yield return(DealHeapCards()); }
/// <summary> /// 发牌堆上的牌(如果现在不是抢地主阶段,发普通牌,如果是,发地主牌) /// </summary> /// <returns></returns> private IEnumerator DealHeapCards() { //显示牌堆 heapPos.gameObject.SetActive(true); //计算每张地主牌的位置 int cardIndex = 0; int cardAllIndex = 0; foreach (var cardName in cardNamesNeeded) { //给当前玩家发一张牌 var nowCardNum = termCurrentPlayer.handCards.Count; termCurrentPlayer.GetCard(cardName, cardIndex); var tempPlayer = termCurrentPlayer; var cover = Instantiate(heapPos.gameObject); // cover.GetComponent<RectTransform>().localScale = Vector3.one; //移动动画,动画结束后自动销毁 var tween = cover.transform.DOMove(playerHeapPos[tempPlayer.uiPos.Value], 0.3f); tween.OnComplete(() => { tempPlayer.ShowLastCard(nowCardNum); Destroy(cover); }); yield return(new WaitForSeconds(1 / dealCardSpeed)); //下一个需要发牌者 // SetNextPlayer(); if (cardAllIndex % (cardNamesNeeded.Count / 3) == 0) { cardIndex++; } cardAllIndex++; } //隐藏牌堆 heapPos.gameObject.SetActive(false); // playerHeapPos[0].gameObject.SetActive(false); //发普通牌 //显示玩家手牌 // ShowPlayerSelfCards(); cardManagerState = CardManagerStates.Playing; }
/// <summary> /// 洗牌 /// </summary> public void ShuffleCards() { //进入洗牌阶段 cardManagerState = CardManagerStates.ShuffleCards; cardNames = cardNames.OrderBy(c => Guid.NewGuid()).ToArray(); }
public void OnGameEnd() { //进入发牌阶段 cardManagerState = CardManagerStates.Ready; StartCoroutine(BackHeapCards()); }
/// <summary> /// 开始出牌阶段 /// </summary> private void StartFollowing() { cardManagerState = CardManagerStates.Playing; //地主先出牌 Players[bankerIndex].ToFollowing(); }
/// <summary> /// 开始抢地主 /// </summary> private void StartBiding() { cardManagerState = CardManagerStates.Bid; Players[termCurrentIndex].ToBiding(); }