Exemple #1
0
        public bool Export(String File)
        {
            Burntime.Platform.IO.File file = new Burntime.Platform.IO.File(new FileStream(File, FileMode.Open, FileAccess.ReadWrite));
            Burntime.Data.BurnGfx.Map map  = new Burntime.Data.BurnGfx.Map(file);

            map.width  = Size.Width;
            map.height = Size.Height;
            // check size
            map.data = new ushort[Size.Width * Size.Height];

            for (int y = 0; y < Size.Height; y++)
            {
                for (int x = 0; x < Size.Width; x++)
                {
                    map.data[x + y * Size.Width] = (ushort)(tiles[x, y].SubSet + (((ushort)tiles[x, y].ID) << 8));
                }
            }

            // check door count
            if (map.Doors.Count != entrances.Count)
            {
                MessageBox.Show("Entrance count must be the same as the original.", "Export", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            for (int i = 0; i < map.Doors.Count; i++)
            {
                map.Doors[i].Area = new Burntime.Platform.Rect(entrances[i].Rect.Left, entrances[i].Rect.Top, entrances[i].Rect.Width, entrances[i].Rect.Height);
            }

            file.Seek(0, Burntime.Platform.IO.SeekPosition.Begin);
            map.SaveToRaw(file);

            file.Flush();
            file.Close();

            return(true);
        }