예제 #1
0
        internal void SetSelectedTile(Tile[,] SelectedTiles, System.Drawing.Rectangle SelectedArea)
        {
            GLB_Data.SelectedTiles = new Tile[SelectedTiles.GetLength(0), SelectedTiles.GetLength(1)];

            // Copy all the selected tiles
            for (int id_y = 0; id_y < SelectedTiles.GetLength(1); id_y++)
            {
                for (int id_x = 0; id_x < SelectedTiles.GetLength(0); id_x++)
                {
                    GLB_Data.SelectedTiles[id_x, id_y].grid_location    = SelectedTiles[id_x, id_y].grid_location;
                    GLB_Data.SelectedTiles[id_x, id_y].id               = SelectedTiles[id_x, id_y].id;
                    GLB_Data.SelectedTiles[id_x, id_y].walkable         = SelectedTiles[id_x, id_y].walkable;
                }
            }
        }
예제 #2
0
        private void ResizeMap(int Depth, int Width, int Height)
        {
            // temp copy
            Tile[,,] aux_tile_map       = (Tile[,,]) GLB_Data.TileMap.Clone();
            Tile[,] aux_walk_layer      = new Tile[GLB_Data.MapSize.Width, GLB_Data.MapSize.Height];
            Int32[,] aux_terrain_layer  = new Int32[GLB_Data.MapSize.Width, GLB_Data.MapSize.Height];

            // Make a copy of the walk layer layout  & terrain layer
            for (int id_y = 0; id_y < GLB_Data.MapSize.Height; id_y++)
            {
                for (int id_x = 0; id_x < GLB_Data.MapSize.Width; id_x++)
                {
                    aux_walk_layer[id_x, id_y].walkable = GLB_Data.TileMap[GLB_Data.MapSize.Depth, id_x, id_y].walkable;
                    //aux_terrain_layer[id_x, id_y] = GLB_Data.TerrainLayout[id_x, id_y];
                }
            }

            // Assign new tilemap dimensions
            GLB_Data.MapSize.Depth  = Depth;
            GLB_Data.MapSize.Width  = Width;
            GLB_Data.MapSize.Height = Height;

            GLB_Data.TileMap = new Tile[Depth + Constants.WALK_LAYER, Width, Height];
            GLB_Data.TerrainLayout = new Int32[GLB_Data.MapSize.Width, GLB_Data.MapSize.Height];
            main_form.InitTileMap();
            main_form.ShowCurrentLayer();

            for (int id_z = 0; id_z < GLB_Data.MapSize.Depth; id_z++)
            {
                for (int id_y = 0; id_y < GLB_Data.MapSize.Height; id_y++)
                {
                    for (int id_x = 0; id_x < GLB_Data.MapSize.Width; id_x++)
                    {
                        if ( id_z < aux_tile_map.GetLength(0) &&
                             id_x < aux_tile_map.GetLength(1) &&
                             id_y < aux_tile_map.GetLength(2) )
                        {
                            // Copy existing data
                            GLB_Data.TileMap[id_z, id_x, id_y].id               = aux_tile_map[id_z, id_x, id_y].id;
                            GLB_Data.TileMap[id_z, id_x, id_y].grid_location    = aux_tile_map[id_z, id_x, id_y].grid_location;
                            if (GLB_Data.TileMap[id_z, id_x, id_y].id == Constants.NULL_TILE)
                            {
                                GLB_Data.TileMap[id_z, id_x, id_y].texture_location = new XNA.Point();
                            }
                            else
                            {
                                GLB_Data.TileMap[id_z, id_x, id_y].texture_location = aux_tile_map[id_z, id_x, id_y].texture_location;
                            }
                        }
                    }
                }
            }

            // copy previous walk layout && terrain layout
            for (int id_y = 0; id_y < aux_walk_layer.GetLength(1); id_y++)
            {
                for (int id_x = 0; id_x < aux_walk_layer.GetLength(0); id_x++)
                {
                    if (id_x < GLB_Data.MapSize.Width && id_y < GLB_Data.MapSize.Height)
                    {
                        GLB_Data.TileMap[GLB_Data.TileMap.GetLength(0) - 1, id_x, id_y].walkable = aux_walk_layer[id_x, id_y].walkable;
                        GLB_Data.TerrainLayout[id_x, id_y] = aux_terrain_layer[id_x, id_y];
                    }
                }
            }
        }
예제 #3
0
        /////////////////////////////////////////////////////////////////////////////////////////
        // SetImage(FileName, WalkData)
        // Overloaded method, creates the new tile palette but recovers loaded walk palette data
        /////////////////////////////////////////////////////////////////////////////////////////
        internal void SetImage(string FileName, Tile[,] WalkData)
        {
            this.SetImage(FileName);

            for (int id_y = 0; id_y < WalkData.GetLength(1); id_y++)
            {
                for (int id_x = 0; id_x < WalkData.GetLength(0); id_x++)
                {
                    GLB_Data.TilePalette[id_x, id_y].walkable = WalkData[id_x, id_y].walkable;
                }
            }
        }