示例#1
0
文件: frmMain.cs 项目: farlei/libEGL
        private void ExportMap()
        {
            try
            {
                if (region != null)
                {
                    project = new Project();

                    List<int> list_event = new List<int>();
                    List<int> tilesets = new List<int>();

                    foreach (Layer lyr in region.layer.Values)
                    {
                        foreach (Dictionary<int, int> events in lyr.evento.Values)
                        {
                            foreach (int event_code in events.Values)
                            {
                                if (!list_event.Contains(event_code))
                                    list_event.Add(event_code);
                            }
                        }
                        foreach (Dictionary<int, Tile> tiles in lyr.tiles.Values)
                        {
                            foreach (Tile tl in tiles.Values)
                            {
                                if (!tilesets.Contains(tl.tileset_code))
                                    tilesets.Add(tl.tileset_code);
                            }
                        }
                    }

                    foreach (int event_code in list_event)
                        if (world.events.ContainsKey(event_code))
                            project.add_event(event_code, world.events[event_code]);

                    foreach (int tileset_code in tilesets)
                        if (world.tilesets.ContainsKey(tileset_code))
                            project.add_tile_set(world.tilesets[tileset_code]);

                    project.add_region(region);

                    using (Stream stream = File.Open(default_map, FileMode.Create, FileAccess.ReadWrite))
                    {
                        BinaryFormatter bin = new BinaryFormatter();
                        bin.Serialize(stream, project);
                    }
                }
            }
            catch (IOException ex)
            {
                string error = ex.Message;
            }
        }
示例#2
0
文件: frmMain.cs 项目: farlei/libEGL
        private void Save()
        {
            try
            {
                project = new Project();
                foreach (int event_code in world.events.Keys)
                    project.add_event(event_code, world.events[event_code]);

                foreach (Tileset tile in world.tilesets.Values)
                    project.add_tile_set(tile);

                foreach (Region region in world.regions.Values)
                    project.add_region(region);

                using (Stream stream = File.Open(default_save, FileMode.Create, FileAccess.ReadWrite))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    bin.Serialize(stream, project);
                }

                this.Text = "Editor Map 2D - " + default_save;
            }
            catch (IOException ex)
            {
                string error = ex.Message;
            }
        }