public void PurchaseCoffeeMaker() { CoffeeMakerAddition addition = PlayerAdditions.GetCoffeeMakerAddition(); if (!addition.GetIsUnlocked()) { if (addition.GetPurchaseCosts().HasInInventory()) { addition.GetPurchaseCosts().SubtractFromInventory(); PlayerAdditions.GetCoffeeMakerAddition().SetIsUnlocked(true); ShopCanvas.TriggerAdditionsInfoUpdate(); // For this to immedialty show up, have to manually trigger // because the addition exists in the same scene as the menu cabinAdditionHandlers[0].HandleAdditions(); } else { Debug.Log("Insufficient Resources"); } } else { Debug.Log("Already Purchased: COFFEE MAKER"); } }
void UpdateAdditionsInfo() { // should disable these or throw an overlay over them if they've already been unlocked additionsGroup.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = PlayerAdditions.GetCoffeeMakerAddition().GetPurchaseCosts().ToString(); additionsGroup.transform.GetChild(0).GetChild(4).gameObject.SetActive(PlayerAdditions.GetCoffeeMakerAddition().GetIsUnlocked()); additionsGroup.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = PlayerAdditions.GetFireplaceAddition().GetPurchaseCosts().ToString(); additionsGroup.transform.GetChild(1).GetChild(4).gameObject.SetActive(PlayerAdditions.GetFireplaceAddition().GetIsUnlocked()); additionsGroup.transform.GetChild(2).GetChild(0).GetComponent <Text>().text = PlayerAdditions.GetFrontPorchAddition().GetPurchaseCosts().ToString(); additionsGroup.transform.GetChild(2).GetChild(4).gameObject.SetActive(PlayerAdditions.GetFrontPorchAddition().GetIsUnlocked()); additionsGroup.transform.GetChild(3).GetChild(0).GetComponent <Text>().text = PlayerAdditions.GetWoodworkingBenchAddition().GetPurchaseCosts().ToString(); additionsGroup.transform.GetChild(3).GetChild(4).gameObject.SetActive(PlayerAdditions.GetWoodworkingBenchAddition().GetIsUnlocked()); updateHomesteadAdditions = false; }
public void HandleAdditions() { switch (addition.ToString()) { case "COFFEE_MAKER": TriggerObjects(PlayerAdditions.GetCoffeeMakerAddition().GetIsUnlocked()); break; case "FRONT_PORCH": TriggerObjects(PlayerAdditions.GetFrontPorchAddition().GetIsUnlocked()); break; case "FIREPLACE": TriggerObjects(PlayerAdditions.GetFireplaceAddition().GetIsUnlocked()); break; case "WOODWORKING_BENCH": TriggerObjects(PlayerAdditions.GetWoodworkingBenchAddition().GetIsUnlocked()); break; } }
public void PurchaseWoodworkingBench() { WoodworkingBenchAddition addition = PlayerAdditions.GetWoodworkingBenchAddition(); if (!addition.GetIsUnlocked()) { if (addition.GetPurchaseCosts().HasInInventory()) { addition.GetPurchaseCosts().SubtractFromInventory(); PlayerAdditions.GetWoodworkingBenchAddition().SetIsUnlocked(true); ShopCanvas.TriggerAdditionsInfoUpdate(); } else { Debug.Log("Insufficient Resources"); } } else { Debug.Log("Already Purchased: WOODWORKING BENCH"); } }
public void PurchaseFrontPorch() { FrontPorchAddition addition = PlayerAdditions.GetFrontPorchAddition(); if (!addition.GetIsUnlocked()) { if (addition.GetPurchaseCosts().HasInInventory()) { addition.GetPurchaseCosts().SubtractFromInventory(); PlayerAdditions.GetFrontPorchAddition().SetIsUnlocked(true); ShopCanvas.TriggerAdditionsInfoUpdate(); } else { Debug.Log("Insufficient Resources"); } } else { Debug.Log("Already Purchased: FRONT PORCH"); } }
public void PurchaseFireplace() { FireplaceAddition addition = PlayerAdditions.GetFireplaceAddition(); if (!addition.GetIsUnlocked()) { if (addition.GetPurchaseCosts().HasInInventory()) { addition.GetPurchaseCosts().SubtractFromInventory(); PlayerAdditions.GetFireplaceAddition().SetIsUnlocked(true); ShopCanvas.TriggerAdditionsInfoUpdate(); cabinAdditionHandlers[1].HandleAdditions(); } else { Debug.Log("Insufficient Resources"); } } else { Debug.Log("Already Purchased: FIREPLACE"); } }
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); }