コード例 #1
0
 public int Register(GameObject o, GOType type, int guid = -1, int extra = -1)
 {
     if (guid < 0)
     {
         guid = _guid++;
     }
     Debug.Log("register go, type : " + type + ", guid :" + guid);
     m_objects[guid] = new GOWrapper(type, o, guid, extra);
     o.GetComponent <Guid>().SetGUID(guid);
     return(guid);
 }
コード例 #2
0
    public byte[] DumpData()
    {
        byte[] data = new byte[m_objects.Count * 17];
        int    i    = 0;

        foreach (var j in m_objects)
        {
            GOWrapper go  = j.Value;
            Vector3   pos = go.go.transform.position;
            Array.Copy(BitConverter.GetBytes(go.guid), 0, data, i, 4);
            i        += 4;
            data[i++] = (byte)go.type;
            data[i++] = (byte)go.extra;
            Array.Copy(BitConverter.GetBytes(pos.x), 0, data, i, 4);
            i += 4;
            Array.Copy(BitConverter.GetBytes(pos.z), 0, data, i, 4);
            i += 4;
        }
        return(data);
    }
コード例 #3
0
    public byte[] DumpData(int guid)
    {
        if (!m_objects.ContainsKey(guid))
        {
            return(null);
        }
        byte[]    data = new byte[17];
        int       i    = 0;
        GOWrapper go   = m_objects[guid];
        Vector3   pos  = go.go.transform.position;

        Array.Copy(BitConverter.GetBytes(go.guid), 0, data, i, 4);
        i        += 4;
        data[i++] = (byte)go.type;
        data[i++] = (byte)go.extra;
        Array.Copy(BitConverter.GetBytes(pos.x), 0, data, i, 4);
        i += 4;
        Array.Copy(BitConverter.GetBytes(pos.z), 0, data, i, 4);
        i += 4;
        return(data);
    }