Exemple #1
0
        public void doData(byte[] data)
        {
            tempindex = 0;
            byte command = DataPro.getByte(data, ref tempindex);

            switch (command)
            {
            case PacketDefine.UserIn:
                isON = true;
                Packet p = new Packet();
                p.addByte(PacketDefine.ConnectionSucess);
                p.addInt(m_id);
                Console.WriteLine("玩家: {0}", m_id);
                sendPacket(p);
                break;

            case PacketDefine.EnterMap:
                Enter(data);
                break;

            case PacketDefine.MoveInMap:
                Move(data);
                break;
            }
        }
Exemple #2
0
        protected void Move(byte[] data)
        {
            int mapId = DataPro.getInt(data, ref tempindex);

            if (m_map.id == mapId)
            {
                x = DataPro.getInt(data, ref tempindex);
                y = DataPro.getInt(data, ref tempindex);

                m_map.Move(this);
            }
        }
Exemple #3
0
        protected void Enter(byte[] data)
        {
            int mapId = DataPro.getInt(data, ref tempindex);
            Map m     = MapManager.getMapOfId(mapId);

            if (m != null)
            {
                m_map = m;
                x     = DataPro.getInt(data, ref tempindex);
                y     = DataPro.getInt(data, ref tempindex);
                m_map.Enter(this);
            }
        }
Exemple #4
0
        //数据解析
        public void parse()
        {
            byte packageLength = DataPro.getByte(m_buffer, ref m_postion);

            if ((packageLength + m_postion) <= m_endIndex)
            {
                Console.WriteLine("Complete Package");
                byte[] data = new byte[packageLength];
                DataPro.getByteArray(m_buffer, ref m_postion, data);

                ThreadMessage tm = new ThreadMessage();
                tm.data = data;
                tm.mc   = m_cc;

                //推入线程池
                MyGlobal.mpool.addJob(tm);

                parse();
            }
            else
            {
                m_postion--;
            }
        }
Exemple #5
0
 public void addString(String data)
 {
     DataPro.addData(m_buffer, ref index, data);
 }
Exemple #6
0
 public void addByte(byte data)
 {
     DataPro.addData(m_buffer, ref index, data);
 }
Exemple #7
0
 public void addInt(int data)
 {
     DataPro.addData(m_buffer, ref index, data);
 }