Example #1
0
    void ChangeTool()
    {
        if (doChangeTool)
        {
            // Debug.Log("Current Tool: " + PlayerTools.GetCurrentlyEquippedToolIndex());
            // Debug.Log("To Equip Tool: " + ToolManager.GetToolToEquipIndex());

            int startLoc = 0;
            if (PlayerTools.GetCurrentlyEquippedToolIndex() > 0)
            {
                startLoc = (PlayerTools.GetCurrentlyEquippedToolIndex() == 2) ? 2 : 1;
            }

            int endLoc = 0;
            if (ToolManager.GetToolToEquipIndex() > 0)
            {
                endLoc = (ToolManager.GetToolToEquipIndex() == 2) ? 2 : 1;
            }

            CharacterAnimator.SetEquipLocations((float)startLoc, (float)endLoc);
            CharacterAnimator.SetSwitchToolAsAction();

            PlayerHud.PlayerHudReference.ChangeToolIcon();

            // Debug.Log("Start Loc: " + startLoc);
            // Debug.Log("End Loc: " + endLoc);

            doChangeTool = false;
        }
    }
Example #2
0
    void Update()
    {
        if (TimeManager.paused)
        {
            return;
        }

        maxEnergyValue          = PlayerSkills.GetMaxEnergyValue();
        currentEnergyValue      = (float)PlayerEnergy.GetCurrentEnergyValue() / maxEnergyValue;
        energyRadial.fillAmount = currentEnergyValue;
        energyRadial.color      = Color.Lerp(Color.red, Color.green, currentEnergyValue);
        energyText.text         = (currentEnergyValue * maxEnergyValue).ToString();

        if (!SceneManager.GetActiveScene().name.Equals("MainCabin"))
        {
            if (((Input.GetButton("ToolWheel") && !toolWheelIsOpen) || (Input.GetButtonUp("ToolWheel") && toolWheelIsOpen)) && !MenuManager.currentMenuManager.IsInMenu())
            {
                ToggleToolWheel();
            }
        }
        else
        {
            if (!toolsDisabledInside)
            {
                toolIconGroup.parent.transform.parent.gameObject.SetActive(false);
                toolsDisabledInside = true;
            }
        }

        DebugPanel.Log("Current Tool: ", "Player HUD", PlayerTools.GetCurrentlyEquippedToolIndex());
        DebugPanel.Log("Current Tool (manager)", "Player HUD", ToolManager.GetCurrentToolIndex());
    }
Example #3
0
    void ToggleToolWheel()
    {
        toolWheelIsOpen = !toolWheelIsOpen;
        toolWheelGroup.gameObject.SetActive(toolWheelIsOpen);

        CharacterInputController.ToggleCameraTurn(!toolWheelIsOpen);

        if (toolWheelIsOpen)
        {
            toolWheelEquipIndex = PlayerTools.GetCurrentlyEquippedToolIndex();
        }
        else
        {
            ToolWheelSwitchExecute();
        }
    }
Example #4
0
    void HandleToolInput()
    {
        if (Input.GetButtonDown("Tool_01") && ToolManager.GetToolToEquipIndex() != 0)
        {
            ToolManager.SetToolToEquipIndex(0);
            doChangeTool = true;
        }
        else if (Input.GetButtonDown("Tool_02") && ToolManager.GetToolToEquipIndex() != 1)
        {
            ToolManager.SetToolToEquipIndex(1);
            doChangeTool = true;
        }
        else if (Input.GetButtonDown("Tool_03") && ToolManager.GetToolToEquipIndex() != 2)
        {
            ToolManager.SetToolToEquipIndex(2);
            doChangeTool = true;
        }
        else if (Input.GetButtonDown("Tool_04") && ToolManager.GetToolToEquipIndex() != 3)
        {
            ToolManager.SetToolToEquipIndex(3);
            doChangeTool = true;
        }

        if (!ToolManager.GetScrollSwitch() && !MenuManager.currentMenuManager.IsInMenu())
        {
            // Debug.Log("Scroll: " + Input.GetAxis("Mouse ScrollWheel"));
            if (Input.GetAxis("Mouse ScrollWheel") >= 0.1f)
            {
                // Debug.Log("Scoll Check Forward");
                ToolManager.SetToolToEquipIndex((PlayerTools.GetCurrentlyEquippedToolIndex() + 1) % 4);
                doChangeTool = true;
                ToolManager.SetScrollSwitch(true);
            }
            else if (Input.GetAxis("Mouse ScrollWheel") <= -0.1f)
            {
                // Debug.Log("Scoll Check Backward");
                ToolManager.SetToolToEquipIndex((PlayerTools.GetCurrentlyEquippedToolIndex() + 3) % 4);
                doChangeTool = true;
                ToolManager.SetScrollSwitch(true);
            }
        }

        // if (doChangeTool) ChangeTool();
    }
Example #5
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        toolsDisabled = scene.name.Equals("MainCabin");

        if (toolsDisabled)
        {
            // Debug.Log("Entered Cabin");
            freeLookInputEnabled = false;
            tempToolIndex        = PlayerTools.GetCurrentlyEquippedToolIndex();
            HandleToolInput(0);
            ChangeTool();
        }
        else
        {
            if (lastScene.Equals("MainCabin"))
            {
                freeLookInputEnabled = true;
                HandleToolInput(tempToolIndex);
                ChangeTool();
            }
        }

        lastScene = scene.name;
    }
Example #6
0
    void HandleSnapLogic()
    {
        bool fellingCondition =
            (currentActivity == LoggingActivity.FELLING && !forestTreeToCut.HasFallen() /*&& forestTreeToCut.PlayerCanStore()*/ && PlayerTools.GetCurrentlyEquippedToolIndex() == 1);

        bool buckingCondition =
            (currentActivity == LoggingActivity.BUCKING && !felledTreeToSaw.IsLocationFullyCut(markToSaw) /*&& felledTreeToSaw.PlayerCanStore()*/ && PlayerTools.GetCurrentlyEquippedToolIndex() == 2);

        bool splittingCondition =
            (currentActivity == LoggingActivity.SPLITTING && logsRemaining > 0 /*&& logToSplit.PlayerCanStore()*/ && PlayerTools.GetCurrentlyEquippedToolIndex() == 3);

        if (Input.GetButtonDown("Interact") && canSnapPlayer)
        {
            if (fellingCondition || buckingCondition || splittingCondition)
            {
                if (!playerIsLocked)
                {
                    SnapPlayer();
                }
                else
                {
                    if (currentActivity == LoggingActivity.SPLITTING && QualityMinigame.GetUngradedFirewood() > 0)
                    {
                        GradeSplitFirewoodBeforeUnsnap();
                    }
                    else
                    {
                        UnsnapPlayer();
                    }
                }
            }

            // if (forestTreeToCut != null)
            // {
            //  if (!forestTreeToCut.PlayerCanStore()) Debug.Log("Full On Trees: Grade " + forestTreeToCut.GetQualityGrade().ToString());
            // }

            // if (felledTreeToSaw != null)
            // {
            //  if (!felledTreeToSaw.PlayerCanStore()) Debug.Log("Full On Logs: Grade " + felledTreeToSaw.GetQualityGrade().ToString());
            // }

            // if (logToSplit != null)
            // {
            //  if (!logToSplit.PlayerCanStore()) Debug.Log("Full On Firewood: Grade " + logToSplit.GetQualityGrade().ToString());
            // }
        }
    }
Example #7
0
 void Start()
 {
     currentToolIndex = PlayerTools.GetCurrentlyEquippedToolIndex();
     EquipTool(currentToolIndex);
 }
Example #8
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();
        }
    }