Exemplo n.º 1
0
 //添加Scene角色
 public void AddPlayer(string id)
 {
     lock (_list){
         ScenePlayer p = new ScenePlayer();
         p.id = id;
         _list.Add(p);
     }
 }
Exemplo n.º 2
0
        //更新信息
        public void UpdateInfo(string id, float x, float y, float z)
        {
            int count = _list.Count;
            ProtocolPbprotobuf protocol = new ProtocolPbprotobuf();
            ScenePlayer        p        = GetScenePlayer(id);

            if (p == null)
            {
                return;
            }
            p.x = x;
            p.y = y;
            p.z = z;
        }
Exemplo n.º 3
0
        //删除Scene角色
        public void DelPlayer(string id)
        {
            lock (_list){
                ScenePlayer p = GetScenePlayer(id);
                if (p != null)
                {
                    _list.Remove(p);
                }
            }
            ProtocolPbprotobuf protocol = new ProtocolPbprotobuf();

            protocol.SetResponse(ProtocolPbprotobuf.QueryName.PlayerLeave.ToString(), 0, id);
            ServNet.ServNet._instance.Broadcast(protocol);
        }
Exemplo n.º 4
0
        //发送列表
        public void SendPlayerList(Player player)
        {
            int count = _list.Count;
            ProtocolPbprotobuf protocol = new ProtocolPbprotobuf();

            protocol.SetName(ProtocolPbprotobuf.QueryName.GetList.ToString());
            for (int i = 0; i < count; i++)
            {
                ScenePlayer p = _list[i];
                protocol.buf.PlayerInfos[p.id] = new PlayerInfo()
                {
                    Id       = p.id,
                    NickName = "",
                    Pos      = new Pos()
                    {
                        X = p.x, Y = p.y, Z = p.z
                    }
                };
                player.Send(protocol);
            }
        }