public void RemoveContract() { Transform contractObj = EventSystem.current.currentSelectedGameObject.transform.parent.transform.parent; contractObj.GetChild(8).gameObject.SetActive(false); // string contractName = EventSystem.current.currentSelectedGameObject.transform.parent.transform.parent.name; int contractNumber = int.Parse(contractObj.name.Substring(9)); //this might need to be done exactly when contracts expire so difficulty updates doesn't require actual player input AvailableContracts.AdjustContractDifficulty(-PlayerContracts.GetContractAtIndex(contractNumber - 1).GetDifficulty().difficulty); PlayerContracts.RemoveContractAtIndex(contractNumber - 1); UpdateContracts(); }
static void ExecuteDailyTasks() { //Do this before generating new so new contracts don't get accidentally decremented PlayerContracts.ProgressAllContractDeadlines(); AvailableContracts.ProgressAllContractDeadlines(); AvailableContracts.GenerateNewContracts(); Debug.Log("Holding Here?"); MenuManager.currentMenuManager.UpdateMenusAtStartOfDay(); didDailyGeneration = true; Debug.Log("Finished Daily Tasks"); Debug.Log("Average Difficulty: " + AvailableContracts.GetAverageContractDifficulty()); Debug.Log("Standard Dev: " + AvailableContracts.CalculateStandardDeviation(AvailableContracts.GetPastGeneratedContractDifficuties())); }
public void TurnInContract() { string contractName = EventSystem.current.currentSelectedGameObject.transform.parent.name; int contractNumber = int.Parse(contractName.Substring(9)); activeContracts[contractNumber - 1].GetRequiredLumber().SubtractFromStockpile(); activeContracts[contractNumber - 1].GetPayout().AddToInventory(); contractsContent.GetChild(contractNumber - 1).GetChild(6).GetComponent <Button>().interactable = false; contractsContent.GetChild(contractNumber - 1).GetChild(6).GetChild(0).GetComponent <Text>().text = "Completed"; AvailableContracts.AdjustContractDifficulty(activeContracts[contractNumber - 1].GetDifficulty().difficulty); //do more visually to the contract object to show it has been turned in MarkContractForRemoval(contractNumber - 1); UpdateCompletionStatus(); }
public static void Load() { if (File.Exists(Application.persistentDataPath + folderPath + currentSaveSlot + saveSlotStrings[currentSaveSlot - 1])) { // Debug.Log("Loading..."); BinaryFormatter data = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + folderPath + currentSaveSlot + saveSlotStrings[currentSaveSlot - 1], FileMode.Open); SaveableData loadData = (SaveableData)data.Deserialize(file); file.Close(); //-----------------------Loading Data--------------------------------- PlayerTools.SetOwnedToolsList(loadData.ownedTools); PlayerTools.SetCurrentlyEquippedTool(loadData.currentlyEquippedTool.GetToolName()); ToolManager.EquipTool(PlayerTools.GetCurrentlyEquippedToolIndex()); PlayerSkills.SetEfficiencySkill(loadData.efficiencySkill); PlayerSkills.SetContractsSkill(loadData.contractsSkill); PlayerSkills.SetCurrencySkill(loadData.currencySkill); PlayerSkills.SetEnergySkill(loadData.energySkill); PlayerSkills.SetBuildingMaterialsSkill(loadData.buildingMaterialsSkill); PlayerSkills.SetToolPartsSkill(loadData.toolPartsSkill); PlayerSkills.SetBookPagesSkill(loadData.bookPagesSkill); PlayerSkills.SetLumberTreesSkill(loadData.lumberTreesSkill); PlayerSkills.SetLumberLogsSkill(loadData.lumberLogsSkill); PlayerSkills.SetLumberFirewoodSkill(loadData.lumberFirewoodSkill); PlayerRooms.SetBedRoom(loadData.bedRoom); PlayerRooms.SetKitchenRoom(loadData.kitchenRoom); PlayerRooms.SetOfficeRoom(loadData.officeRoom); PlayerRooms.SetStudyRoom(loadData.studyRoom); PlayerRooms.SetWorkshopRoom(loadData.workshopRoom); PlayerAdditions.SetCoffeeMakerAddition(loadData.coffeeMakerAddition); PlayerAdditions.SetFireplaceAddition(loadData.fireplaceAddition); PlayerAdditions.SetFrontPorchAddition(loadData.frontPorchAddition); PlayerAdditions.SetWoodworkingBenchAddition(loadData.woodworkingBenchAddition); PlayerContracts.SetActiveContractsList(loadData.activeContracts); AvailableContracts.SetAvailableContracts(loadData.availableContracts); AvailableContracts.SetContractsToRemove(loadData.availableContractsToRemove); TimeManager.SetDidDailyGeneration(loadData.didDailyGeneration); AvailableContracts.SetAverageContractDifficulty(loadData.averageContractDifficulty); AvailableContracts.SetPastGeneratedContractDifficulties(loadData.pastGeneratedContractDifficulties); PlayerEnergy.SetCurrentEnergyValue(loadData.currentEnergy); PlayerResources.SetCurrentCurrencyValue(loadData.currentCurrency); PlayerResources.SetCurrentBuildingMaterialsValue(loadData.currentBuildingMaterials); PlayerResources.SetCurrentToolPartsValue(loadData.currentToolParts); PlayerResources.SetCurrentBookPagesValue(loadData.currentBookPages); HomesteadStockpile.SetAllTreesCount(loadData.homesteadTreesCount); HomesteadStockpile.SetAllLogsCount(loadData.homesteadLogsCount); HomesteadStockpile.SetAllFirewoodCount(loadData.homesteadFirewoodCount); TimeManager.SetCurrentTime(loadData.currentTime); MainMenu.SetSceneToLoad(loadData.lastSceneName); float[] spawnHolder = loadData.lastSceneSpawnLocation; MainMenu.SetLocationToSpawn(new Vector3(spawnHolder[0], spawnHolder[1], spawnHolder[2])); //-----------------------Done Loading---------------------------------- } else { Save(); } }
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); }
void Start() { AvailableContractsReference = this; }
public void ExecuteCommand() { command = commandDropdown.options[commandDropdown.value].text; commandValue = int.Parse(commandInputField.text); if (secondaryCommmandInputField.text.Length != 0) { secondaryCommandValue = int.Parse(secondaryCommmandInputField.text); } Debug.Log("Command: " + command); Debug.Log("Value: " + commandValue); switch (command) { case "Currency Value": PlayerResources.SetCurrentCurrencyValue(commandValue); break; case "Energy Value": PlayerEnergy.SetCurrentEnergyValue(commandValue); break; case "Building Materials Value": PlayerResources.SetCurrentBuildingMaterialsValue(commandValue); break; case "Tool Parts Value": PlayerResources.SetCurrentToolPartsValue(commandValue); break; case "Book Pages Value": PlayerResources.SetCurrentBookPagesValue(commandValue); break; case "Active Contracts Tier": PlayerSkills.SetCurrentContractsTier(commandValue); break; case "Currency Tier": PlayerSkills.SetCurrentCurrencyTier(commandValue); break; case "Efficiency Tier": PlayerSkills.SetCurrentEfficiencyTier(commandValue); break; case "Energy Tier": PlayerSkills.SetCurrentEnergyTier(commandValue); break; case "Building Materials Tier": PlayerSkills.SetCurrentBuildingMaterialsTier(commandValue); break; case "Tool Parts Tier": PlayerSkills.SetCurrentToolPartsTier(commandValue); break; case "Book Pages Tier": PlayerSkills.SetCurrentBookPagesTier(commandValue); break; case "Felling Axe Tier": PlayerTools.GetToolByName(ToolName.FELLING_AXE).SetCurrentTier(commandValue); break; case "Crosscut Saw Tier": PlayerTools.GetToolByName(ToolName.CROSSCUT_SAW).SetCurrentTier(commandValue); break; case "Splitting Axe Tier": PlayerTools.GetToolByName(ToolName.SPLITTING_AXE).SetCurrentTier(commandValue); break; case "Bedroom Tier": PlayerRooms.SetBedRoomTier(commandValue); break; case "Kitchen Tier": PlayerRooms.SetKitchenRoomTier(commandValue); break; case "Office Tier": PlayerRooms.SetOfficeRoomTier(commandValue); break; case "Study Tier": PlayerRooms.SetStudyRoomTier(commandValue); break; case "Workshop Tier": PlayerRooms.SetWorkshopRoomTier(commandValue); break; case "Lumber Trees Value": HomesteadStockpile.SetTreesCountAtIndex(secondaryCommandValue, commandValue); break; case "Lumber Logs Value": HomesteadStockpile.SetLogsCountAtIndex(secondaryCommandValue, commandValue); break; case "Lumber Firewood Value": HomesteadStockpile.SetFirewoodCountAtIndex(secondaryCommandValue, commandValue); break; case "Lumber Trees Tier": PlayerSkills.SetCurrentLumberTreesTier(commandValue); break; case "Lumber Logs Tier": PlayerSkills.SetCurrentLumberLogsTier(commandValue); break; case "Lumber Firewood Tier": PlayerSkills.SetCurrentLumberFirewoodTier(commandValue); break; case "Skip To Time": TimeManager.SetCurrentTime((float)commandValue); break; case "Clear Active Contracts": PlayerContracts.SetActiveContractsList(new List <LumberContract>()); break; case "Clear Available Contracts": AvailableContracts.SetAvailableContracts(new List <LumberContract>()); break; } }