private void Start() { playerData = SaveManager.GetInstance().LoadPersistentData(SaveManager.PLAYER_DATA).GetData <PlayerData>(); thrustForceUpgradeCost = GameplayMath.GetInstance().GetCostFromInitCost(playerData.thrustForcePoints, INIT_THRUST_COST, GameplayMath.DEFAULT_RATIO); resilienceUpgradeCost = GameplayMath.GetInstance().GetCostFromInitCost(playerData.GetHealthPoints(), INIT_HEALTH_COST, GameplayMath.RESILIENCE_RATIO); SaveObject objectData; objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH); currencyData = objectData.GetData <CurrencyData>(); skillsData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SKILLSDATA_PATH).GetData <PlayerSkillsData>(); PlayerAspectData aspect = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH).GetData <PlayerAspectData>(); previewSphere = Instantiate(PersistentPrefs.GetInstance().GetAspectWithId(aspect.equippedSkinId).prefab); previewSphere.transform.SetParent(playerPreviewParent); previewSphere.transform.localScale = new Vector3(200, 200, 200); previewSphere.transform.localPosition = new Vector3(0, 0, -1); antigravityUpgradeCost = GameplayMath.GetInstance().GetCostFromInitCost(skillsData.antigravityPoints, INIT_ANTIGRAVITY_COST, GameplayMath.DEFAULT_RATIO); quantumTunnelUpgradeCost = GameplayMath.GetInstance().GetCostFromInitCost(skillsData.quantumTunnelPoints, INIT_QUANTUMTUNNEL_COST, GameplayMath.DEFAULT_RATIO); solarflareUpgradeCost = GameplayMath.GetInstance().GetCostFromInitCost(skillsData.solarflarePoints, INIT_SOLARFLARE_COST, GameplayMath.DEFAULT_RATIO); GRBUpgradeCost = GameplayMath.GetInstance().GetGRBCost(skillsData.gammaRayBurstPoints); UpdateUI(); UpdateGRBEffect(); }
private void Awake() { gameMode = FindObjectOfType <GameMode>(); movementManager = GetComponent <MovementManager>(); skillManager = GetComponent <SkillManager>(); extraManager = GetComponent <ExtraManager>(); playerData = SaveManager.GetInstance().LoadPersistentData(SaveManager.PLAYER_DATA).GetData <PlayerData>(); if (playerData != null) { playerState = playerData.playerState; initialResilience = playerData.resilience; } PlayerAspectData aspectsData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH).GetData <PlayerAspectData>(); aspect = Instantiate(PersistentPrefs.GetInstance().GetAspectWithId(aspectsData.equippedSkinId).prefab); aspect.transform.SetParent(gameObject.transform); aspect.transform.localScale = new Vector3(1, 1, 1); Material mat = aspect.GetComponent <MeshRenderer>().material; deathEffect.GetComponent <Renderer>().material = mat; dangerZoneCount = 0; }
public void EarnReward(bool restartTimer) { PersistentPrefs.Reward reward = PersistentPrefs.GetInstance().GetRandomReward(); switch (reward.type) { case PersistentPrefs.RewardType.ASPECT: aspectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH).GetData <PlayerAspectData>(); rewardInfoText.text = aspectData.AspectStringFromId(reward.id); rewardIcon.sprite = PersistentPrefs.GetInstance().transparentIcon; rewardText.text = "Aspect unlocked !"; obtainedAspect = Instantiate(PersistentPrefs.GetInstance().GetAspectWithId(reward.id).prefab); obtainedAspect.transform.SetParent(rewardIcon.transform); obtainedAspect.transform.localScale = new Vector3(200, 200, 200); obtainedAspect.transform.localPosition = new Vector3(0, 0, -20); StartCoroutine(FadeInObtainedAspect()); aspectData.UnlockAspect(reward.id); SaveManager.GetInstance().SavePersistentData(aspectData, SaveManager.ASPECTDATA_PATH); GameObject tmp = availableRewards[reward.id]; Debug.Log(availableAspectRewardRefs.Remove(SharedUtilities.GetInstance().GetGameObjectsInChildrenWithTag(tmp, "Preview")[0])); Destroy(tmp); availableRewards.Remove(reward.id); PersistentPrefs.GetInstance().SetUnlockableAspects(); //TODO reward break; case PersistentPrefs.RewardType.GRAVITON: rewardIcon.sprite = PersistentPrefs.GetInstance().gravitonsIcon; rewardInfoText.text = reward.amount.ToString(); rewardText.text = "Gravitons earned !"; currencyData.gravitons += reward.amount; SaveManager.GetInstance().SavePersistentData(currencyData, SaveManager.CURRENCY_PATH); break; case PersistentPrefs.RewardType.GRAVITY_POINT: rewardIcon.sprite = PersistentPrefs.GetInstance().gravityPointsIcon; rewardInfoText.text = reward.amount.ToString(); rewardText.text = "Gravity Points earned !"; currencyData.gravityPoints += reward.amount; SaveManager.GetInstance().SavePersistentData(currencyData, SaveManager.CURRENCY_PATH); break; } rewardPanel.SetActive(true); instantiatedEff?.SetActive(false); if (restartTimer) { servData.lastRewardClaimed = System.DateTime.Now; SaveManager.GetInstance().SavePersistentData(servData, SaveManager.SERVICES_PATH); } }
public void SetUnlockableAspects() { rewards = originalRewards; PlayerAspectData aspect = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH).GetData <PlayerAspectData>(); int length = rewards.Count; List <Reward> temp = new List <Reward>(rewards); for (int i = 0; i < length; i++) { if (rewards[i].type == RewardType.ASPECT && aspect.IsAspectUnlocked(rewards[i].id)) { temp.Remove(rewards[i]); } } rewards = temp; NormalizeRewardsProbabilities(); }
private void Start() { storeProducts = store.GetComponentsInChildren <StoreProduct>(true); List <GameObject> list = SharedUtilities.GetInstance().GetGameObjectsInChildrenWithTag(store, "Preview"); skinsPreviews = list.ToArray(); currencyData = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH).GetData <CurrencyData>(); aspectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH).GetData <PlayerAspectData>(); skillsData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SKILLSDATA_PATH).GetData <PlayerSkillsData>(); gravitonsText.text = currencyData.gravitons.ToString("0"); parentScrollRect = parentScrollView.GetComponent <ScrollRect>(); parentScrollRect.content = SharedUtilities.GetInstance().GetFirstComponentInChildrenWithTag <RectTransform>(powerUpsViewport, "ViewContent"); EnableViewport("PowerUps"); InitializeProductsState(); }
private void InitializeData() { SaveObject objectData; //SETTINGS DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SETTINGS_PATH); if (objectData == null) { settingsData = SaveManager.GetInstance().SavePersistentData(new SettingsData(), SaveManager.SETTINGS_PATH).GetData <SettingsData>(); } else { settingsData = objectData.GetData <SettingsData>(); } SharedUtilities.GetInstance().SetQualitySettings(settingsData.qualityLevel); //PLAYER DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.PLAYER_DATA); if (objectData == null) { objectData = SaveManager.GetInstance().SavePersistentData(new PlayerData(), SaveManager.PLAYER_DATA); } PlayerData playerData = objectData.GetData <PlayerData>(); playerData.InitializeMissingData(); levelText.text = playerData.playerLevel.ToString("0"); currentExpText.text = playerData.currentExp.ToString("0"); int expNeeded = playerData.GetLevelExpNeeded(); expNeededText.text = expNeeded.ToString("0"); levelBar.fillAmount = playerData.currentExp / (float)expNeeded; GameObject eff = GetLevelEffect(playerData.playerLevel); if (eff != null) { instantiatedEff = Instantiate(eff, playerLevelTransform); instantiatedEff.transform.localScale = new Vector3(1, 1, 1); instantiatedEff.transform.localPosition = new Vector3(0, 40, 0); } SaveManager.GetInstance().SavePersistentData(playerData, SaveManager.PLAYER_DATA); //SKILLS DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SKILLSDATA_PATH); if (objectData == null) { objectData = SaveManager.GetInstance().SavePersistentData(new PlayerSkillsData(), SaveManager.SKILLSDATA_PATH); } PlayerSkillsData skillData = objectData.GetData <PlayerSkillsData>(); skillData.InitializeMissingData(); SaveManager.GetInstance().SavePersistentData(skillData, SaveManager.SKILLSDATA_PATH); //ACHIEVEMENTS objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ACHIEVMENTS_PATH); if (objectData == null) { SaveManager.GetInstance().SavePersistentData(new PlayerAchievementsData(), SaveManager.ACHIEVMENTS_PATH); } //LEVELS DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.LEVELSDATA_PATH); if (objectData == null) { objectData = SaveManager.GetInstance().SavePersistentData <LevelsData>(new LevelsData(), SaveManager.LEVELSDATA_PATH); } LevelsData data = objectData.GetData <LevelsData>(); data.InitializeMissingData(); SaveManager.GetInstance().SavePersistentData(data, SaveManager.LEVELSDATA_PATH); highScoreText.text = data.GetLevelHighScore(LevelsData.ENDLESS_ID).ToString(); //CURRENCY DATA SaveObject currencyObj = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH); if (currencyObj == null) { currencyObj = SaveManager.GetInstance().SavePersistentData <CurrencyData>(new CurrencyData(), SaveManager.CURRENCY_PATH); } currencyData = currencyObj.GetData <CurrencyData>(); currencyData.InitializeMissingData(); int currentGP = 0; objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.GRAVITYPOINTS_PATH); if (objectData != null) { currentGP = objectData.GetData <int>(); currencyData.gravityPoints = currentGP; } SaveManager.GetInstance().SavePersistentData <CurrencyData>(currencyData, SaveManager.CURRENCY_PATH); SaveManager.GetInstance().DeleteData(SaveManager.GRAVITYPOINTS_PATH); gravityPointsText.text = currencyData.gravityPoints.ToString(); gravitonsText.text = currencyData.gravitons.ToString(); //ASPECT DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ASPECTDATA_PATH); if (objectData == null) { objectData = SaveManager.GetInstance().SavePersistentData(new PlayerAspectData(), SaveManager.ASPECTDATA_PATH); } aspectData = objectData.GetData <PlayerAspectData>(); aspectData.InitializeMissingData(); SaveManager.GetInstance().SavePersistentData(aspectData, SaveManager.ASPECTDATA_PATH); //SERVICES DATA objectData = SaveManager.GetInstance().LoadPersistentData(SaveManager.SERVICES_PATH); if (objectData == null) { objectData = SaveManager.GetInstance().SavePersistentData(new ServicesData(), SaveManager.SERVICES_PATH); } servData = objectData.GetData <ServicesData>(); servData.InitializeMissingData(); SaveManager.GetInstance().SavePersistentData(servData, SaveManager.SERVICES_PATH); }