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(); }
/// <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); }
/// <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); }
public void DestroyGrid() { grid = new GridStruct(0, 0); }
public LevelEditor(GridStruct grid) { this.grid = grid; }
/// <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)); }