示例#1
0
文件: RoomData.cs 项目: unstephen/Q3
        public void SetPlayerData(int pId, string userId, string userLoc, int score)
        {
            Log.Info("SetPlayerData设置玩家数据pId={0},userId={1},score={2}", pId, userId, score);
            var  player = GetPlayer(pId);
            bool bNew   = false;

            if (player == null)
            {
                if (GameManager.Instance.IsSelf(pId))
                {
                    player = playerSelf.Value;
                }
            }

            if (player == null)
            {
                player          = new PlayerOther();
                player.id.Value = pId;
                player.InitData();
                bNew = true;
            }


            player.name.Value    = userId;
            player.score.Value   = score;
            player.userLoc.Value = userLoc;
            player.SetPos(GetPosByPid(pId));

            if (bNew)
            {
                player.state = EPlayerState.Seat;
                RoomManager.Instance.rData.roomPlayers.Add(player as PlayerOther);
            }
        }
示例#2
0
    private void RecvNotifyJoin(byte[] args)
    {
        int gId = MsgParse.PopInt(ref args);

        if (gId != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }

        int pId = MsgParse.PopInt(ref args);

        byte pos   = MsgParse.PopByte(ref args);
        int  score = MsgParse.PopInt(ref args);

        //通过PID获取玩家的基本信息
        NetWorkManager.Instance.Send(Protocal.PLAYER_INFO, pId);
        if (pId == GameManager.Instance.GetRoleData().pId.Value)
        {
            RoomManager.Instance.Self.Value.SetPos(pos);
            RoomManager.Instance.Self.Value.state       = EPlayerState.Seat;
            RoomManager.Instance.Self.Value.score.Value = score;
        }
        else
        {
            var player = RoomManager.Instance.rData.GetPlayer(pId) as PlayerOther;
            if (player == null)
            {
                player          = new PlayerOther();
                player.id.Value = pId;
                player.InitData();
                player.SetPos(pos);
                player.state       = EPlayerState.Seat;
                player.score.Value = score;
                RoomManager.Instance.rData.roomPlayers.Add(player);
            }
        }
    }