示例#1
0
 //添加玩家
 public void AddPlayer(string id)
 {
     lock (list)
     {
         ScenePlayer p = new ScenePlayer();
         p.id = id;
         list.Add(p);
     }
 }
示例#2
0
        //更新信息
        public void UpdateInfo(string id, float x, float y, float z, int score)
        {
            int           count    = list.Count;
            ProtocolBytes protocol = new ProtocolBytes();
            ScenePlayer   p        = GetScenePlayer(id);

            if (p == null)
            {
                return;
            }
            p.x     = x; p.y = y; p.z = z;
            p.score = score;
        }
示例#3
0
        //删除列表
        public void DelPlayer(string id)
        {
            lock (list)
            {
                ScenePlayer p = GetScenePlayer(id);
                if (p != null)
                {
                    list.Remove(p);
                }
            }
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("PlayerLeave");
            protocol.AddString(id);
            ServNet.instance.Broadcast(protocol);
        }
示例#4
0
        //发送列表
        public void SendPlayerList(Player player)
        {
            int           count    = list.Count;
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("GetList");
            protocol.AddInt(count);
            for (int i = 0; i < count; i++)
            {
                ScenePlayer p = list[i];
                protocol.AddString(p.id);
                protocol.AddFloat(p.x);
                protocol.AddFloat(p.y);
                protocol.AddFloat(p.z);
                protocol.AddInt(p.score);
                Console.WriteLine("玩家:" + p.id + " " + p.score);
            }
            player.Send(protocol);
        }