Beispiel #1
0
 //添加玩家
 public void AddPlayer(string id)
 {
     lock (list)
     {
         ScenePlayer p = new ScenePlayer();
         p.id = id;
         list.Add(p);
     }
 }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }