Inheritance: RubyObject, IRubyUserdefinedDumpObject
Beispiel #1
0
        protected override void Save()
        {
            if (!this.infoLoaded)
                return;

            RGSSTable table = new RGSSTable(this.Size.Width, this.Size.Height, this.Layers.Count);
            List<MapLayer> truth = new List<MapLayer>(this.Layers);
            if (truth.Count == 4)
            {
                MapLayer layer = truth[2];
                truth.Remove(layer);
                truth.Add(layer);
            }
            for (int z = 0; z < truth.Count; z++)
            {
                for (int x = 0; x < this.Size.Width; x++)
                {
                    for (int y = 0; y < this.Size.Height; y++)
                    {
                        table[x, y, z] = truth[z].Data[x, y];
                    }
                }
            }
            raw.InstanceVariable["@data"] = table;

            using (var fs = new System.IO.FileStream(this.filename, System.IO.FileMode.Create, System.IO.FileAccess.Write))
            {
                NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(fs, raw);
            }
        }
Beispiel #2
0
        protected override void Save()
        {
            if (!this.infoLoaded)
            {
                return;
            }

            RGSSTable       table = new RGSSTable(this.Size.Width, this.Size.Height, this.Layers.Count);
            List <MapLayer> truth = new List <MapLayer>(this.Layers);

            if (truth.Count == 4)
            {
                MapLayer layer = truth[2];
                truth.Remove(layer);
                truth.Add(layer);
            }
            for (int z = 0; z < truth.Count; z++)
            {
                for (int x = 0; x < this.Size.Width; x++)
                {
                    for (int y = 0; y < this.Size.Height; y++)
                    {
                        table[x, y, z] = truth[z].Data[x, y];
                    }
                }
            }
            raw.InstanceVariable["@data"] = table;

            using (var fs = new System.IO.FileStream(this.filename, System.IO.FileMode.Create, System.IO.FileAccess.Write))
            {
                NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(fs, raw);
            }
        }
Beispiel #3
0
        private void LoadInfo()
        {
            RGSSTable data;

            infoLoaded = true;

            raw            = NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(new System.IO.FileStream(this.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)) as RubyObject;
            this.TilesetID = (int)raw.InstanceVariable["@tileset_id"] - 1;
            var j = raw.InstanceVariable["@data"] as NekoKun.Serialization.RubyMarshal.RubyUserdefinedDumpObject;

            data      = new RGSSTable(j.DumpedObject as byte[]);
            this.Size = new System.Drawing.Size((int)raw.InstanceVariable["@width"], (int)raw.InstanceVariable["@height"]);

            this.Layers = new List <MapLayer>();
            for (int z = 0; z < data.ZSize; z++)
            {
                MapLayer layer = new MapLayer();
                layer.Data = new short[this.Size.Width, this.Size.Height];
                for (int x = 0; x < this.Size.Width; x++)
                {
                    for (int y = 0; y < this.Size.Height; y++)
                    {
                        layer.Data[x, y] = data[x, y, z];
                    }
                }
                layer.Type = MapLayerType.Tile;

                this.Layers.Add(layer);
            }

            if (this.Layers.Count == 4)
            {
                MapLayer layer = this.Layers[3];
                this.Layers.Remove(layer);
                this.Layers.Insert(2, layer);

                layer.Type = MapLayerType.HalfBlockShadow;
            }

            raw.InstanceVariable["@data"] = null;
        }
Beispiel #4
0
        private void LoadInfo()
        {
            RGSSTable data;
            infoLoaded = true;

            raw = NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(new System.IO.FileStream(this.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)) as RubyObject;
            this.TilesetID = (int)raw.InstanceVariable["@tileset_id"] - 1;
            var j = raw.InstanceVariable["@data"] as NekoKun.Serialization.RubyMarshal.RubyUserdefinedDumpObject;
            data = new RGSSTable(j.DumpedObject as byte[]);
            this.Size = new System.Drawing.Size((int)raw.InstanceVariable["@width"], (int)raw.InstanceVariable["@height"]);

            this.Layers = new List<MapLayer>();
            for (int z = 0; z < data.ZSize; z++)
            {
                MapLayer layer = new MapLayer();
                layer.Data = new short[this.Size.Width, this.Size.Height];
                for (int x = 0; x < this.Size.Width; x++)
                {
                    for (int y = 0; y < this.Size.Height; y++)
                    {
                        layer.Data[x, y] = data[x, y, z];
                    }
                }
                layer.Type = MapLayerType.Tile;

                this.Layers.Add(layer);
            }

            if (this.Layers.Count == 4)
            {
                MapLayer layer = this.Layers[3];
                this.Layers.Remove(layer);
                this.Layers.Insert(2, layer);

                layer.Type = MapLayerType.HalfBlockShadow;
            }

            raw.InstanceVariable["@data"] = null;
        }