Пример #1
0
    static LevelBuilder()
    {
        Palette.LoadPalette(0);
        var dt1 = DT1.Load(Application.streamingAssetsPath + "/ds1edit.dt1", mpq: false);

        specialTiles.Add(dt1.tiles);
    }
Пример #2
0
        static LevelBuilder()
        {
            var palette = Palette.GetPalette(PaletteType.Act1);
            var dt1     = DT1.Load(Application.streamingAssetsPath + "/ds1edit.dt1", palette, mpq: false);

            specialTiles.Add(dt1.tiles);
        }
Пример #3
0
    static DS1 Load(byte[] bytes)
    {
        using (var stream = new MemoryStream(bytes))
            using (var reader = new BinaryReader(stream))
            {
                DS1 ds1 = new DS1();
                ds1.version = reader.ReadInt32();
                ds1.width   = reader.ReadInt32() + 1;
                ds1.height  = reader.ReadInt32() + 1;

                int act = 0;
                if (ds1.version >= 8)
                {
                    act = reader.ReadInt32();
                    act = Mathf.Min(act, 4);
                }

                int tagType = 0;
                if (ds1.version >= 10)
                {
                    tagType = reader.ReadInt32();
                }

                if (ds1.version >= 3)
                {
                    Palette.LoadPalette(act);
                    ds1.dt1Files    = ReadDependencies(reader);
                    ds1.tileSampler = new DT1.Sampler();
                    foreach (var dt1Filename in ds1.dt1Files)
                    {
                        var dt1 = DT1.Load(dt1Filename);
                        ds1.tileSampler.Add(dt1.tiles);
                    }
                }

                if ((ds1.version >= 9) && (ds1.version <= 13))
                {
                    stream.Seek(8, SeekOrigin.Current);
                }

                ReadLayers(ds1, bytes, reader, stream, tagType);
                ReadObjects(ds1, reader, act);
                try
                {
                    ReadGroups(ds1, reader, tagType);
                }
                catch (EndOfStreamException)
                {
                    // in fact there can be less groups than expected
                }

                return(ds1);
            }
    }
Пример #4
0
 private void InitTileSampler()
 {
     tileSampler = new DT1.Sampler();
     if (info != null)
     {
         foreach (var dt1Filename in info.type.dt1Files)
         {
             var dt1 = DT1.Load(dt1Filename);
             tileSampler.Add(dt1.tiles);
         }
     }
 }
Пример #5
0
        static public void ConvertDT1ToPNG()
        {
            var assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (!Application.isPlaying)
            {
                DT1.ResetCache();
            }

            var lowerPath = assetPath.ToLower();

            Color32[] palette;
            if (lowerPath.Contains("act2"))
            {
                palette = Palette.GetPalette(PaletteType.Act2);
            }
            else if (lowerPath.Contains("act3"))
            {
                palette = Palette.GetPalette(PaletteType.Act3);
            }
            else if (lowerPath.Contains("act4"))
            {
                palette = Palette.GetPalette(PaletteType.Act4);
            }
            else if (lowerPath.Contains("act5"))
            {
                palette = Palette.GetPalette(PaletteType.Act5);
            }
            else
            {
                palette = Palette.GetPalette(PaletteType.Act1);
            }
            var dt1 = DT1.Load(assetPath, palette, mpq: false);
            int i   = 0;

            foreach (var texture in dt1.textures)
            {
                var pngData = texture.EncodeToPNG();
                Object.DestroyImmediate(texture);
                var pngPath = assetPath + "." + i + ".png";
                File.WriteAllBytes(pngPath, pngData);
                AssetDatabase.ImportAsset(pngPath);
                ++i;
            }
        }