Example #1
0
        public void ResetGameAndJson()
        {
            IncomeData = new SaveIncomeData
            {
                numberOfOwnedProducts        = 1,
                totalNumberOfProductsCanSell = 3,
                productIncomeData            = new ProductIncomeData[1]
            };

            PlayerData = new SavePlayerData
            {
                playerLevelData = new PlayerLevelData(1, 0, 200),
                characterData   = new CharacterData(0, 7),
            };

            MultiplierData = new SaveMultiplierData
            {
            };

            IncomeData.productIncomeData[0] = new ProductIncomeData(0, 1, 15, 0, 0, 0.10f);

            //Shoves all the SaveData information into one long ass string.
            string incomeContents     = JsonUtility.ToJson(IncomeData, true);
            string playerContents     = JsonUtility.ToJson(PlayerData, true);
            string multiplierContents = JsonUtility.ToJson(MultiplierData, true);

            //Writes it all to the dataFileName (data.json) and stores that file into the dataPath (Application.persistentDataPath, or the folder that the phone or computers allows us to store.)
            File.WriteAllText(incomeDataPath, incomeContents);
            File.WriteAllText(playerDataPath, playerContents);
            File.WriteAllText(multiplierDataPath, multiplierContents);

            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }
Example #2
0
        public void LoadFromJson()
        {
            if (File.Exists(incomeDataPath))
            {
                //Writes all the data.json values into one long ass string.
                string incomeContents = File.ReadAllText(incomeDataPath);

                //Shoves all the content from the string "contents" into the SaveData information.
                IncomeData = JsonUtility.FromJson <SaveIncomeData>(incomeContents);

                //Loads up and replaces all the necessary information.
                LoadIncomeData();
            }
            else
            {
                ResetGameAndJson();
                Start();
            }

            if (File.Exists(playerDataPath))
            {
                //Writes all the data.json values into one long ass string.
                string playerContents = File.ReadAllText(playerDataPath);

                //Shoves all the content from the string "contents" into the SaveData information.
                PlayerData = JsonUtility.FromJson <SavePlayerData>(playerContents);

                //Loads up and replaces all the necessary information.
                LoadPlayerData();
            }
            else
            {
                ResetGameAndJson();
                Start();
            }

            if (File.Exists(multiplierDataPath))
            {
                //Writes all the data.json values into one long ass string.
                string multiplierContents = File.ReadAllText(multiplierDataPath);

                //Shoves all the content from the string "contents" into the SaveData information.
                MultiplierData = JsonUtility.FromJson <SaveMultiplierData>(multiplierContents);

                //Loads up and replaces all the necessary information.
                LoadMultiplierData();
            }
            else
            {
                ResetGameAndJson();
                Start();
            }
        }
Example #3
0
        public void SetAllMultiplierValuesViaJson(SaveMultiplierData json)
        {
            DirtyMoneyIncreaseMultiplier = json.productMultiplierData.dirtyMoneyIncrease;
            CleanMoneyIncreaseMultiplier = json.productMultiplierData.cleanMoneyIncrease;
            ReputationIncreaseMultiplier = json.productMultiplierData.reputationIncrease;
            InfluenceIncreaseMultiplier  = json.productMultiplierData.influenceIncrease;
            TimerReductionMultiplier     = json.productMultiplierData.timerReduction;

            CurrentResearchedGrade   = json.productQualityData.currentGrade;
            CurrentResearchedProduct = json.productQualityData.currentProduct;
            NextResearchedGrade      = json.productQualityData.nextGrade;
            NextResearchedProduct    = json.productQualityData.nextProduct;

            LaunderRateIncreaseMultiplier          = json.researchMultiplierData.launderRateIncrease;
            ExperienceIncreaseMultiplier           = json.researchMultiplierData.experienceRateIncrease;
            SecondsBetweenWeeksReductionMultiplier = json.researchMultiplierData.secondsBetweenWeeksReduction;
            MoneyButtonClickIncreaseMultiplier     = json.researchMultiplierData.moneyButtonClickIncrease;
            ResearchCostReductionMultiplier        = json.researchMultiplierData.researchCostReduction;
            AdBonusRateIncreaseMultiplier          = json.researchMultiplierData.adBonusRateIncrease;
            AdBonusLengthIncreaseMultiplier        = json.researchMultiplierData.adBonusLengthIncrease;
        }
Example #4
0
        public void SaveToJson()
        {
            //Creates a new SaveData class, which resets everything to default values of 0.
            IncomeData     = new SaveIncomeData();
            PlayerData     = new SavePlayerData();
            MultiplierData = new SaveMultiplierData();

            //Grabs all the necessary information and shoves it into the SaveData class.
            SavePlayerData();
            SaveIncomeData();
            SaveMultiplierData();

            //Shoves all the SaveData information into one long ass string.
            string incomeContents     = JsonUtility.ToJson(IncomeData, true);
            string playerContents     = JsonUtility.ToJson(PlayerData, true);
            string multiplierContents = JsonUtility.ToJson(MultiplierData, true);

            //Writes it all to the dataFileName (data.json) and stores that file into the dataPath (Application.persistentDataPath, or the folder that the phone or computers allows us to store.)
            File.WriteAllText(incomeDataPath, incomeContents);
            File.WriteAllText(playerDataPath, playerContents);
            File.WriteAllText(multiplierDataPath, multiplierContents);
        }