Example #1
0
    public void SetSpecialStageItem(
        SpecialStageLifetimeVg specialStage, LevelSelectCreator levelSelect, SpecialStageSelectButton selectStageButton)
    {
        this.specialStageVG           = specialStage;
        this.levelSelectCreator       = levelSelect;
        this.specialStageSelectButton = selectStageButton;

        PurchaseWithVirtualItem purchaseType = (PurchaseWithVirtualItem)specialStage.PurchaseType;

        this.Message.text = string.Format("Would you like to purchase this stage for {0} tokens?", purchaseType.Amount);
    }
    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);
        }
    }
    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);
        }
    }