public void IntLoadWorldData() { if (File.Exists(WorldDataPath + "gen_" + SettingWorldName + ".json")) { string jsonLoadGen = File.ReadAllText(WorldDataPath + "gen_" + SettingWorldName + ".json"); SaveWorldGenData = JsonUtility.FromJson <JAWGSaveWorldGenData>(jsonLoadGen); SettingWorldSize = SaveWorldGenData.s_WorldSize; SettingWorldOffset = SaveWorldGenData.s_WorldOffset; SettingChunkSize = SaveWorldGenData.s_ChunkSize; WorldSeed = SaveWorldGenData.s_WorldSeed; Debug.Log("World_GenData Json Loaded Succesfully"); } else { Debug.LogError("Missing WorldGenData File at: " + WorldDataPath + "gen_" + SettingWorldName + ".json"); Debug.Break(); } if (File.Exists(WorldDataPath + "run_" + SettingWorldName + ".json")) { string jsonLoadRun = File.ReadAllText(WorldDataPath + "run_" + SettingWorldName + ".json"); SaveWorldRuntimeData = JsonUtility.FromJson <JAWGSaveWorldRuntimeData>(jsonLoadRun); CurrentWorldTimeMinutes = SaveWorldRuntimeData.s_CurrentMinutes; CurrentWorldTimeHours = SaveWorldRuntimeData.s_CurrentHours; CurrentWorldTimeDays = SaveWorldRuntimeData.s_CurrentDays; SettingCycleDayNight = SaveWorldRuntimeData.s_GameRuleDoDayCycle; Player.transform.position = new Vector3(SaveWorldRuntimeData.s_PlayerCoordX, SaveWorldRuntimeData.s_PlayerCoordY, 0); Debug.Log("World_RunData Json Loaded Succesfully"); } else { Debug.LogError("Missing WorldRuntimeData File at: " + WorldDataPath + "run_" + SettingWorldName + ".json"); Debug.Break(); } if (File.Exists(WorldDataPath + "res_" + SettingWorldName + ".json")) { string jsonLoadRes = File.ReadAllText(WorldDataPath + "res_" + SettingWorldName + ".json"); SaveResourceObjectsData = JsonUtility.FromJson <ResourceObject[]>(jsonLoadRes); //Load Saved Data using the Saveable Format ResourceObject[] ResourceObjectsArray = new ResourceObject[SaveResourceObjectsData.Length]; for (int res = 0; res < SaveResourceObjectsData.Length; res++) { ResourceObjectsArray[res].coordX = SaveResourceObjectsData[res].coordX; ResourceObjectsArray[res].coordY = SaveResourceObjectsData[res].coordY; ResourceObjectsArray[res].BiomeID = SaveResourceObjectsData[res].BiomeID; ResourceObjectsArray[res].SurfaceObjectID = SaveResourceObjectsData[res].SurfaceObjectID; } //Convert Saveable format to the useable format WorldResourcesReadable = new GameObject[WorldSizeX, WorldSizeY]; for (int res = 0; res < ResourceObjectsArray.Length; res++) { WorldResourcesReadable[ResourceObjectsArray[res].coordX, ResourceObjectsArray[res].coordY] = BiomesList[ResourceObjectsArray[res].BiomeID].SurfaceObjects[ResourceObjectsArray[res].SurfaceObjectID].ResourceObj; } Debug.Log("World_ResData Json Loaded Succesfully"); } else { Debug.LogError("Missing WorldResourcesData File at: " + WorldDataPath + "res_" + SettingWorldName + ".json"); Debug.Break(); } if (File.Exists(WorldMapPath + "map_Landmass.png") && File.Exists(WorldMapPath + "map_Biomes.png")) { byte[] bytes_Landmass; byte[] bytes_Biomes; bytes_Landmass = File.ReadAllBytes(WorldMapPath + "map_Landmass.png"); bytes_Biomes = File.ReadAllBytes(WorldMapPath + "map_Biomes.png"); map_Landmass = new Texture2D(2, 2); map_Biomes = new Texture2D(2, 2); map_Landmass.LoadImage(bytes_Landmass); map_Biomes.LoadImage(bytes_Biomes); map_Landmass.filterMode = FilterMode.Point; map_Biomes.filterMode = FilterMode.Point; Debug.Log("World_Map png Loaded Succesfully"); } else { Debug.LogError("Missing WorldGenMap Files at: " + WorldMapPath + "map_Landmass.png" + "\n" + WorldMapPath + "map_Biomes.png"); Debug.Break(); } }
public void IntLoadWorldData() { if (File.Exists(WorldDataPath + "gen_" + SettingWorldName + ".json")) { string jsonLoad = File.ReadAllText(WorldDataPath + "gen_" + SettingWorldName + ".json"); SaveWorldGenData = JsonUtility.FromJson <JAWGSaveWorldGenData>(jsonLoad); SettingWorldSize = SaveWorldGenData.s_WorldSize; SettingWorldOffset = SaveWorldGenData.s_WorldOffset; SettingChunkSize = SaveWorldGenData.s_ChunkSize; WorldSeed = SaveWorldGenData.s_WorldSeed; Debug.Log("World_GenData Json Loaded Succesfully"); } else { Debug.LogError("Missing WorldGenData File at: " + WorldDataPath + "gen_" + SettingWorldName + ".json"); Debug.Break(); } if (File.Exists(WorldDataPath + "run_" + SettingWorldName + ".json")) { string jsonLoad = File.ReadAllText(WorldDataPath + "run_" + SettingWorldName + ".json"); SaveWorldRuntimeData = JsonUtility.FromJson <JAWGSaveWorldRuntimeData>(jsonLoad); CurrentWorldTimeMinutes = SaveWorldRuntimeData.s_CurrentMinutes; CurrentWorldTimeHours = SaveWorldRuntimeData.s_CurrentHours; CurrentWorldTimeDays = SaveWorldRuntimeData.s_CurrentDays; SettingCycleDayNight = SaveWorldRuntimeData.s_GameRuleDoDayCycle; Player.transform.position = new Vector3(SaveWorldRuntimeData.s_PlayerCoordX, SaveWorldRuntimeData.s_PlayerCoordY, 0); Debug.Log("World_RunData Json Loaded Succesfully"); } else { Debug.LogError("Missing WorldRuntimeData File at: " + WorldDataPath + "run_" + SettingWorldName + ".json"); Debug.Break(); } if (File.Exists(WorldMapPath + "map_Landmass.png") && File.Exists(WorldMapPath + "map_Biomes.png") && File.Exists(WorldMapPath + "map_Resources.png")) { byte[] bytes_Landmass; byte[] bytes_Biomes; byte[] bytes_Resources; bytes_Landmass = File.ReadAllBytes(WorldMapPath + "map_Landmass.png"); bytes_Biomes = File.ReadAllBytes(WorldMapPath + "map_Biomes.png"); bytes_Resources = File.ReadAllBytes(WorldMapPath + "map_Resources.png"); map_Landmass = new Texture2D(2, 2); map_Biomes = new Texture2D(2, 2); map_Resources = new Texture2D(2, 2); map_Landmass.LoadImage(bytes_Landmass); map_Biomes.LoadImage(bytes_Biomes); map_Resources.LoadImage(bytes_Resources); map_Landmass.filterMode = FilterMode.Point; map_Biomes.filterMode = FilterMode.Point; map_Resources.filterMode = FilterMode.Point; Debug.Log("World_Map png Loaded Succesfully"); } else { Debug.LogError("Missing WorldGenMap Files at: " + WorldMapPath + "map_Landmass.png" + "\n" + WorldMapPath + "map_Biomes.png" + "\n" + WorldMapPath + "map_Resources.png"); Debug.Break(); } }