Esempio n. 1
0
 //添加玩家
 public void AddPlayer(string id)
 {
     lock (list)
     {
         ScenePlayer p = new ScenePlayer(id);
         list.Add(p);
     }
 }
Esempio n. 2
0
 public void AddPlayer(string id)
 {
     lock (list)
     {
         ScenePlayer p = new ScenePlayer();
         p.id = id;
         list.Add(p);
         Console.WriteLine("[场景管理]添加玩家");
     }
 }
 //添加玩家
 public void AddPlayer(string username)
 {
     //加锁防止多线程同时操作
     lock (list)
     {
         ScenePlayer p = new ScenePlayer();
         p.username = username;
         list.Add(p);
     }
 }
Esempio n. 4
0
        public void UpdateInfo(string id, float x, float y, float z, int score)
        {
            ProtocolBytes protocol = new ProtocolBytes();
            ScenePlayer   p        = GetScenePlayer(id);

            if (p == null)
            {
                return;
            }
            p.x     = x;
            p.y     = y;
            p.z     = z;
            p.score = score;
        }
Esempio n. 5
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.getInstance().Broadcast(protocol);
        }
        //更新信息
        public void UpdateInfo(string username, float x, float y, float z, int score, int kill)
        {
            int           count    = list.Count;
            ProtocolBytes protocol = new ProtocolBytes();
            ScenePlayer   p        = GetScenePlayer(username);

            if (p == null)
            {
                return;
            }
            p.x     = x;
            p.y     = y;
            p.z     = z;
            p.score = score;
            p.kill  = kill;
        }
        //删除玩家
        public void DelPlayer(string username)
        {
            lock (list)
            {
                ScenePlayer p = GetScenePlayer(username);
                if (p != null)
                {
                    list.Remove(p);
                }
            }
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("PlayerLeave");
            protocol.AddString(username);
            ServerTCP.instance.Broadcast(protocol);
        }
Esempio n. 8
0
        public void UpdateInfo(string id, float x, float y, float z, float xScale, int animInfo, string name)
        {
            int           count = list.Count;
            ProtocolBytes bytes = new ProtocolBytes();
            ScenePlayer   p     = GetScenePlayer(id);

            if (p == null)
            {
                return;
            }
            p.x        = x;
            p.y        = y;
            p.z        = z;
            p.xScale   = xScale;
            p.animInfo = animInfo;
            p.name     = name;
        }
Esempio n. 9
0
        public void DelPlayer(string id)
        {
            lock (list)
            {
                ScenePlayer p = GetScenePlayer(id);
                if (p != null)
                {
                    list.Remove(p);
                    Console.WriteLine("[场景管理]删除玩家");
                }
            }
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("PlayerLeave");
            protocol.AddString(id);
            Serv.instance.Broadcast(protocol);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public void SendPlayerList(Player player)
        {
            Console.WriteLine("发送玩家信息");
            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.AddFloat(p.xScale);
                protocol.AddInt(p.animInfo);
                protocol.AddString(p.name);
            }
            player.Send(protocol);
        }