public void SetupReachedLevelParameters(Level.LevelData reachedLevelData) { int reachedLevelIndex = reachedLevelData.levelIndex; Debug.Log("SetupReachedLevelParameters [" + reachedLevelIndex + "]"); LevelManager.instance.SetupGameAtLevelIndex(reachedLevelIndex); }
public GameSaveData(GameManager.GeneralGameData generalGameData, Building.BuildingData[] buildingsData, SpaceshipManager.SpaceshipData[] spaceshipsData, Level.LevelData reachedLevelData, ResourcesManager.ResourceData[] resourcesData, BuildingManager.UnlockedBuildingData[] unlockedBuildingsData, TechTreeManager.TechnologyData[] technologiesData, MegaStructureManager.MegaStructuresData megaStructuresData, PopulationManager.PopulationData populationData) { this.generalGameData = generalGameData; this.buildingsData = buildingsData; this.spaceshipsData = spaceshipsData; this.reachedLevelData = reachedLevelData; this.resourcesData = resourcesData; this.unlockedBuildingsData = unlockedBuildingsData; this.technologiesData = technologiesData; this.megaStructuresData = megaStructuresData; this.populationData = populationData; }
public void SetupSavedData() { Debug.Log("SetupSavedData"); Building.BuildingData[] buildingsData = gameSetupParameters.gameSaveData.buildingsData; GameManager.GeneralGameData generalGameData = gameSetupParameters.gameSaveData.generalGameData; SpaceshipManager.SpaceshipData[] spaceshipsData = gameSetupParameters.gameSaveData.spaceshipsData; Level.LevelData reachedLevelData = gameSetupParameters.gameSaveData.reachedLevelData; ResourcesManager.ResourceData[] resourcesData = gameSetupParameters.gameSaveData.resourcesData; BuildingManager.UnlockedBuildingData[] unlockedBuildingsData = gameSetupParameters.gameSaveData.unlockedBuildingsData; TechTreeManager.TechnologyData[] technologiesData = gameSetupParameters.gameSaveData.technologiesData; MegaStructureManager.MegaStructuresData megaStructuresData = gameSetupParameters.gameSaveData.megaStructuresData; PopulationManager.PopulationData populationData = gameSetupParameters.gameSaveData.populationData; if (buildingsData != null) { SetupSavedBuildings(buildingsData); } if (generalGameData != null) { SetupGeneralParameters(generalGameData); } if (reachedLevelData != null) { SetupReachedLevelParameters(reachedLevelData); } if (resourcesData != null) { SetupResourcesData(resourcesData); } if (technologiesData != null) { SetupTechnologies(technologiesData); } if (spaceshipsData != null) { SetupSpaceships(spaceshipsData); } if (megaStructuresData != null) { SetupMegaStructures(megaStructuresData); } if (populationData != null) { SetupPopulationData(populationData); } }
public void SaveGameStateIntoSlot(int saveGameSlotIndex) { Debug.Log("Saving game state..."); string saveTime = DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"); GameManager.GeneralGameData generalData = GatherGeneralGameData(); Building.BuildingData[] buildingDatas = GatherBuildingsData(); SpaceshipManager.SpaceshipData[] spaceshipsData = GatherSpaceshipsData(); Level.LevelData reachedLevelData = GatherReachedLevelData(); ResourcesManager.ResourceData[] resourcesData = GatherResourcesData(); BuildingManager.UnlockedBuildingData[] unlockedBuildingsData = GatherUnlockedBuildingsData(); TechTreeManager.TechnologyData[] technologiesData = GatherTechnologiesData(); MegaStructureManager.MegaStructuresData megaStructuresData = GatherMegaStructuresData(); PopulationManager.PopulationData populationData = GatherPopulationData(); // Build Game Save Data GameSaveData gameSaveData = new GameSaveData(generalData, buildingDatas, spaceshipsData, reachedLevelData, resourcesData, unlockedBuildingsData, technologiesData, megaStructuresData, populationData); int currentLevelReached = LevelManager.instance.currentLevelNumber; // Binary Formatter + Stream BinaryFormatter bf = new BinaryFormatter(); string fileName = (gameSaveFileName + saveGameSlotIndex + gameSaveFileExtension); Debug.Log("File Name: " + fileName); FileStream stream = new FileStream(Application.persistentDataPath + "/" + fileName, FileMode.Create); // Write chosen save file bf.Serialize(stream, gameSaveData); stream.Close(); // Update SaveFilesInfo general object SavedGameFilesInfoData.SaveFileInfo saveFileInfo = new SavedGameFilesInfoData.SaveFileInfo(saveGameSlotIndex, true, saveTime); Debug.Log("Created new SaveFileInfo | SlotIndex [" + saveGameSlotIndex + "] | IsUsed [" + true + "] | SaveTime [" + saveTime + "]"); globalSavedGameInfoData.UpdateSavedGameFilesInfoForIndex(saveFileInfo); // Update indicator in save panel SaveGamePanel.instance.UpdateSaveSlotInfo(saveFileInfo); // Write game saves info file WriteSaveFilesInfo(); }
public Level.LevelData BuildReachedLevelData() { Level.LevelData reachedLevelData = new Level.LevelData(currentLevelNumber); return(reachedLevelData); }