Пример #1
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;
        }
Пример #2
0
        private void PaintTileInternal(MapLayer item, System.Drawing.Rectangle dest, int x, int y, System.Drawing.Graphics g)
        {
            short data = item.Data[x, y];
            if (item.Type == MapLayerType.Tile)
            {
                g.DrawImage(
                    this.tileset[data],
                    dest
                );

            }
            else if (item.Type == MapLayerType.HalfBlockShadow)
            {
                for (int shadow = 0; shadow < 4; shadow++)
                {
                    if ((data & (1 << shadow)) != 0)
                    {
                        g.FillRectangle(
                            shadowBrush,
                            dest.X + (shadow % 2) * size.Width / 2,
                            dest.Y + (shadow / 2) * size.Height / 2,
                            size.Width / 2,
                            size.Height / 2
                        );
                    }
                }
            }
            else if (item.Type == MapLayerType.TilesetLabel)
            {
                if (data == -1)
                    return;

                if (data == -2)
                {
                    g.FillRectangle(System.Drawing.Brushes.Black, dest);
                    return;
                }

                if (data >= 0 && item.Storage.ContainsKey(data.ToString()))
                {
                    g.FillRectangle(System.Drawing.Brushes.Black, dest);
                    string s = item.Storage[data.ToString()] as string;
                    System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
                    sf.LineAlignment = System.Drawing.StringAlignment.Center;
                    sf.Alignment = System.Drawing.StringAlignment.Center;
                    g.DrawString(s, this.Font, System.Drawing.Brushes.White, dest, sf);
                }
            }
        }
Пример #3
0
        protected override List <MapLayer> BuildTilePanelData()
        {
            var        ret   = new List <MapLayer>();
            List <int> data  = new List <int>();
            List <int> data2 = new List <int>();

            if (this.images[0] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 16; i++)
                {
                    data.Add(2048 + i * 48 + ((i >= 5 && i % 2 == 1) ? 3 : 47));
                }

                data2.Add(0);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 16, data2);
            }

            if (this.images[1] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 32; i++)
                {
                    data.Add(2816 + i * 48 + 47);
                }

                data2.Add(1);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 32, data2);
            }

            if (this.images[2] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 16; i++)
                {
                    data.Add(4352 + i * 48 + 15);
                }

                data2.Add(2);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 16, data2);
            }

            if (this.images[3] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 48; i++)
                {
                    data.Add(5888 + i * 48 + ((i / 8 % 2 == 1) ? 15 : 47));
                }

                data2.Add(3);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 48, data2);
            }

            if (this.images[4] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 128; i++)
                {
                    data.Add(1536 + i);
                }

                data2.Add(4);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 128, data2);
            }

            if (this.images[5] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 256; i++)
                {
                    data.Add(0 + i);
                }

                data2.Add(5);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 256, data2);
            }

            if (this.images[6] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 256; i++)
                {
                    data.Add(256 + i);
                }

                data2.Add(6);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 256, data2);
            }

            if (this.images[7] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 256; i++)
                {
                    data.Add(512 + i);
                }

                data2.Add(7);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 256, data2);
            }

            if (this.images[8] != null)
            {
                AddTimes(0, 8, data);
                for (int i = 0; i < 256; i++)
                {
                    data.Add(768 + i);
                }

                data2.Add(8);
                AddTimes(-2, 7, data2);
                AddTimes(-1, 256, data2);
            }

            MapLayer layer;

            layer      = new MapLayer();
            layer.Type = MapLayerType.Tile;
            layer.Data = new short[8, data.Count / 8];
            for (int i = 0; i < data.Count; i++)
            {
                layer.Data[i % 8, i / 8] = (short)data[i];
            }
            ret.Add(layer);

            layer      = new MapLayer();
            layer.Type = MapLayerType.TilesetLabel;
            layer.Data = new short[8, data2.Count / 8];
            for (int i = 0; i < data2.Count; i++)
            {
                layer.Data[i % 8, i / 8] = (short)data2[i];
            }
            ret.Add(layer);
            layer.Storage["0"] = "A1";
            layer.Storage["1"] = "A2";
            layer.Storage["2"] = "A3";
            layer.Storage["3"] = "A4";
            layer.Storage["4"] = "A5";
            layer.Storage["5"] = "B";
            layer.Storage["6"] = "C";
            layer.Storage["7"] = "D";
            layer.Storage["8"] = "E";

            return(ret);
        }
Пример #4
0
        protected override List<MapLayer> BuildTilePanelData()
        {
            MapLayer layer = new MapLayer();
            int h = (this.images[0] != null ? this.images[0].Height / this.TileSize.Height : 0);

            layer.Type = MapLayerType.Tile;
            layer.Data = new short[8, 1 + h];
            for (int i = 0; i < 8; i++)
            {
                layer.Data[i, 0] = (short)(48 * i);
            }

            for (int i = 0; i < h * 8; i++)
            {
                layer.Data[i % 8, i / 8 + 1] = (short)(384 + i);
            }
            var ret = new List<MapLayer>();
            ret.Add(layer);
            return ret;
        }