// Use this for initialization IEnumerator Start() { Manager.LoadProgress(); while (Application.isPlaying) { yield return(new WaitForSecondsRealtime(1)); Manager.Tick(); Manager.SaveProgress(); PlayerPrefs.Save(); } }
public void TestSave(ManagerSaveSettings.SaveTypeEnum saveType) { _testClickable.Currency = _testCurrency; _testClickable.Amount = 1; ArrayUtility.Add(ref _testManager.Config.Currencies, _testCurrency); _testManager.SaveSettings.SaveType = saveType; Assert.Throws <ArgumentException>(() => { _testManager.LoadProgress(); }); _testManager.SaveProgress(); _testManager.LoadProgress(); }
public override void OnInspectorGUI() { ClickerManager manager = this.target as ClickerManager; base.OnInspectorGUI(); if (GUILayout.Button("Populate Buildings")) { string[] buildingGUIDs = AssetDatabase.FindAssets("t:Building"); manager.Config.AvailableBuildings = new Building[buildingGUIDs.Length]; for (int i = 0; i < buildingGUIDs.Length; i++) { string guid = buildingGUIDs[i]; manager.Config.AvailableBuildings[i] = AssetDatabase.LoadAssetAtPath <Building>(AssetDatabase.GUIDToAssetPath(guid)); } Array.Sort(manager.Config.AvailableBuildings, BuildingSorter); } if (GUILayout.Button("Populate Upgrades")) { string[] upgradeGUIDs = AssetDatabase.FindAssets("t:Upgrade"); manager.Config.AvailableUpgrades = new Upgrade[upgradeGUIDs.Length]; for (int i = 0; i < upgradeGUIDs.Length; i++) { string guid = upgradeGUIDs[i]; manager.Config.AvailableUpgrades[i] = AssetDatabase.LoadAssetAtPath <Upgrade>(AssetDatabase.GUIDToAssetPath(guid)); } Array.Sort(manager.Config.AvailableUpgrades, UpgradeSorter); } if (GUILayout.Button("Reset Progress")) { manager.State.EarnedBuildings.Clear(); manager.State.EarnedUpgrades.Clear(); foreach (Building availableBuilding in manager.Config.AvailableBuildings) { availableBuilding.Unlocked = false; } foreach (Upgrade availableUpgrade in manager.Config.AvailableUpgrades) { availableUpgrade.Unlocked = false; } manager.State.CurrencyCurrentTotals.Clear(); } if (GUILayout.Button("Save")) { manager.SaveProgress(); } if (GUILayout.Button("Load")) { manager.LoadProgress(); } }