Beispiel #1
0
        /// <summary>
        /// 发送座位信息变更消息
        /// </summary>
        /// <param name="seat"></param>
        private void SendSeatInfoChangeNotify(SeatEntity seat)
        {
            if (seat == null)
            {
                return;
            }
            TransferData data = new TransferData();

            data.SetValue("SeatEntity", seat);
            data.SetValue("SeatIndex", seat.Index);
            data.SetValue("SeatPos", seat.Pos);
            data.SetValue("PlayerId", seat.PlayerId);
            data.SetValue("Avatar", seat.Avatar);
            data.SetValue("Gold", seat.Gold);
            data.SetValue("IsPlayer", seat.IsPlayer);
            data.SetValue("Nickname", seat.Nickname);
            data.SetValue("PokerList", seat.pokerList);
            data.SetValue("SeatStatus", seat.status);
            data.SetValue("Bet", seat.bet);
            data.SetValue("RoomStatus", CurrentRoom.roomStatus);
            data.SetValue("TotalScore", seat.totalScore);
            SendNotification(ON_SEAT_INFO_CHANGED, data);
        }
Beispiel #2
0
        /// <summary>
        /// 结算
        /// </summary>
        /// <param name="room"></param>
        public void Settle(RoomEntity room)
        {
            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_SETTLE, data);
        }
Beispiel #3
0
        /// <summary>
        /// 下注
        /// </summary>
        /// <param name="obj"></param>
        private void OnSeatBet(TransferData data)
        {
            SeatEntity seat = data.GetValue <SeatEntity>("SeatEntity");

            if (seat == null)
            {
                return;
            }
            if (seat.Index != m_Index)
            {
                return;
            }

            if (m_arrScoreParent)
            {
                m_arrScoreParent.gameObject.SetActive(true);
            }

            for (int i = 0; i < m_arrScore.Length; ++i)
            {
                m_arrScore[i].SafeSetActive(m_arrScore[i].name.ToInt() == seat.bet);
            }

            string audioSuffix;

            if (m_gender == 1)
            {
                audioSuffix = "Man";
            }
            else
            {
                audioSuffix = "Woman";
            }

            PlayAudio("bet" + seat.bet + audioSuffix);
        }
Beispiel #4
0
 /// <summary>
 /// 计算index
 /// </summary>
 private void CalculateSeatIndex()
 {
     CurrentRoom.PlayerSeat = null;
     if (CurrentRoom == null)
     {
         return;
     }
     for (int i = 0; i < CurrentRoom.SeatList.Count; ++i)
     {
         if (CurrentRoom.SeatList[i].IsPlayer)
         {
             CurrentRoom.PlayerSeat          = CurrentRoom.SeatList[i];
             CurrentRoom.PlayerSeat.IsPlayer = true;
             for (int j = 0; j < CurrentRoom.SeatList.Count; ++j)
             {
                 SeatEntity seat      = CurrentRoom.SeatList[j];
                 int        seatIndex = seat.Pos - CurrentRoom.PlayerSeat.Pos;
                 seatIndex  = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex;
                 seat.Index = seatIndex;
             }
             break;
         }
     }
     if (CurrentRoom.PlayerSeat == null)
     {
         CurrentRoom.PlayerSeat          = CurrentRoom.SeatList[0];
         CurrentRoom.PlayerSeat.IsPlayer = true;
         for (int j = 0; j < CurrentRoom.SeatList.Count; ++j)
         {
             SeatEntity seat      = CurrentRoom.SeatList[j];
             int        seatIndex = seat.Pos - CurrentRoom.PlayerSeat.Pos;
             seatIndex  = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex;
             seat.Index = seatIndex;
         }
     }
 }
Beispiel #5
0
        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());
        }
Beispiel #6
0
        public void SetUI(SeatEntity seatEntity, int bet, bool isOwner, bool isPlayer, int Times)
        {
            playerIDText.SafeSetText(seatEntity.PlayerId.ToString());
            playerNameText.SafeSetText(seatEntity.Nickname.ToString());
            betText.SafeSetText(bet.ToString());
            scoreText.SafeSetText(seatEntity.score.ToString());

            if (seatEntity.isWiner)
            {
                img_isWinner.SafeSetActive(true);
            }
            else
            {
                img_isWinner.SafeSetActive(false);
            }

            if (seatEntity.IsBanker)
            {
                multipleText.SafeSetText((Times * 2).ToString());
                if (isBankerObj != null)
                {
                    isBankerObj.SetActive(true);
                }
            }
            else
            {
                multipleText.SafeSetText(Times.ToString());
                if (isBankerObj != null)
                {
                    isBankerObj.SetActive(false);
                }
            }

            if (isOwner)
            {
                if (isOwnerObj != null)
                {
                    isOwnerObj.SetActive(true);
                }
            }
            else
            {
                if (isOwnerObj != null)
                {
                    isOwnerObj.SetActive(false);
                }
            }
            if (isPlayer)
            {
                if (seatEntity.isWiner)
                {
                    img_isPlayerWinerBg.SafeSetActive(true);
                    img_isPlayerLoserBg.SafeSetActive(false);
                    img_isBg.SafeSetActive(false);
                }
                else
                {
                    img_isPlayerWinerBg.SafeSetActive(false);
                    img_isPlayerLoserBg.SafeSetActive(true);
                    img_isBg.SafeSetActive(false);
                }
            }
            else
            {
                img_isPlayerWinerBg.SafeSetActive(false);
                img_isPlayerLoserBg.SafeSetActive(false);
                img_isBg.SafeSetActive(true);
            }

            TextureManager.Instance.LoadHead(seatEntity.Avatar, OnAvatarLoadFinish);
        }
Beispiel #7
0
        /// <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");
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// 设置地主
        /// </summary>
        /// <param name="obj"></param>
        private void OnSetBanker(TransferData data)
        {
            SeatEntity seat = data.GetValue <SeatEntity>("SeatEntity");

            if (seat == null)
            {
                return;
            }
            if (seat.Index == m_Index)
            {
                List <Poker> pokers = data.GetValue <List <Poker> >("PokerList");
                if (pokers == null)
                {
                    return;
                }

                if (seat.IsPlayer)
                {
                    for (int i = 0; i < pokers.Count; ++i)
                    {
                        UIItemPoker item = SpawnPoker(pokers[i]);
                        item.gameObject.SetParent(m_HandContainer);
                        m_HandList.Add(item);
                    }
                }
                else
                {
                    for (int i = 0; i < pokers.Count; ++i)
                    {
                        UIItemPoker item = SpawnPoker(new Poker(pokers[i].index, 0, 0));
                        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 (m_arrScoreParent)
            {
                m_arrScoreParent.gameObject.SetActive(true);
            }

            m_imgBanker.SafeSetActive(seat.Index == m_Index);
            m_imgPlayer.SafeSetActive(seat.Index != m_Index);

            for (int i = 0; i < m_arrScore.Length; ++i)
            {
                m_arrScore[i].SafeSetActive(false);
            }
        }
Beispiel #9
0
        /// <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);
                }
            }
        }