Ejemplo n.º 1
0
    private byte[] ParseListFloat(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        string[] valueSplit = value.Split(',');
        var      dataCount  = valueSplit.Length;

        data = BitConverter.GetBytes(dataCount);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        List <float> listValues = new List <float>(dataCount);

        foreach (var v in valueSplit)
        {
            listValues.Add(float.Parse(v));
        }

        foreach (var v in listValues)
        {
            data = BitConverter.GetBytes(v);
            BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
            AddBytesData(bytes, data);
        }

        return(bytes.ToArray());
    }
Ejemplo n.º 2
0
    private byte[] ParseHashSetString(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        string[] valueSplit = value.Split(',');
        var      dataCount  = valueSplit.Length;

        data = BitConverter.GetBytes(dataCount);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        Dictionary <int, bool> keyMap = new Dictionary <int, bool>();

        List <int> listValues = new List <int>(dataCount);

        foreach (var v in valueSplit)
        {
            keyMap.Add(m_StringBufferToIndexMap[v], true);
            listValues.Add(m_StringBufferToIndexMap[v]);
        }

        foreach (var v in listValues)
        {
            data = BitConverter.GetBytes(v);
            BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
            AddBytesData(bytes, data);
        }

        return(bytes.ToArray());
    }
Ejemplo n.º 3
0
    private void writeItemCount(FileStream fs, short count)
    {
        var data = BitConverter.GetBytes(count);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        fs.Write(data, 0, data.Length);
    }
Ejemplo n.º 4
0
    private void WriteStringBuffer(FileStream fs)
    {
        var bytes = BitConverter.GetBytes(this.m_ItemCount);

        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        fs.WriteByte(m_HasStringBuffer);

        if (m_HasStringBuffer != 0)
        {
            var buffsize = GetStringBufferSize(m_StringBufferList);

            bytes = BitConverter.GetBytes(buffsize);
            BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
            fs.Write(bytes, 0, bytes.Length);
        }

        foreach (var strBuff in m_StringBufferList)
        {
            bytes = Encoding.UTF8.GetBytes(strBuff);
            fs.Write(bytes, 0, bytes.Length);
            fs.WriteByte(0);
        }
    }
Ejemplo n.º 5
0
    private void WriteTrunk(List <short> loadList, FileStream fs)
    {
        if (loadList.Count > 0)
        {
            var bytes = BitConverter.GetBytes(loadList.Count);
            BitConverterUtility.ConvertToLittleEndian(bytes, 0, 4);
            fs.Write(bytes, 0, bytes.Length);

            foreach (var priority in loadList)
            {
                bytes = BitConverter.GetBytes(priority);
                BitConverterUtility.ConvertToLittleEndian(bytes, 0, 2);
                fs.Write(bytes, 0, bytes.Length);
            }
        }
    }
Ejemplo n.º 6
0
    private byte[] ParseString(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        var sbIndex = m_StringBufferToIndexMap[value];

        data = BitConverter.GetBytes(sbIndex);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        return(bytes.ToArray());
    }
Ejemplo n.º 7
0
    private byte[] ParseFloat(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        var result = float.Parse(value);

        data = BitConverter.GetBytes(result);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        return(bytes.ToArray());
    }
Ejemplo n.º 8
0
    private void WriteLoadConfig(Dictionary <string, int> priorityMap, List <FileInfos> fileInfos)
    {
        if (Directory.Exists(m_Window.SettingUI.XmlBinExportDirectory))
        {
            Directory.Delete(m_Window.SettingUI.XmlBinExportDirectory, true);
        }
        if (!Directory.Exists(m_Window.SettingUI.XmlBinExportDirectory))
        {
            Directory.CreateDirectory(m_Window.SettingUI.XmlBinExportDirectory);
        }

        FileStream fs = File.Create(m_Window.SettingUI.XmlBinExportDirectory + "/GameDataConfig.xml");

        int flag        = GetTrunkFlag();
        int count       = priorityMap.Count;
        int bufferBytes = GetStringBufferSize(priorityMap);

        var bytes = BitConverter.GetBytes(flag);

        BitConverterUtility.ConvertToLittleEndian(bytes, 0, 4);
        fs.Write(bytes, 0, bytes.Length);

        bytes = BitConverter.GetBytes(count);
        BitConverterUtility.ConvertToLittleEndian(bytes, 0, 4);
        fs.Write(bytes, 0, bytes.Length);

        bytes = BitConverter.GetBytes(bufferBytes);
        BitConverterUtility.ConvertToLittleEndian(bytes, 0, 4);
        fs.Write(bytes, 0, bytes.Length);

        WriteStringBuff(fileInfos, fs);

        WriteTrunk(m_PreloadList, fs);
        WriteTrunk(m_HighList, fs);
        WriteTrunk(m_MediumList, fs);
        WriteTrunk(m_NormalList, fs);
        WriteTrunk(m_LowList, fs);
        WriteTrunk(m_DontLoadList, fs);

        fs.Flush();
        fs.Close();
    }
Ejemplo n.º 9
0
    private byte[] ParseListFloat2(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        string[] valueSplit = value.Split(',');
        data = BitConverter.GetBytes(valueSplit.Length);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        for (int i = 0; i < valueSplit.Length; i++)
        {
            var parseResult = valueSplit[i].Split('_');

            data = BitConverter.GetBytes(parseResult.Length);
            BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
            AddBytesData(bytes, data);

            List <float> listValues = new List <float>(parseResult.Length);
            foreach (var v in parseResult)
            {
                listValues.Add(float.Parse(v));
            }

            foreach (var v in listValues)
            {
                data = BitConverter.GetBytes(v);
                BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
                AddBytesData(bytes, data);
            }
        }

        return(bytes.ToArray());
    }
Ejemplo n.º 10
0
    private void WriteHead(FileStream fs)
    {
        var bytes = BitConverter.GetBytes(this.m_FieldCount);

        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        foreach (var type in this.m_FieldTypeList)
        {
            fs.WriteByte(type);
        }

        bytes = BitConverter.GetBytes(m_FieldNameBufferSzie);
        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        foreach (var fieldName in m_FieldNameList)
        {
            bytes = Encoding.UTF8.GetBytes(fieldName);
            fs.Write(bytes, 0, bytes.Length);
            fs.WriteByte(0);
        }
    }
Ejemplo n.º 11
0
    private byte[] ParseMapS2I(short fieldIndex, string value)
    {
        List <byte> bytes = new List <byte>();

        var data = BitConverter.GetBytes(fieldIndex);

        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        string[] valueSplit = value.Split(',');
        data = BitConverter.GetBytes(valueSplit.Length);
        BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
        AddBytesData(bytes, data);

        Dictionary <int, int> keySet = new Dictionary <int, int>();

        for (int i = 0; i < valueSplit.Length; i++)
        {
            var parseResult = valueSplit[i].Split(':');

            List <int> listValues = new List <int>(2);

            keySet.Add(m_StringBufferToIndexMap[parseResult[0]], int.Parse(parseResult[1])); //有重复的健会报错

            listValues.Add(m_StringBufferToIndexMap[parseResult[0]]);
            listValues.Add(int.Parse(parseResult[1]));

            foreach (var v in listValues)
            {
                data = BitConverter.GetBytes(v);
                BitConverterUtility.ConvertToLittleEndian(data, 0, data.Length);
                AddBytesData(bytes, data);
            }
        }

        return(bytes.ToArray());
    }
Ejemplo n.º 12
0
    private static void ExportAssetDependences()
    {
        List <string>            stringBuff      = new List <string>();
        Dictionary <string, int> stringBuffIndex = new Dictionary <string, int>();

        foreach (var gameAsset in GameAssets)
        {
            var path = EditorFileUtility.GetPathWithoutExt(gameAsset.Value.Path);
            if (!stringBuffIndex.ContainsKey(path))
            {
                stringBuff.Add(path);
                stringBuffIndex.Add(path, stringBuff.Count - 1);
            }

            if (!stringBuffIndex.ContainsKey(gameAsset.Value.AssetBundlePath))
            {
                stringBuff.Add(gameAsset.Value.AssetBundlePath);
                stringBuffIndex.Add(gameAsset.Value.AssetBundlePath, stringBuff.Count - 1);
            }

            foreach (var dependence in gameAsset.Value.ChildDependences)
            {
                path = EditorFileUtility.GetPathWithoutExt(dependence);
                if (!stringBuffIndex.ContainsKey(path))
                {
                    stringBuff.Add(path);
                    stringBuffIndex.Add(path, stringBuff.Count - 1);
                }
            }
        }

        FileStream fs = File.Create(Application.dataPath + "/Resources/AssetsDependences.xml");

        //资源的数量
        var count = GameAssets.Count;
        var bytes = BitConverter.GetBytes(count);

        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        //字符串的数量
        count = stringBuff.Count;
        bytes = BitConverter.GetBytes(count);
        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        //写入字符串资源
        var buffsize = GetStringBufferSize(stringBuff);

        bytes = BitConverter.GetBytes(buffsize);
        BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
        fs.Write(bytes, 0, bytes.Length);

        foreach (var str in stringBuff)
        {
            bytes = Encoding.UTF8.GetBytes(str);
            fs.Write(bytes, 0, bytes.Length);
            fs.WriteByte(0);
        }

        //写入每一个资源的条目
        foreach (var gameAsset in GameAssets)
        {
            var index = stringBuffIndex[EditorFileUtility.GetPathWithoutExt(gameAsset.Value.Path)];
            bytes = BitConverter.GetBytes(index);
            BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
            fs.Write(bytes, 0, bytes.Length);

            index = stringBuffIndex[gameAsset.Value.AssetBundlePath];
            bytes = BitConverter.GetBytes(index);
            BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
            fs.Write(bytes, 0, bytes.Length);

            count = gameAsset.Value.ChildDependences.Count;
            bytes = BitConverter.GetBytes(count);
            BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
            fs.Write(bytes, 0, bytes.Length);

            foreach (var d in gameAsset.Value.ChildDependences)
            {
                index = stringBuffIndex[EditorFileUtility.GetPathWithoutExt(d)];
                bytes = BitConverter.GetBytes(index);
                BitConverterUtility.ConvertToLittleEndian(bytes, 0, bytes.Length);
                fs.Write(bytes, 0, bytes.Length);
            }
        }

        fs.Flush();
        fs.Close();

        AssetDatabase.Refresh();
        Object[] objs = new Object[1];
        objs[0] = AssetDatabase.LoadMainAssetAtPath("Assets/Resources/AssetsDependences.xml");
        string[] assetsName = new string[] { "Assets/Resources/AssetsDependences" };
        BuildAssetBundle(objs, assetsName, Path.GetDirectoryName(Application.dataPath) + ExportDir + "/AssetsDependences.pkg");

        File.Delete(Application.dataPath + "/Resources/AssetsDependences.xml");
        File.Delete(Application.dataPath + "/Resources/AssetsDependences.xml.meta");
        AssetDatabase.Refresh();
    }