/// <summary> /// 初始化房间 /// </summary> /// <param name="room"></param> public void InitRoom(RoomEntity room) { CurrentRoom = room; CalculateSeatIndex(); bool mustPlay = false; bool canPlay = true; Deck prevDeck = GetPreviourDeck(); if (prevDeck == null) { mustPlay = true; } else { List <Deck> Tip = DouDiZhuHelper.GetStrongerDeck(prevDeck, CurrentRoom.PlayerSeat.pokerList); if (Tip == null || Tip.Count == 0) { canPlay = false; } } TransferData data = new TransferData(); data.SetValue("Room", CurrentRoom); data.SetValue("MustPlay", mustPlay); data.SetValue("CanPlay", canPlay); SendNotification(ON_INIT, data); SendRoomInfoChangeNotify(); }
public void SetUI(RoomEntity room) { RoomEntity currentRoom = room; for (int i = 0; i < currentRoom.SeatList.Count; i++) { SeatEntity seatEntity = currentRoom.SeatList[i]; bool isWiner = true; for (int j = 0; j < currentRoom.SeatList.Count; j++) { if (currentRoom.SeatList[i].totalScore < currentRoom.SeatList[j].totalScore) { isWiner = false; break; } } UIItemResult_DouDZ uiItemResult = UIPoolManager.Instance.Spawn("UIItemResultInfo_DouDiZhu").GetComponent <UIItemResult_DouDZ>(); uiItemResult.transform.SetParent(infoContainer); if (uiItemResult.transform.position.z != 0) { uiItemResult.transform.localPosition = Vector3.zero; } uiItemResult.transform.localScale = Vector3.one; uiItemResult.SetUI(seatEntity, isWiner, currentRoom.OwnerID == seatEntity.PlayerId, seatEntity.IsPlayer); } roomIdText.SafeSetText(currentRoom.roomId.ToString()); roomLoopText.SafeSetText("游戏局数:" + /*currentRoom.currentLoop + "/" +*/ currentRoom.maxLoop); dateText.SafeSetText(System.DateTime.Now.ToString()); }
/// <summary> /// 结算 /// </summary> /// <param name="room"></param> public void Result(RoomEntity room) { //if (CurrentRoom == null) return; //CurrentRoom.roomStatus = RoomEntity.RoomStatus.Idle; //for (int i = 0; i < CurrentRoom.SeatList.Count; ++i) //{ // CurrentRoom.SeatList[i].status = SeatEntity.SeatStatus.Idle; //} //TransferData data = new TransferData(); //data.SetValue("Room", CurrentRoom); if (CurrentRoom == null) { return; } CurrentRoom.roomStatus = RoomEntity.RoomStatus.Idle; for (int i = 0; i < room.SeatList.Count; ++i) { SeatEntity protoSeat = room.SeatList[i]; SeatEntity seat = GetSeatByPlayerId(protoSeat.PlayerId); seat.totalScore = protoSeat.totalScore; } for (int i = 0; i < CurrentRoom.SeatList.Count; ++i) { CurrentRoom.SeatList[i].status = SeatEntity.SeatStatus.Idle; } TransferData data = new TransferData(); data.SetValue("Room", room); SendNotification(ON_RESULT, data); }
/// <summary> /// 翻倍 /// </summary> /// <param name="data"></param> private void OnPlusTimes(TransferData data) { RoomEntity room = data.GetValue <RoomEntity>("Room"); if (room == null) { return; } m_txtTimes.SafeSetText(room.Times.ToString()); }
/// <summary> /// 结算 /// </summary> /// <param name="obj"></param> private void OnSeatSettle(TransferData data) { RoomEntity CurrentRoom = data.GetValue <RoomEntity>("Room"); for (int i = 0; i < CurrentRoom.SeatList.Count; i++) { if (CurrentRoom.SeatList[i].Pos == m_Pos) { m_txtTotalScore.SafeSetText(CurrentRoom.SeatList[i].totalScore.ToString()); break; } } }
/// <summary> /// 下注 /// </summary> /// <param name="obj"></param> private void OnBet(TransferData data) { RoomEntity room = data.GetValue <RoomEntity>("Room"); if (room == null) { return; } SeatEntity seat = data.GetValue <SeatEntity>("SeatEntity"); if (seat == null) { return; } SetBetMenuActive(false, 0); m_txtBaseScore.SafeSetText(room.baseScore.ToString()); }
private void OnSeatResult(TransferData data) { RoomEntity resultRoom = data.GetValue <RoomEntity>("Room"); bool isSpring = false; for (int i = 0; i < resultRoom.SeatCount; i++) { if (resultRoom.SeatList[i].isSpring) { isSpring = true; break; } } float waitTime = 0; if (isSpring) { waitTime = 1.5f; if (springAnimation != null) { springAnimation.gameObject.SetActive(true); springAnimation.transform.GetComponent <UIItemSpringAnimation>().FlowerAnimation(); springAnimation.DORestart(); } //Action OpenSettleView = (() => //{ // m_UISettleView = UIViewUtil.Instance.LoadWindow("Settle_DouDiZhu").GetComponent<UISettleView>(); // m_UISettleView.SetUI(settleRoom/*,UISceneDouDZView.Instance.GetTxtLoop()*/); //}); //GetOrCreatUIItemAnimation().ShowPokersAnimation("DouDiZhu/UI_Spring_DouDiZhu", m_AnimationContainer.position, m_AnimationContainer.position, AnimationType.Spring, 1.5f, DG.Tweening.Ease.Linear,OpenSettleView); } //m_UIResultView = UIViewUtil.Instance.LoadWindow("Result_DouDiZhu").GetComponent<UIResultView_DouDZ>(); //m_UIResultView.SetUI(resultRoom); //m_UIResultView.SafeSetActive(false); //if (m_UISettleView != null) //{ // m_UISettleView.SetResultView(m_UIResultView); //} //StartCoroutine(openResultView(waitTime, resultRoom)); }
/// <summary> /// 初始化 /// </summary> /// <param name="obj"></param> private void OnInit(TransferData data) { RoomEntity room = data.GetValue <RoomEntity>("Room"); if (room == null) { return; } for (int i = 0; i < m_BasePokerList.Count; ++i) { UIPoolManager.Instance.Despawn(m_BasePokerList[i].transform); } m_BasePokerList.Clear(); for (int i = 0; i < room.basePoker.Count; ++i) { UIItemPoker item = SpawnPoker(room.basePoker[i]); item.gameObject.SetParent(m_BasePokerContainer); m_BasePokerList.Add(item); } for (int i = 0; i < room.SeatList.Count; ++i) { if (room.SeatList[i].IsPlayer) { bool mustPlay = data.GetValue <bool>("MustPlay"); bool canPlay = data.GetValue <bool>("CanPlay"); SetPlayPokerMenuActive(room.SeatList[i].status == SeatEntity.SeatStatus.PlayPoker, !mustPlay, !canPlay); SetBetMenuActive(room.SeatList[i].status == SeatEntity.SeatStatus.Bet, room.baseScore); m_btnReady.SafeSetActive(room.SeatList[i].status == SeatEntity.SeatStatus.Idle && room.roomStatus == RoomEntity.RoomStatus.Idle); m_btnShowPokerReady.SafeSetActive(room.SeatList[i].status == SeatEntity.SeatStatus.Idle && room.roomStatus == RoomEntity.RoomStatus.Idle); } } m_imgTrustee.SafeSetActive(room.PlayerSeat.IsTrustee); SetShowPokerImage(false); m_txtBaseScore.SafeSetText(room.baseScore.ToString()); }
public void SetUI(RoomEntity room /*,Text roomLoop*/) { RoomEntity currentRoom = room; //if (roomLoopText == null) //{ // roomLoopText = roomLoop; //} int bet = 0; bool isPlayer = false; for (int i = 0; i < currentRoom.SeatList.Count; i++) { if (currentRoom.SeatList[i].IsBanker) { bet = currentRoom.SeatList[i].bet; break; } } for (int i = 0; i < currentRoom.SeatList.Count; i++) { SeatEntity seatEntity = currentRoom.SeatList[i]; if (seatEntity.IsPlayer) { if (seatEntity.isWiner) { img_isWinnerTitle.SafeSetActive(true); img_isLoserTitle.SafeSetActive(false); AudioEffectManager.Instance.Play("doudizhu/" + "win"); } else { img_isWinnerTitle.SafeSetActive(false); img_isLoserTitle.SafeSetActive(true); AudioEffectManager.Instance.Play("doudizhu/" + "lose"); } } UIItemSettleSeatInfo_DouDZ uiitemSettleInfo = UIPoolManager.Instance.Spawn("UIItemSettleInfo_DouDiZhu").GetComponent <UIItemSettleSeatInfo_DouDZ>(); if (uiitemSettleInfo.transform != null) { uiitemSettleInfo.transform.SetParent(infoContainer); } else { Debug.LogWarning("空"); } if (uiitemSettleInfo.transform.position.z != 0) { uiitemSettleInfo.transform.localPosition = Vector3.zero; } uiitemSettleInfo.transform.localScale = Vector3.one; uiitemSettleInfo.SetUI(seatEntity, bet, currentRoom.OwnerID == seatEntity.PlayerId, isPlayer, currentRoom.Times); } roomIdText.SafeSetText(currentRoom.roomId.ToString()); roomSettleLoopText.SafeSetText("游戏局数:" + currentRoom.currentLoop + "/" + currentRoom.maxLoop); m_loop = currentRoom.currentLoop; m_maxLoop = currentRoom.maxLoop; roomLoopText.SafeSetText(currentRoom.currentLoop + "/" + currentRoom.maxLoop); dateText.SafeSetText(System.DateTime.Today.ToString()); }
/// <summary> /// 总结算 /// </summary> /// <param name="obj"></param> private void OnSeatResult(TransferData data) { RoomEntity CurrentRoom = data.GetValue <RoomEntity>("Room"); }
/// <summary> /// 开局 /// </summary> /// <param name="obj"></param> private void OnBegin(TransferData data) { RoomEntity room = data.GetValue <RoomEntity>("Room"); if (room == null) { return; } for (int i = 0; i < room.SeatList.Count; ++i) { SeatEntity seat = room.SeatList[i]; if (seat.Index == m_Index) { for (int j = 0; j < m_HandList.Count; ++j) { UIPoolManager.Instance.Despawn(m_HandList[j].transform); } m_HandList.Clear(); m_gender = seat.Gender; for (int j = 0; j < m_PlayPokers.Count; ++j) { UIPoolManager.Instance.Despawn(m_PlayPokers[j].transform); } m_PlayPokers.Clear(); List <GameObject> lstPokerTrans = new List <GameObject>(); for (int j = 0; j < seat.pokerList.Count; ++j) { UIItemPoker item = SpawnPoker(seat.pokerList[j]); lstPokerTrans.Add(item.gameObject); item.gameObject.SetParent(m_HandContainer); item.gameObject.SetActive(false); m_HandList.Add(item); } HandSort(); StartCoroutine(PlaySetHandPokerActive(lstPokerTrans)); if (m_txtOverPlus != null) { m_txtOverPlus.SetNumber(m_HandList.Count.ToString()); } if (m_PokerCount != null) { m_PokerCount.SetNumber(m_HandList.Count.ToString()); } m_imgReady.SafeSetActive(false); m_imgBanker.SafeSetActive(false); m_imgPlayer.SafeSetActive(true); PlayAudio("deal"); } } }
/// <summary> /// 初始化 /// </summary> /// <param name="obj"></param> private void OnInit(TransferData data) { RoomEntity room = data.GetValue <RoomEntity>("Room"); if (room == null) { return; } for (int i = 0; i < room.SeatList.Count; ++i) { SeatEntity seat = room.SeatList[i]; if (seat.Index != m_Index) { continue; } m_gender = seat.Gender; m_Pos = seat.Pos; for (int j = 0; j < m_HandList.Count; ++j) { UIPoolManager.Instance.Despawn(m_HandList[j].transform); } m_HandList.Clear(); for (int j = 0; j < m_PlayPokers.Count; ++j) { UIPoolManager.Instance.Despawn(m_PlayPokers[j].transform); } m_PlayPokers.Clear(); m_txtTotalScore.SafeSetText(seat.totalScore.ToString()); for (int j = 0; j < seat.pokerList.Count; ++j) { UIItemPoker item = SpawnPoker(seat.pokerList[j]); item.gameObject.SetParent(m_HandContainer); m_HandList.Add(item); } HandSort(); for (int j = 0; j < m_HandList.Count; j++) { m_HandList[j].transform.SetSiblingIndex(0); } if (m_txtOverPlus != null) { m_txtOverPlus.SetNumber(m_HandList.Count.ToString()); } if (m_PokerCount != null) { m_PokerCount.SetNumber(m_HandList.Count.ToString()); } if (seat.PreviourPoker != null) { for (int j = seat.PreviourPoker.Count - 1; j >= 0; --j) { UIItemPoker item = SpawnPoker(seat.PreviourPoker[j]); item.gameObject.SetParent(m_PlayPokerContainer); m_PlayPokers.Add(item); item.isBanker = seat.IsBanker; } } m_imgReady.SafeSetActive(room.roomStatus == RoomEntity.RoomStatus.Idle && seat.status == SeatEntity.SeatStatus.Ready); m_imgBanker.SafeSetActive(seat.IsBanker); m_imgPlayer.SafeSetActive(!seat.IsBanker); if (m_arrScoreParent) { m_arrScoreParent.gameObject.SetActive(true); } for (int j = 0; j < m_arrScore.Length; ++j) { m_arrScore[j].SafeSetActive(room.roomStatus == RoomEntity.RoomStatus.Bet && m_arrScore[j].name.ToInt() == seat.bet); } m_imgPass.SafeSetActive(room.roomStatus == RoomEntity.RoomStatus.Gaming && seat.PreviourPoker == null && seat.status == SeatEntity.SeatStatus.Wait); if (seat.status == SeatEntity.SeatStatus.PlayPoker) { m_countDown.SafeSetActive(true); m_countDown.transform.SetParent(m_CountDownContainer); m_countDown.transform.localPosition = Vector3.zero; m_countDown.SetCountDown(seat.unixtime); } } }
public SettleCommand(RoomEntity room) { m_Room = room; }
/// <summary> /// 重置房间数据 /// </summary> public void Reset() { CurrentRoom = null; //CurrentRoom.PlayerSeat = null; }
public ResultCommand(RoomEntity room) { m_Room = room; }
/// <summary> /// 打开结算界面 /// </summary> private IEnumerator openResultView(float waitTime, RoomEntity resultRoom) { yield return(new WaitForSeconds(waitTime)); //m_UIResultView.SafeSetActive(true); }