Esempio n. 1
0
 public void Load(LusuoStream ls)
 {
     //Debug.Log("模型自身读取数据");
     m_resID = ls.ReadInt();
     ls.ReadString(out m_strName);
     ls.ReadVector3(ref m_vPos);
     ls.ReadVector3(ref m_vRotate);
     ls.ReadVector3(ref m_vScale);
     ls.ReadBool(ref m_bStatic);
     // 读取光照图
     ls.ReadInt(ref m_lightMapIndexNum);
     m_lightMapIndex       = new int[m_lightMapIndexNum];
     m_lightMapScaleOffset = new Vector4[m_lightMapIndexNum];
     for (int i = 0; i < m_lightMapIndexNum; i++)
     {
         ls.ReadInt(ref m_lightMapIndex[i]);
     }
     for (int i = 0; i < m_lightMapIndexNum; i++)
     {
         ls.ReadVector4(ref m_lightMapScaleOffset[i]);
     }
     // 读取环境音效
     ls.ReadInt(ref m_envSoundNum);
     m_envSoundResId = new int[m_envSoundNum];
     for (int i = 0; i < m_envSoundNum; i++)
     {
         ls.ReadInt(ref m_envSoundResId[i]);
     }
 }
Esempio n. 2
0
        private void InitStaticData()
        {
            if (m_staticDynamic == null)
            {
                return;
            }
            byte[]      data = m_staticDynamic.GetData();
            LusuoStream ls   = new LusuoStream(data);

            m_width      = ls.ReadInt();
            m_hight      = ls.ReadInt();
            m_staticData = new byte[m_width * m_hight];
            ls.Read(ref m_staticData);
        }
Esempio n. 3
0
 /// <summary>
 /// 接受消息时的外部方法,读取流对象取数据
 /// 子类无需重写
 /// </summary>
 public void OnRecv(int contentLen, ref LusuoStream ls)
 {
     eno         = ls.ReadInt();
     structBytes = new byte[contentLen - StringHelper.s_ShortSize - StringHelper.s_IntSize];
     ls.Read(ref structBytes);
     //Debug.Log("消息:" + msgID + " eno:" + eno);
 }
Esempio n. 4
0
        private void HandleMsg()
        {
            LusuoStream stream = new LusuoStream(m_recvBuffer);
            int         msgLen = stream.ReadInt();
            ushort      msgId  = stream.ReadUShort();
            //Debug.Log("接受消息长度:" + msgLen);
            //Debug.Log("接受消息ID:" + (eNetMessageID)msgId);
            // 通过消息头,获取消息体
            NetMessage msg = NetManager.Inst.GetMessage((eNetMessageID)msgId);

            msg.OnRecv(msgLen, ref stream);
            if (msg is FspMsgFrame)
            {
                msg.OnRecv();
                GameManager.Inst.AddFrameMsg(msg);
            }
            //msg.OnRecv();
            m_msgList.Add(msg);


            // 如果id段大于1000,那么就是lua协议
            //if (msgId > s_luaStartId)
            //{
            //    LuaMsgStruct data;
            //    data.id = msgId;
            //    data.msgLen = msgLen;
            //    data.stream = stream;
            //    m_luaMsgList.Add(data);
            //}
        }
Esempio n. 5
0
        private void _HandleMsgNew()
        {
            for (int i = 0; i < _m_listMsg.Count; i++)
            {
                LusuoStream stream = _m_listMsg[i];
                int         msgLen = stream.ReadInt();
                //ushort msgId = stream.ReadUShort();
                int msgId = stream.ReadInt();
                //Debug.Log("接受消息长度:" + msgLen);
                //Debug.Log("接受消息ID:" + (eNetMessageID)msgId);
                byte[] structBytes = new byte[msgLen - StringHelper.s_IntSize];
                stream.Read(ref structBytes);
                //MyMessage recv = ProtobufHelper.DeSerialize<MyMessage>(structBytes);

                //Action<MyMessage> OnRecv;
                //if (_m_msgList.TryGetValue(msgId, out OnRecv))
                //{
                //    if (OnRecv != null)
                //        OnRecv(recv);
                //}
            }
            _m_listMsg.Clear();
        }
Esempio n. 6
0
        private void HandleMsg(Conn conn)
        {
            LusuoStream stream     = new LusuoStream(conn.readBuff);
            int         contentLen = stream.ReadInt();
            ushort      msgId      = stream.ReadUShort();
            NetMessage  msg        = NetManager.Inst.GetMessage(msgId);

            if (msg == null)
            {
                return;
            }
            if (msgId != (int)eNetMessageID.MsgHeartBeat)
            {
                Console.WriteLine(m_serverType + ":接受消息:" + (eNetMessageID)msgId);
            }
            msg.OnRecv(ref conn, contentLen, ref stream);

            MessageCache cache;

            cache.conn = conn;
            cache.msg  = msg;
            // 每次接受存起来,然后一阵一个
            msgList.Add(cache);
        }
Esempio n. 7
0
 /// <summary>
 /// 接受消息时的外部方法,读取流对象取数据
 /// 子类无需重写
 /// </summary>
 public void OnRecv(ref Conn conn, int contentLen, ref LusuoStream ls)
 {
     eno         = ls.ReadInt();
     structBytes = new byte[contentLen - StringHelper.s_ShortSize - StringHelper.s_IntSize];
     ls.Read(ref structBytes);
 }