| | |
| | | |
| | | if (SaveSystem.isGameLoaded) |
| | | { |
| | | SaveDataMap mapState = SaveSystem.LoadMapState(); |
| | | SaveDataMap mapState = GetComponent<SaveSystemManager>().GetMapStateFromSave(); |
| | | if (mapState != null && mapState.fogOfWarData != null) |
| | | { |
| | | GetComponent<FogOfWar>().LoadFromSaveData(mapState.fogOfWarData); |
| | | LoadFromSaveData(mapState.fogOfWarData); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public FogOfWarData GetSaveData() |
| | | public (TileBase[,] discoveredFog, TileBase fogTile, FogLevel[] fogLevels) GetSaveValues() |
| | | { |
| | | FogOfWarData saveData = new FogOfWarData(); |
| | | |
| | | for (int x = 0; x < discoveredFog.GetLength(0); x++) |
| | | { |
| | | for (int y = 0; y < discoveredFog.GetLength(1); y++) |
| | | { |
| | | TileBase currentTile = discoveredFog[x, y]; |
| | | if (currentTile == null || currentTile != fogTile) // Only save revealed tiles |
| | | { |
| | | FogTileData tileData = new FogTileData |
| | | { |
| | | x = x, |
| | | y = y, |
| | | fogLevelIndex = currentTile == null ? -1 : System.Array.FindIndex(fogLevels, f => f.tile == currentTile) |
| | | }; |
| | | saveData.discoveredTiles.Add(tileData); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return saveData; |
| | | return (discoveredFog,fogTile, fogLevels); |
| | | } |
| | | |
| | | public void LoadFromSaveData(FogOfWarData saveData) |