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