示例#1
0
        public void Enter(User u)
        {
            lock (mylock)
            {
                m_stack.Add(u);
            }

            Packet p = new Packet();
            p.addByte(PacketDefine.PlayerInMap);
            p.addInt(u.id);
            p.addInt(this.id);
            p.addInt(u.x);
            p.addInt(u.y);

            foreach (User user in m_stack)
            {
                user.sendPacket(p);         //向玩家发送此玩家进入地图

                Packet other = new Packet();
                other.addByte(PacketDefine.PlayerInMap);
                other.addInt(user.id);
                other.addInt(this.id);
                other.addInt(user.x);
                other.addInt(user.y);

                if (user.id != u.id)
                {
                    u.sendPacket(other);    //向u发送已经存在地图的玩家
                }

            }
        }
示例#2
0
        public void Move(User u)
        {
            Packet p = new Packet();
            p.addByte(PacketDefine.PlayerPositonMove);
            p.addInt(u.id);
            p.addInt(this.id);
            p.addInt(u.x);
            p.addInt(u.y);

            foreach (User user in m_stack)
            {
                user.sendPacket(p);
            }
        }
示例#3
0
        public void Leave(User u)
        {
            Packet p = new Packet();
            p.addByte(PacketDefine.UserLeave);
            p.addInt(u.id);
            p.addInt(this.id);

            foreach (User user in m_stack)
            {
                if (user == u)
                {
                    lock(mylock)
                    {
                        m_stack.Remove(user);
                        break;
                    }
                }
            }
            foreach (User ua in m_stack)
            {
                ua.sendPacket(p);
            }
        }
示例#4
0
        private int m_postion; //当前解析位置

        #endregion Fields

        #region Constructors

        public OneProtocol(User cc)
        {
            m_cc = cc;
            m_buffer = new byte[ServerConfig.BUFFERLENGTH*10];
        }