/// <summary> /// Convert the grid on the screen to a map object /// </summary> /// <returns></returns> private SavedMap ConvertGridToMap() { SavedMap map = new SavedMap(col, row); for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { map.SetTile(i, j, GetTileType(i, j)); } } return(map); }
/// <summary> /// Load a map from file /// </summary> /// <param name="fileName"></param> /// <param name="coustomMap"></param> /// <returns> false if the file dont exist otherwise true</returns> public bool LoadMap(string fileName, bool coustomMap = false) { if (!IsFileExist(fileName, coustomMap)) { return(false); } BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.OpenRead(GetFilePath(coustomMap) + fileName); map = (SavedMap)bf.Deserialize(file); file.Close(); return(true); }
/// <summary> /// Convert Map to the grid the mapeditor /// </summary> /// <param name="map"></param> private void ConvertMapToGrid(SavedMap map) { col = map.GetCol(); row = map.GetRow(); initGridLayout(); for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { GameObject newTile = GameObjectUtil.Instantiate(genricMapEditorButton, Vector2.zero, transform); newTile.transform.localScale = Vector3.one; newTile.GetComponent <TileMapEditorButton>().ChangeTile(map.GetTile(i, j)); } } }
public void SetupSceneMap(SavedMap newMap) { initMap(); map.LoadMapFromSavedMap(newMap); InitBoard(); }
public MapSaver(TextAsset asset) { map = DeserializeFromText(asset); CheckAndCreateFolders(); }
public MapSaver(SavedMap map) { this.map = map; CheckAndCreateFolders(); }
public MapSaver(int col, int row) { map = new SavedMap(col, row); CheckAndCreateFolders(); }
public void LoadMapFromSavedMap(SavedMap map) { initMapFormArray(map.GetMap()); mirroMapViaY(); }