Exemplo n.º 1
0
        /// <summary>
        /// 设置玩家头像
        /// </summary>
        /// <param name="vo"></param>
        public void SetPlayerUI(UserVO vo)
        {
            if (vo == null)
            {
                return;
            }

            this.curUseVO = vo;

            this.PlayerHead.sprite = SpriteHelper.GetSprite("ddzgame", this.GetHeadSpriteNameByIndex());

            this.SetHeadTransformByIndex();

            this.PlayerGoldItem.SetActive(true);

            //由于自己位置给的空间比较大,昵称就尽量显示长一些。
            if (seatId != 0)
            {
                this.PlayerName.text = StringHelper.FormatNickName(vo.nickName);
            }
            else
            {
                this.PlayerName.text = StringHelper.FormatNickName(vo.nickName, 20);
            }

            this.PlayerGold.text = NumberHelper.FormatMoney(vo.gold);

            this.PlayerHead.gameObject.SetActive(true);

            //this.LandlordFlag.SetActive(vo.IsLord == 1);

            this.Panel.SetActive(true);

            this.PlayerHead.SetNativeSize();
        }
Exemplo n.º 2
0
        private void InitData()
        {
            //初始化自己的信息
            UserVO myVo = new UserVO()
            {
                userID = GamePrefs.GetUserId(),

                headId = UserDataHelper.UserInfo.HeadId,

                sex = UserDataHelper.UserInfo.Gender,

                gold = UserDataHelper.UserInfo.Gold,

                nickName = UserDataHelper.UserInfo.Nickname,

                seatID = 0
            };

            DataCenterComponent.Instance.userInfo.httpUserInfo = myVo;

            DataCenterComponent.Instance.userInfo.addUser(myVo);

            //播放背景音乐

            SoundComponent.Instance.Stop(DataCenterComponent.Instance.soundInfo.bg_hall);

            var _soundVolume = PlayerPrefs.GetFloat("SoundVolume", 1);

            this.CurrentSoundName = DataCenterComponent.Instance.soundInfo.ddzbg + UnityEngine.Random.Range(1, 3);

            SoundComponent.Instance.PlayMusic(this.CurrentSoundName, 0, _soundVolume, true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="userVo">用户数据Vo</param>
 public void addUser(UserVO userVo)
 {
     if (userList.ContainsKey(userVo.userID))
     {
         UnityEngine.Debug.Log("用户重复添加:" + userVo.userID);
     }
     else
     {
         userList[userVo.userID] = userVo;
     }
 }
Exemplo n.º 4
0
        protected override void Run(ETModel.Session session, Actor_JionDDZRoom_Ntt message)
        {
            if (!DDZGameHelper.IsJoinRoom || GameHelper.ApplicationIsPause)
            {
                return;
            }

            if (message.RoomId == 0)
            {
                Log.Error("异常:房间号为0了");
            }

            if (DDZGameHelper.RoomId != message.RoomId)
            {
                return;
            }

            if (!DataCenterComponent.Instance.userInfo.isExist(message.PlayerData.UserId))
            {
                UserVO vo = new UserVO
                {
                    userID = message.PlayerData.UserId,

                    headId = message.PlayerData.HeadId,

                    sex = message.PlayerData.Gender,

                    gold = message.PlayerData.Gold,

                    nickName = message.PlayerData.NickeName,

                    seatID = message.PlayerData.ChairId,

                    point = message.PlayerData.QdzJiaoFen,

                    IsReady = message.PlayerData.IsPrepare?1:0
                };

                DataCenterComponent.Instance.userInfo.addUser(vo);
            }

            DDZConfig.GameScene.DDZJionRoom_Ntt(message);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 房间详情返回
        /// </summary>
        /// <param name="resp"></param>
        private void On_G2C_GetRoomInfo_Res(G2C_GetRoomInfo_Res resp)
        {
            DDZGameHelper.IsGetRoomDetails = true;

            DDZRoomData roomData = resp.RoomData.DdzRoomData;

            //将游戏配置参数保存
            DDZGameConfigComponent.Instance.SaveConfig(roomData);

            //保存倒计时
            DDZGameConfigComponent.Instance.LeftTime = resp.RoomData.LeftTime;

            //保存自己的信息,并刷新一次

            DataCenterComponent.Instance.userInfo.deleteAllUserExcptMe();

            var myVo = DataCenterComponent.Instance.userInfo.getMyUserVo();

            for (int i = 0; i < roomData.PlayerData.count; i++)
            {
                var playerData = roomData.PlayerData[i];

                // 保存谁是地主
                if (playerData.IsLord)
                {
                    DDZGameConfigComponent.Instance.LordID = playerData.ChairId;
                }

                if (!DataCenterComponent.Instance.userInfo.isExist(playerData.UserId))
                {
                    UserVO vo = new UserVO
                    {
                        userID = playerData.UserId,

                        headId = playerData.HeadId,

                        sex = playerData.Gender,

                        seatID = playerData.ChairId,

                        gold = playerData.Gold,

                        nickName = playerData.NickeName,

                        IsLord = playerData.IsLord ? 1 : 0,

                        IsReady = playerData.IsPrepare ? 1:0,

                        point = playerData.QdzJiaoFen //-1 没抢 1,2,3 0:不叫
                    };

                    DataCenterComponent.Instance.userInfo.addUser(vo);
                }
                else
                {
                    var vo = DataCenterComponent.Instance.userInfo.getUserByUserID(playerData.UserId);

                    vo.seatID = playerData.ChairId;

                    vo.IsLord = playerData.IsLord ? 1 : 0;

                    vo.gold = playerData.Gold;

                    vo.IsReady = playerData.IsPrepare?1:0;

                    vo.point = playerData.QdzJiaoFen;
                }
            }

            //显示座位玩家
            DDZPlayerHeadPlugin.SetOnSeatPlayer();

            //刷新倍数,底注

            this.DDZTopPlugin.SetBeiSu();

            this.DDZTopPlugin.SetBaseScore();

            //刷新底牌
            this.DDZTopPlugin.ShowDP(roomData.DpCards);

            //显示各个玩家的手牌数量

            if (roomData.SurCardsNum != null)
            {
                for (int i = 0; i < roomData.SurCardsNum.count; i++)
                {
                    int cardNum = roomData.SurCardsNum[i];

                    this.DDZPlayerHeadPlugin.SetCardNum(i, cardNum);
                }
            }

            //绘制玩家手牌
            if (roomData.Card != null)
            {
                this.DDZHandCardPlugin.ShowHandCard(roomData.Card);

                //刷新最新的手牌
                DDZGameConfigComponent.Instance.myHandCard = roomData.Card;
            }

            //绘制各玩家上一手的出牌

            if (roomData.PlayLastCircleCards != null)
            {
                var playLastCircleCards = roomData.PlayLastCircleCards.ToList();

                this.DDZOutCardPlugin.ShowHand(playLastCircleCards);
            }

            #region 处理各阶段状态

            DDZGameHelper.IsStartGame = (roomData.GameState == 0) ? false : true;

            //判断当前的游戏状态
            if (roomData.GameState == (int)DDZ_GameState.NoStart)
            {
                Log.Debug("当前游戏状态:未开局");

                this.CheckReadyState();
            }
            else if (roomData.GameState == (int)DDZ_GameState.Ready)
            {
                Log.Debug("当前游戏状态:准备");

                this.CheckReadyState();
            }
            else if (roomData.GameState == (int)DDZ_GameState.FaPai)
            {
                Log.Debug("当前游戏状态:发牌");
            }
            else if (roomData.GameState == (int)DDZ_GameState.CallScore)
            {
                Log.Debug("当前游戏状态:叫地主");

                //检测之前的叫分状态
                this.CheckCallScoreState();

                //采用服务器的倒计时
                DDZGameConfigComponent.Instance.ActiveOpTime = resp.RoomData.LeftTime;

                DDZGameConfigComponent.Instance.ActiveChairId = roomData.ActiveChairId;

                int realID = DDZGameHelper.ChangeSeat(roomData.ActiveChairId);

                if (realID == 0)
                {
                    this.DDZCallScorePlugin.Show(resp.RoomData.LeftTime);
                }
            }
            else if (roomData.GameState == (int)DDZ_GameState.DaPai)
            {
                Log.Debug("当前游戏状态:打牌");

                //采用服务器的倒计时
                DDZGameConfigComponent.Instance.ActiveOpTime = resp.RoomData.LeftTime;

                //判断当前活动玩家是否是自己,如果是:弹出抢分.

                DDZGameConfigComponent.Instance.ActiveChairId = roomData.ActiveChairId;

                int realID = DDZGameHelper.ChangeSeat(roomData.ActiveChairId);

                if (realID == 0)
                {
                    this.DDZInteractivePlugin.Show(resp.RoomData.LeftTime);
                }
            }
            else if (roomData.GameState == (int)DDZ_GameState.JieSuan)
            {
                Log.Debug("当前游戏状态:结算");
            }
            #endregion
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改自己的名字
        /// </summary>
        /// <param name="str"></param>
        public void changeName(string str)
        {
            UserVO user = this.getUser(this.httpUserInfo.userID);

            user.nickName = str;
        }