Ejemplo n.º 1
0
        public void add_region(Region region)
        {
            try
            {
                if (region == null)
                    return;

                ProjectRegion tmp = new ProjectRegion();

                tmp.name = region.name;
                tmp.setor = new int[4];
                tmp.setor[0] = region.map_width;
                tmp.setor[1] = region.map_height;
                tmp.setor[2] = region.tile_width;
                tmp.setor[3] = region.tile_height;

                tmp.layer = new ProjectLayer[region.layer.Count];
                int i;
                for (i = 0; i < region.layer.Count; i++)
                {
                    Layer layer = region.layer[i];
                    ProjectLayer tmpLayer = new ProjectLayer();

                    tmpLayer.name = layer.name;
                    tmpLayer.visible = layer.visible;

                    int num = 0;
                    foreach (Dictionary<int, Tile> list in layer.tiles.Values)
                        num += list.Count;

                    tmpLayer.tiles = new ProjectTile[num];

                    int j = 0;
                    foreach (int x in layer.tiles.Keys)
                    {
                        Dictionary<int, Tile> list = layer.tiles[x];
                        foreach (int y in list.Keys)
                        {
                            Tile tile = list[y];
                            ProjectTile tmpTile = new ProjectTile();
                            tmpTile.point = new int[2];
                            tmpTile.point[0] = x;
                            tmpTile.point[1] = y;
                            tmpTile.tile_code = tile.tile_code;
                            tmpTile.tile_crop = tile.tile_crop;
                            tmpTile.tileset_code = tile.tileset_code;

                            tmpLayer.tiles[j] = tmpTile;

                            j++;
                        }
                    }

                    num = 0;
                    foreach (Dictionary<int, int> list in layer.evento.Values)
                        num += list.Count;

                    tmpLayer.events = new int[num, 3];

                    j = 0;
                    foreach (int x in layer.evento.Keys)
                    {
                        Dictionary<int, int> list = layer.evento[x];
                        foreach (int y in list.Keys)
                        {
                            int code = list[y];

                            tmpLayer.events[j, 0] = code;
                            tmpLayer.events[j, 1] = x;
                            tmpLayer.events[j, 2] = y;

                            j++;
                        }
                    }

                    tmp.layer[i] = tmpLayer;
                }
                regions.Add(tmp);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
Ejemplo n.º 2
0
        public void add_region(Region region)
        {
            try
            {
                if (region == null)
                {
                    return;
                }

                ProjectRegion tmp = new ProjectRegion();

                tmp.name     = region.name;
                tmp.setor    = new int[4];
                tmp.setor[0] = region.map_width;
                tmp.setor[1] = region.map_height;
                tmp.setor[2] = region.tile_width;
                tmp.setor[3] = region.tile_height;

                tmp.layer = new ProjectLayer[region.layer.Count];
                int i;
                for (i = 0; i < region.layer.Count; i++)
                {
                    Layer        layer    = region.layer[i];
                    ProjectLayer tmpLayer = new ProjectLayer();

                    tmpLayer.name    = layer.name;
                    tmpLayer.visible = layer.visible;

                    int num = 0;
                    foreach (Dictionary <int, Tile> list in layer.tiles.Values)
                    {
                        num += list.Count;
                    }

                    tmpLayer.tiles = new ProjectTile[num];

                    int j = 0;
                    foreach (int x in layer.tiles.Keys)
                    {
                        Dictionary <int, Tile> list = layer.tiles[x];
                        foreach (int y in list.Keys)
                        {
                            Tile        tile    = list[y];
                            ProjectTile tmpTile = new ProjectTile();
                            tmpTile.point        = new int[2];
                            tmpTile.point[0]     = x;
                            tmpTile.point[1]     = y;
                            tmpTile.tile_code    = tile.tile_code;
                            tmpTile.tile_crop    = tile.tile_crop;
                            tmpTile.tileset_code = tile.tileset_code;

                            tmpLayer.tiles[j] = tmpTile;

                            j++;
                        }
                    }

                    num = 0;
                    foreach (Dictionary <int, int> list in layer.evento.Values)
                    {
                        num += list.Count;
                    }

                    tmpLayer.events = new int[num, 3];

                    j = 0;
                    foreach (int x in layer.evento.Keys)
                    {
                        Dictionary <int, int> list = layer.evento[x];
                        foreach (int y in list.Keys)
                        {
                            int code = list[y];

                            tmpLayer.events[j, 0] = code;
                            tmpLayer.events[j, 1] = x;
                            tmpLayer.events[j, 2] = y;

                            j++;
                        }
                    }

                    tmp.layer[i] = tmpLayer;
                }
                regions.Add(tmp);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }