Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
    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();
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 4
0
 public void OpenConfirmPanel(bool state)
 {
     confirmPanel.SetActive(state);
     instantiatedEff?.SetActive(!state);
     if (state)
     {
         confirmPanelCostText.text = PersistentPrefs.GetInstance().gravitonsCost.ToString();
     }
 }
Exemplo n.º 5
0
 public void RewardConfirmed()
 {
     currencyData            = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH).GetData <CurrencyData>();
     currencyData.gravitons -= PersistentPrefs.GetInstance().gravitonsCost;
     gravitonsText.text      = currencyData.gravitons.ToString();
     SaveManager.GetInstance().SavePersistentData(currencyData, SaveManager.CURRENCY_PATH);
     OpenConfirmPanel(false);
     EarnReward(false);
 }
Exemplo n.º 6
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 7
0
    private void BroadcastStats()
    {
        //Send broadcast stats
        SessionStats stats = new SessionStats
        {
            maxSpeedReached = movementManager.GetMaxSpeedReached(),
            maxSpeed        = movementManager.maxSpeed,
            timePlayed      = properTime,
            distortedTime   = relativeExTime - properTime,
            score           = gameMode.sessionScore,
            obstaclesHit    = sessionObstaclesHit
        };

        PersistentPrefs.GetInstance().CheckAchievements(stats);
    }
Exemplo n.º 8
0
    void Start()
    {
        achievementsData = SaveManager.GetInstance().LoadPersistentData(SaveManager.ACHIEVMENTS_PATH).GetData <PlayerAchievementsData>();
        achievements     = PersistentPrefs.GetInstance().GetAllAchievements();

        foreach (AchievementInfo achInfo in achievements)
        {
            GameObject instance = Instantiate(achievementPrefab);
            instance.transform.SetParent(layout.transform);
            Image image = instance.GetComponentInChildren <Image>();
            image.sprite = achInfo.sprite;
            instance.GetComponent <Text>().text = achInfo.description;
            instance.transform.localScale       = new Vector3(1, 1, 1);
            if (achievementsData.IsAchievementUnlocked(achInfo.id))
            {
                image.color = Color.cyan;
            }
        }
    }
Exemplo n.º 9
0
    private void Start()
    {
        InitializeData();

        AudioManager.GetInstance().NotifyAudioSettings(settingsData);
        AudioManager.GetInstance().currentMusic = AudioManager.GetInstance().PlaySound(AudioManager.MENU_SONG);
        PersistentPrefs.GetInstance().SetUnlockableAspects();

        timedReward_c = DailyReward_C();
        StartCoroutine(timedReward_c);

        List <PersistentPrefs.Reward> rewards = PersistentPrefs.GetInstance().GetAllRewards();

        foreach (PersistentPrefs.Reward r in rewards)
        {
            GameObject obj = Instantiate(rewardPrefab);
            obj.transform.SetParent(availableRewardsParent);
            obj.transform.localScale = new Vector3(1, 1, 1);
            switch (r.type)
            {
            case PersistentPrefs.RewardType.GRAVITY_POINT:
                obj.GetComponentInChildren <Text>().text        = r.amount.ToString();
                obj.GetComponentsInChildren <Image>()[1].sprite = PersistentPrefs.GetInstance().gravityPointsIcon;
                break;

            case PersistentPrefs.RewardType.GRAVITON:
                obj.GetComponentInChildren <Text>().text        = r.amount.ToString();
                obj.GetComponentsInChildren <Image>()[1].sprite = PersistentPrefs.GetInstance().gravitonsIcon;
                break;

            case PersistentPrefs.RewardType.ASPECT:
                GameObject aspectRef = SharedUtilities.GetInstance().GetGameObjectsInChildrenWithTag(obj, "Preview")[0];
                aspectRef.SetActive(true);
                obj.GetComponentInChildren <Text>().text         = aspectData.AspectStringFromId(r.id);
                aspectRef.GetComponent <MeshRenderer>().material = PersistentPrefs.GetInstance().GetAspectWithId(r.id).UI_material;
                availableAspectRewardRefs.Add(aspectRef);
                break;
            }
            availableRewards.Add(r.id, obj);
        }
    }
Exemplo n.º 10
0
    private IEnumerator DailyReward_C()
    {
        servData.lastAccess = System.DateTime.Now;
        int difference = (int)(servData.lastAccess - servData.lastRewardClaimed).TotalSeconds;

        //yield return new WaitForSecondsRealtime(0.1f);
        while (true)
        {
            if (difference < PersistentPrefs.GetInstance().timeDelay)
            {
                gravitonsIcon.SetActive(true);
                adIcon.SetActive(false);
                rewardTimeText.text = SharedUtilities.GetInstance().GetTimeStringFromSeconds(PersistentPrefs.GetInstance().timeDelay - difference);
                rewardTimeText.gameObject.SetActive(true);
                costText.text = PersistentPrefs.GetInstance().gravitonsCost.ToString();
                rewardReady   = false;
            }
            else
            {
                if (GoogleAdsManager.GetInstance().IsRewardedAdLoaded(GoogleAdsManager.RewardedAdType.TIMED_REWARD))
                {
                    gravitonsIcon.SetActive(false);
                    adIcon.SetActive(true);
                    rewardTimeText.gameObject.SetActive(false);
                    rewardReady = true;
                }
                else
                {
                    rewardTimeText.gameObject.SetActive(true);
                    rewardTimeText.text = "Loading ad...";
                    costText.text       = PersistentPrefs.GetInstance().gravitonsCost.ToString();
                    rewardReady         = false;
                }
            }
            yield return(new WaitForSecondsRealtime(1f));

            difference = (int)(System.DateTime.Now - servData.lastRewardClaimed).TotalSeconds;
        }
    }
Exemplo n.º 11
0
    public void GetDailyReward()
    {
        if (rewardReady)
        {
            rewardReady = false;
            GoogleAdsManager.GetInstance().ShowRewardedAd(GoogleAdsManager.RewardedAdType.TIMED_REWARD);
            if (Application.isEditor)
            {
                EarnReward(true);
            }
        }
        else
        {
            currencyData = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH).GetData <CurrencyData>();
            if (currencyData.gravitons < PersistentPrefs.GetInstance().gravitonsCost)
            {
                toast.EnqueueToast("Not enough gravitons", null, 1.5f);
                return;
            }

            OpenConfirmPanel(true);
        }
    }