Beispiel #1
0
        public LevelEditor(Pos range)
        {
            grid = new GridStruct(range.x, range.y);

            for (int x = 0; x < grid.width; x++)
            {
                for (int y = 0; y < grid.height; y++)
                {
                    grid.SetTile(x, y, Floors.EMPTY_FLOOR, Blocks.EMPTY, Blocks.EMPTY);
                }
            }
            LoadBlocks();
        }
Beispiel #2
0
        /// <summary>
        /// Turn EncodedGridStruct to GridStruct
        /// </summary>
        /// <param name="grid"></param>
        /// <returns></returns>
        public static GridStruct DecodeGrid(this EncodedGridStruct grid)
        {
            GridStruct DecodedGrid = new GridStruct(grid.width, grid.height);

            for (int x = 0; x < grid.width; x++)
            {
                for (int y = 0; y < grid.height; y++)
                {
                    DecodedGrid.grid[x, y] = TileBuilder.Create(Type.GetType(grid.grid[x, y].floor), Type.GetType(grid.grid[x, y].environmentObject), Type.GetType(grid.grid[x, y].gameObject));
                }
            }

            return(DecodedGrid);
        }
Beispiel #3
0
        /// <summary>
        /// Turn GridStruct to EncodedGridStruct
        /// </summary>
        /// <param name="grid"></param>
        /// <returns></returns>
        public static EncodedGridStruct Encode(this GridStruct grid)
        {
            EncodedGridStruct encodedGrid = new EncodedGridStruct(grid.width, grid.height);

            for (int x = 0; x < grid.width; x++)
            {
                for (int y = 0; y < grid.height; y++)
                {
                    encodedGrid.grid[x, y] = new EncodedTileStruct(ObjectToString(grid.grid[x, y].floor), ObjectToString(grid.grid[x, y].environmentObject), ObjectToString(grid.grid[x, y].gameObject));
                }
            }

            return(encodedGrid);
        }
Beispiel #4
0
 public void DestroyGrid()
 {
     grid = new GridStruct(0, 0);
 }
Beispiel #5
0
 public LevelEditor(GridStruct grid)
 {
     this.grid = grid;
 }
Beispiel #6
0
 /// <summary>
 /// Returns json string
 /// </summary>
 /// <param name="grid"></param>
 /// <returns></returns>
 public static string Serialize(this GridStruct grid)
 {
     return(JsonConvert.SerializeObject(grid.Encode(), Formatting.Indented));
 }