예제 #1
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();
        }
    }