Exemplo n.º 1
0
        public Assets(string folder, XElement xml)
        {
            XML = xml;
            if (XML.Element("VSwap") != null)
            {
                VSwap = VSwap.Load(folder, XML);
            }
            if (XML.Element("Maps") != null)
            {
                Maps = GameMap.Load(folder, XML);
            }
            if (XML.Element("VgaGraph") != null)
            {
                VgaGraph = VgaGraph.Load(folder, XML);
            }

            Pushwall = (ushort)(uint)XML?.Element("VSwap")?.Element("Objects")?.Element("Pushwall")?.Attribute("Number");

            // Creating floor texture
            uint[]            palette  = WarpWriterFriendlyPalette(VSwap.Palette);
            ByteArrayRenderer renderer = new ByteArrayRenderer()
            {
                Width  = 254,
                Height = 128,
                Color  = new FlatVoxelColor()
                {
                    Palette = palette,
                },
            };

            renderer.IsoTile(64, 64,
                             palette[
                                 WarpWriterFriendly(
                                     (byte)(int)XML.Element("Maps").Attribute("FloorIndex")
                                     )
                             ]
                             );
            Godot.Image image = new Image();
            image.CreateFromData((int)renderer.Width, (int)renderer.Height, false, Image.Format.Rgba8, renderer.Bytes);
            Floor = new ImageTexture();
            Floor.CreateFromImage(image, 0);

            FloorTileSet = new TileSet();
            FloorTileSet.CreateTile(0);
            FloorTileSet.TileSetTexture(0, Floor);
        }
Exemplo n.º 2
0
        public VgaGraph(byte[][] file, XElement xml)
        {
            Palette = VSwap.LoadPalette(xml);
            XML     = xml.Element("VgaGraph");
            using (MemoryStream sizes = new MemoryStream(file[(uint)XML.Element("Sizes").Attribute("Chunk")]))
                Sizes = Load16BitPairs(sizes);
            uint startFont = (uint)XML.Element("Sizes").Attribute("StartFont");

            Fonts = new Font[(uint)XML.Element("Sizes").Attribute("NumFont")];
            for (uint i = 0; i < Fonts.Length; i++)
            {
                using (MemoryStream memoryStream = new MemoryStream(file[startFont + i]))
                    using (BinaryReader font = new BinaryReader(memoryStream))
                        Fonts[i] = new Font(font);
            }
            uint startPics = (uint)XML.Element("Sizes").Attribute("StartPics");

            Pics = new byte[(uint)XML.Element("Sizes").Attribute("NumPics")][];
            for (uint i = 0; i < Pics.Length; i++)
            {
                Pics[i] = VSwap.Index2ByteArray(Deplanify(file[startPics + i], Sizes[i][0]), Palette);
            }
        }