Example #1
0
    void Start()
    {
        switch (name)
        {
        case "Kitchen":
            associatedRoom = PlayerRooms.GetKitchenRoom();
            break;

        case "Bedroom":
            associatedRoom = PlayerRooms.GetBedRoom();
            break;

        case "Office":
            associatedRoom = PlayerRooms.GetOfficeRoom();
            break;

        case "Study":
            associatedRoom = PlayerRooms.GetStudyRoom();
            break;

        case "Workshop":
            associatedRoom = PlayerRooms.GetWorkshopRoom();
            break;
        }

        roomName        = toolTipGroup.GetChild(0).GetComponent <Text>();
        tierNumber      = toolTipGroup.GetChild(1).GetComponent <Text>();
        roomDescription = toolTipGroup.GetChild(2).GetComponent <Text>();
        tierValue       = toolTipGroup.GetChild(3).GetComponent <Text>();
    }
    public static void GenerateNewContracts()
    {
        // Debug.Log("To Remove Count: " + contractsToRemove.Count);
        if (contractsToRemove.Count > 0)
        {
            for (int i = contractsToRemove.Count - 1; i >= 0; i--)
            {
                if (contractsToRemove[i] <= availableContracts.Count - 1)
                {
                    // Debug.Log("Remove Index: " + contractsToRemove[i] + " | Loop Index: " + i);
                    availableContracts.RemoveAt(contractsToRemove[i]);
                }
            }
            contractsToRemove.Clear();
        }

        totalNumberToDisplay = PlayerRooms.GetKitchenRoomValue();
        freeContractSpaces   = totalNumberToDisplay - availableContracts.Count;

        for (int j = 0; j < freeContractSpaces; j++)
        {
            int            difficulty = GenerateDifficulty();
            LumberContract toAdd      = new LumberContract(difficulty);

            // Debug.Log("C" + j + ": " + toAdd.GetDifficulty().difficulty + ", " + toAdd.GetDifficulty().GetQualityGradeInt());

            availableContracts.Add(toAdd);
        }

        if (SceneManager.GetActiveScene().name.Equals("MainCabin"))
        {
            AvailableContractsReference.PopulateCanvasObjcets();
        }
    }
Example #3
0
    float DetermineSleepDuration()
    {
        float startTime = TimeManager.GetCurrentTime();

        if (startTime % 30 >= 15)
        {
            startTime = (startTime - (startTime % 30)) + 30;
        }
        else
        {
            startTime -= (startTime % 30);
        }

        float sleepDuration = 0;

        if (startTime < TimeManager.morningTime)
        {
            sleepDuration = (TimeManager.morningTime - startTime) / 60;
        }
        else
        {
            sleepDuration = ((1440 - startTime) + TimeManager.morningTime) / 60;
        }
        sleepDuration = Mathf.Clamp(sleepDuration, 0, PlayerRooms.GetBedRoomValue());

        // Debug.Log("Sleep Start Time: " + startTime);
        // Debug.Log("Sleep Duration: " + sleepDuration);

        return(sleepDuration);
    }
Example #4
0
    public static void RestoreEnergyPercentage(float sleepDuration)
    {
        float restorePercentage = sleepDuration / PlayerRooms.GetBedRoomValue();
        int   restoreAmount     = Mathf.RoundToInt(PlayerSkills.GetMaxEnergyValue() * restorePercentage);

        // Debug.Log("Current Energy: " + currentEnergyValue);
        // Debug.Log("Restore Perc: " + restorePercentage);
        // Debug.Log("Resore Min Amount: " + restoreAmount);

        currentEnergyValue = Mathf.Clamp(currentEnergyValue, restoreAmount, PlayerSkills.GetMaxEnergyValue());
    }
Example #5
0
    public void UpgradeStudy()
    {
        StudyRoom study = PlayerRooms.GetStudyRoom();

        if (study.CanBeUpgraded())
        {
            int currentTier = PlayerRooms.GetStudyRoomTier();

            if (study.GetDevResourceQuantityAtTier(currentTier + 1).HasInInventory())
            {
                PlayerRooms.SetStudyRoomTier(currentTier + 1);
                study.GetDevResourceQuantityAtTier(currentTier + 1).SubtractFromInventory();
                ShopCanvas.TriggerRoomsInfoUpdate();
            }
            else
            {
                Debug.Log("Insufficient Resources:" + study.GetDevResourceQuantityAtTier(currentTier + 1));
            }
        }
        else
        {
            Debug.Log("Max Tier Reached: STUDY ");
        }
    }
Example #6
0
    public void UpgradeBedroom()
    {
        BedRoom bedroom = PlayerRooms.GetBedRoom();

        if (bedroom.CanBeUpgraded())
        {
            int currentTier = PlayerRooms.GetBedRoomTier();

            if (bedroom.GetDevResourceQuantityAtTier(currentTier + 1).HasInInventory())
            {
                PlayerRooms.SetBedRoomTier(currentTier + 1);
                bedroom.GetDevResourceQuantityAtTier(currentTier + 1).SubtractFromInventory();
                ShopCanvas.TriggerRoomsInfoUpdate();
            }
            else
            {
                Debug.Log("Insufficient Resources:" + bedroom.GetDevResourceQuantityAtTier(currentTier + 1));
            }
        }
        else
        {
            Debug.Log("Max Tier Reached: BEDROOM ");
        }
    }
Example #7
0
    public void UpgradeOffice()
    {
        OfficeRoom office = PlayerRooms.GetOfficeRoom();

        if (office.CanBeUpgraded())
        {
            int currentTier = PlayerRooms.GetOfficeRoomTier();

            if (office.GetDevResourceQuantityAtTier(currentTier + 1).HasInInventory())
            {
                PlayerRooms.SetOfficeRoomTier(currentTier + 1);
                office.GetDevResourceQuantityAtTier(currentTier + 1).SubtractFromInventory();
                ShopCanvas.TriggerRoomsInfoUpdate();
            }
            else
            {
                Debug.Log("Insufficient Resources:" + office.GetDevResourceQuantityAtTier(currentTier + 1));
            }
        }
        else
        {
            Debug.Log("Max Tier Reached: OFFICE ");
        }
    }
Example #8
0
    public void UpgradeKitchen()
    {
        KitchenRoom kitchen = PlayerRooms.GetKitchenRoom();

        if (kitchen.CanBeUpgraded())
        {
            int currentTier = PlayerRooms.GetKitchenRoomTier();

            if (kitchen.GetDevResourceQuantityAtTier(currentTier + 1).HasInInventory())
            {
                PlayerRooms.SetKitchenRoomTier(currentTier + 1);
                kitchen.GetDevResourceQuantityAtTier(currentTier + 1).SubtractFromInventory();
                ShopCanvas.TriggerRoomsInfoUpdate();
            }
            else
            {
                Debug.Log("Insufficient Resources:" + kitchen.GetDevResourceQuantityAtTier(currentTier + 1));
            }
        }
        else
        {
            Debug.Log("Max Tier Reached: KITCHEN ");
        }
    }
Example #9
0
    public void UpgradeWorkshop()
    {
        WorkshopRoom workshop = PlayerRooms.GetWorkshopRoom();

        if (workshop.CanBeUpgraded())
        {
            int currentTier = PlayerRooms.GetWorkshopRoomTier();

            if (workshop.GetDevResourceQuantityAtTier(currentTier + 1).HasInInventory())
            {
                PlayerRooms.SetWorkshopRoomTier(currentTier + 1);
                workshop.GetDevResourceQuantityAtTier(currentTier + 1).SubtractFromInventory();
                ShopCanvas.TriggerRoomsInfoUpdate();
            }
            else
            {
                Debug.Log("Insufficient Resources:" + workshop.GetDevResourceQuantityAtTier(currentTier + 1));
            }
        }
        else
        {
            Debug.Log("Max Tier Reached: WORKSHOP ");
        }
    }
    public void PopulateCanvasObjcets()
    {
        totalNumberToDisplay = PlayerRooms.GetKitchenRoomValue();

        for (int i = 0; i < contractsContent.childCount; i++)
        {
            contractsContent.GetChild(i).gameObject.SetActive(i < totalNumberToDisplay);
        }

        //This shows newest contracts last. consider starting at end of list and going backward to show newest first
        // Debug.Log("Available Count: " + availableContracts.Count);
        // Debug.Log("Available Total Display: " + totalNumberToDisplay);
        for (int j = 0; j < totalNumberToDisplay; j++)
        {
            // Debug.Log("Available Populate Index: " + j);
            contractsContent.GetChild(j).GetChild(0).GetComponent <Text>().text = availableContracts[j].GetCompletionDeadline().ToString();
            contractsContent.GetChild(j).GetChild(1).GetComponent <Text>().text = "Quality Grade: " + availableContracts[j].GetRequiredLumber().GetTreeGrade();
            contractsContent.GetChild(j).GetChild(2).GetComponent <Text>().text = availableContracts[j].GetRequiredLumber().StringWithoutQuality();
            contractsContent.GetChild(j).GetChild(3).GetComponent <Text>().text = availableContracts[j].GetPayout().ToString();

            contractsContent.GetChild(j).GetChild(6).GetComponent <Button>().interactable = (availableContracts[j].GetStatus() == ContractStatus.AVAILABLE);
            contractsContent.GetChild(j).GetChild(7).GetComponent <Button>().interactable = (availableContracts[j].GetStatus() == ContractStatus.AVAILABLE);
        }
    }
Example #11
0
    void UpdateRoomsInfo()
    {
        roomUpgradesGroup.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = PlayerRooms.GetBedRoomTier().ToString();
        roomUpgradesGroup.transform.GetChild(0).GetChild(1).GetComponent <Text>().text = PlayerRooms.GetNextBedRoomUpgradeCostsAsString();

        roomUpgradesGroup.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = PlayerRooms.GetKitchenRoomTier().ToString();
        roomUpgradesGroup.transform.GetChild(1).GetChild(1).GetComponent <Text>().text = PlayerRooms.GetNextKitchenUpgradeCostsAsString();

        roomUpgradesGroup.transform.GetChild(2).GetChild(0).GetComponent <Text>().text = PlayerRooms.GetOfficeRoomTier().ToString();
        roomUpgradesGroup.transform.GetChild(2).GetChild(1).GetComponent <Text>().text = PlayerRooms.GetNextOfficeUpgradeCostsAsString();

        roomUpgradesGroup.transform.GetChild(3).GetChild(0).GetComponent <Text>().text = PlayerRooms.GetStudyRoomTier().ToString();
        roomUpgradesGroup.transform.GetChild(3).GetChild(1).GetComponent <Text>().text = PlayerRooms.GetNextStudyUpgradeCostsAsString();

        roomUpgradesGroup.transform.GetChild(4).GetChild(0).GetComponent <Text>().text = PlayerRooms.GetWorkshopRoomTier().ToString();
        roomUpgradesGroup.transform.GetChild(4).GetChild(1).GetComponent <Text>().text = PlayerRooms.GetNextWorkshopUpgradeCostsAsString();

        updateRooms = false;
    }
Example #12
0
    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();
        }
    }
Example #13
0
    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);
    }
Example #14
0
    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;
        }
    }