public void SelectStage()
    {
        if (this.IsUnlocked)
        {
            this.levelSelectCreator.SelectStage(this.specialStage);
        }
        else
        {
            SpecialStageLifetimeVg specialStageLifetimeVg = GnomeStoreAssets.GetSpecialStagesStatic()[this.specialStage.StageId];

            this.purchaseStagePopUp.SetSpecialStageItem(specialStageLifetimeVg, this.levelSelectCreator, this);
        }
    }
Exemple #2
0
    public void SetSpecialStageInitialMappings()
    {
        VirtualGood[] specialStages = GnomeStoreAssets.GetGoodsStatic();

        // Initialize mappings
        List <IdkyKeyValuePairGameObject> backgrounds = this.SpecialStageMappings != null
                                                           ? new List <IdkyKeyValuePairGameObject>(this.SpecialStageMappings)
                                                           : new List <IdkyKeyValuePairGameObject>();

        if (this.SpecialStageMappings == null)
        {
            this.SpecialStageMappings = new IdkyKeyValuePairGameObject[specialStages.Length];

            foreach (VirtualGood specialStage in specialStages)
            {
                backgrounds.Add(new IdkyKeyValuePairGameObject {
                    Key = specialStage.ItemId
                });
            }
        }
        else
        {
            foreach (VirtualGood specialStage in specialStages)
            {
                IIdkyKeyValuePair <string, GameObject> idkyKeyValuePair = this.SpecialStageMappings.GetPair(specialStage.ItemId);

                if (idkyKeyValuePair == null)
                {
                    backgrounds.Add(new IdkyKeyValuePairGameObject {
                        Key = specialStage.ItemId
                    });
                }
            }
        }

        this.SpecialStageMappings = backgrounds.ToArray();
    }
    public void SetSpecialStageCompletedIcons(bool unlocked = false)
    {
        // Didn't initialize yet
        if (this.levelSelectCreator == null)
        {
            return;
        }

        this.IsUnlocked = ShopManager.GoodsBalances[this.specialStage.StageId] > 0 || unlocked;

        if (this.IsUnlocked)
        {
            bool hasLevelIncomplete = false;

            foreach (int levelInStage in this.specialStage.LevelMapping.Keys)
            {
                string key = string.Format(
                    "{0}_{1}_{2}", SharedResources.TimesLevelPlayedToCompletePrefix, this.specialStage.StageId, levelInStage);

                int timesToCompleteLevel = PlayerPrefsFast.GetInt(key, 0);

                // Check if the level has been completed yet
                if (timesToCompleteLevel == 0)
                {
                    hasLevelIncomplete = true;
                    break;
                }
            }

            this.StageCompletedIcon.SetActive(!hasLevelIncomplete);
            this.StageNotCompletedIcon.SetActive(hasLevelIncomplete);
            this.StageLockedIcon.SetActive(false);

            // Set the stage select activate targets if it's unlocked
            if (this.ActivateOnClick != null)
            {
                this.ActivateOnClick.ActivateTarget   = this.stageSelectOverrideActivateTarget;
                this.ActivateOnClick.DeactivateTarget = this.stageSelectOverrideDeactivateTarget;
            }
        }
        else
        {
            SpecialStageLifetimeVg specialStageLifetimeVg = GnomeStoreAssets.GetSpecialStagesStatic()[this.specialStage.StageId];

            if (specialStageLifetimeVg != null)
            {
                if (specialStageLifetimeVg.CanPurchase)
                {
                    // Show purchase with tokens pop up
                    this.ActivateOnClick.ActivateTarget   = this.purchaseStagePopUp.gameObject;
                    this.ActivateOnClick.DeactivateTarget = this.levelSelectCreator.gameObject;
                }
                else
                {
                    // Show reward only pop up
                    this.ActivateOnClick.ActivateTarget   = this.rewardedOnlyPopUp;
                    this.ActivateOnClick.DeactivateTarget = this.levelSelectCreator.gameObject;
                }
            }

            this.StageLockedIcon.SetActive(true);
            this.StageCompletedIcon.SetActive(false);
            this.StageNotCompletedIcon.SetActive(false);
        }
    }