Example #1
0
            public static void Init()
            {
                var       asset  = (TextAsset)Game.ResourcesComponent.GetAsset("config", "TestConfig.bytes");
                var       bytes  = asset.bytes;
                var       binary = new ConfigBinary(bytes);
                const int MAGIC  = (byte)'B' | ((byte)'K' << 8) | ((byte)'C' << 16) | (1 << 24);

                if (binary.ReadInt() != MAGIC)
                {
                    throw new Exception("Wrong Magic");
                }

                {
                    int count = binary.ReadInt();
                    poolString = new string[count];
                    for (int i = 0; i < count; i++)
                    {
                        poolString[i] = binary.ReadString();
                    }
                }
                {
                    int count = binary.ReadInt();
                    poolStringArray = new string[count][];
                    for (int i = 0; i < count; i++)
                    {
                        poolStringArray[i] = LoadStringArray(binary);
                    }
                }
                {
                    int count = binary.ReadInt();
                    poolIntArray = new int[count][];
                    for (int i = 0; i < count; i++)
                    {
                        poolIntArray[i] = LoadIntArray(binary);
                    }
                }
                {
                    int count = binary.ReadInt();
                    ConfigCount = count;
                    ConfigList  = new TestConfig[count];
                    for (int i = 0; i < count; i++)
                    {
                        var Id    = binary.ReadUInt();
                        var Str   = poolString[binary.ReadInt()];
                        var Int   = binary.ReadInt();
                        var Flo   = binary.ReadFloat();
                        var StrA  = poolStringArray[binary.ReadInt()];
                        var IntA  = poolIntArray[binary.ReadInt()];
                        var EnumA = (EnumAType)binary.ReadInt();
                        var cfg   = new TestConfig(Id, Str, Int, Flo, StrA, IntA, EnumA);
                        ConfigList[i] = cfg;
                        ConfigDic.Add(cfg.Id, cfg);
                    }
                }
            }
Example #2
0
        protected Exporter(string name, string filePath, string csOutputPath, string binaryOutputPath)
        {
            FilePath         = filePath;
            CsOutputPath     = csOutputPath;
            BinaryOutputPath = binaryOutputPath;
            Name             = name;

            ExcelPackage = new ExcelPackage(new FileInfo(filePath));
            DataView     = new DataView(name, filePath, ExcelPackage);
            Binary       = new ConfigBinary($"{binaryOutputPath}/{Name}.bytes");
        }