void Update() { if (GetComponent <Canvas>().enabled&& doUpdate) { activeContracts = PlayerContracts.GetActiveContractsList(); ShowContracts(); doUpdate = false; } else if (!GetComponent <Canvas>().enabled&& !doUpdate) { doUpdate = true; for (int i = contractsToRemove.Count - 1; i >= 0; i--) { activeContracts.RemoveAt(contractsToRemove[i]); } contractsToRemove.Clear(); PlayerContracts.SetActiveContractsList(activeContracts); } }
void UpdateContracts() { List <LumberContract> activeContracts = PlayerContracts.GetActiveContractsList(); int activeCount = activeContracts.Count; for (int i = 0; i < contractsContent.childCount; i++) { contractsContent.GetChild(i).gameObject.SetActive(i < activeCount); } for (int j = 0; j < activeCount; j++) { contractsContent.GetChild(j).GetChild(0).GetComponent <Text>().text = activeContracts[j].GetCompletionDeadline().ToString(); contractsContent.GetChild(j).GetChild(1).GetComponent <Text>().text = "Quality Grade: " + activeContracts[j].GetRequiredLumber().GetTreeGrade(); contractsContent.GetChild(j).GetChild(2).GetComponent <Text>().text = activeContracts[j].GetRequiredLumber().StringWithoutQuality(); contractsContent.GetChild(j).GetChild(3).GetComponent <Text>().text = activeContracts[j].GetPayout().ToString(); contractsContent.GetChild(j).GetChild(6).gameObject.SetActive(activeContracts[j].IsExpired()); contractsContent.GetChild(j).GetChild(7).gameObject.SetActive(!activeContracts[j].IsExpired()); contractsContent.GetChild(j).GetChild(8).gameObject.SetActive(false); } }
void Start() { activeContracts = PlayerContracts.GetActiveContractsList(); }
public static void Save() { Debug.Log("Save Slot: " + currentSaveSlot); BinaryFormatter data = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + folderPath + currentSaveSlot + saveSlotStrings[currentSaveSlot - 1]); SaveableData saveData = new SaveableData(); //-----------------------Setting Save Data--------------------------------------------- saveData.activeContracts = PlayerContracts.GetActiveContractsList(); saveData.availableContracts = AvailableContracts.GetAvailableContracts(); saveData.availableContractsToRemove = AvailableContracts.GetContractsToRemove(); saveData.didDailyGeneration = TimeManager.GetDidDailyGeneration(); saveData.averageContractDifficulty = AvailableContracts.GetAverageContractDifficulty(); saveData.pastGeneratedContractDifficulties = AvailableContracts.GetPastGeneratedContractDifficuties(); saveData.currentEnergy = PlayerEnergy.GetCurrentEnergyValue(); saveData.currentCurrency = PlayerResources.GetCurrentCurrencyValue(); saveData.currentBuildingMaterials = PlayerResources.GetCurrentBuildingMaterialsValue(); saveData.currentToolParts = PlayerResources.GetCurrentToolPartsValue(); saveData.currentBookPages = PlayerResources.GetCurrentBookPagesValue(); saveData.homesteadTreesCount = HomesteadStockpile.GetAllTreesCount(); saveData.homesteadLogsCount = HomesteadStockpile.GetAllLogsCount(); saveData.homesteadFirewoodCount = HomesteadStockpile.GetAllFirewoodCount(); saveData.ownedTools = PlayerTools.GetOwnedToolsList(); saveData.currentlyEquippedTool = PlayerTools.GetCurrentlyEquippedTool(); saveData.efficiencySkill = PlayerSkills.GetEfficiencySkill(); saveData.contractsSkill = PlayerSkills.GetContractsSkill(); saveData.currencySkill = PlayerSkills.GetCurrencySkill(); saveData.energySkill = PlayerSkills.GetEnergySkill(); saveData.buildingMaterialsSkill = PlayerSkills.GetBuildingMaterialsSkill(); saveData.toolPartsSkill = PlayerSkills.GetToolPartsSkill(); saveData.bookPagesSkill = PlayerSkills.GetBookPagesSkill(); saveData.lumberTreesSkill = PlayerSkills.GetLumberTreesSkill(); saveData.lumberLogsSkill = PlayerSkills.GetLumberLogsSkill(); saveData.lumberFirewoodSkill = PlayerSkills.GetLumberFirewoodSkill(); saveData.bedRoom = PlayerRooms.GetBedRoom(); saveData.kitchenRoom = PlayerRooms.GetKitchenRoom(); saveData.officeRoom = PlayerRooms.GetOfficeRoom(); saveData.studyRoom = PlayerRooms.GetStudyRoom(); saveData.workshopRoom = PlayerRooms.GetWorkshopRoom(); saveData.coffeeMakerAddition = PlayerAdditions.GetCoffeeMakerAddition(); saveData.fireplaceAddition = PlayerAdditions.GetFireplaceAddition(); saveData.frontPorchAddition = PlayerAdditions.GetFrontPorchAddition(); saveData.woodworkingBenchAddition = PlayerAdditions.GetWoodworkingBenchAddition(); saveData.currentTime = TimeManager.GetCurrentTime(); saveData.lastSceneName = SceneManager.GetActiveScene().name; Vector3 spawnHolder = SpawnLocations.GetSpawnForLoad(SceneManager.GetActiveScene().name); saveData.lastSceneSpawnLocation = new float[3] { spawnHolder.x, spawnHolder.y, spawnHolder.z }; //-----------------------Done Setting Data--------------------------------------------- data.Serialize(file, saveData); file.Close(); Debug.Log("Saved here: " + Application.persistentDataPath); }