public void RebuildTexts()
    {
        string     arg        = string.Empty;
        string     text       = string.Format("[snout] {0}", this.cost);
        UnlockType unlockType = this.unlockType;

        if (unlockType != SpecialSandboxUnlockDialog.UnlockType.Skull)
        {
            if (unlockType == SpecialSandboxUnlockDialog.UnlockType.Statue)
            {
                arg = "[statue]";
            }
        }
        else
        {
            arg = "[skull]";
        }
        string text2 = string.Format("{0} {1}/{2}", arg, this.collected, this.required);

        for (int i = 0; i < this.collectedTexts.Length; i++)
        {
            this.collectedTexts[i].text = text2;
            TextMeshSpriteIcons.EnsureSpriteIcon(this.collectedTexts[i]);
        }
        this.costTextDisabled.text = text;
        TextMeshSpriteIcons.EnsureSpriteIcon(this.costTextDisabled);
        this.costTextEnabled.text = text;
        TextMeshSpriteIcons.EnsureSpriteIcon(this.costTextEnabled);
    }
Esempio n. 2
0
    private void UpdatePlayerStats()
    {
        for (int i = 0; i < 3; i++)
        {
            int num = 0;
            if (i != 0)
            {
                if (i != 1)
                {
                    if (i == 2)
                    {
                        num = GameProgress.GetInt("cake_race_bronze_trophies_won", 0, GameProgress.Location.Local, null);
                    }
                }
                else
                {
                    num = GameProgress.GetInt("cake_race_silver_trophies_won", 0, GameProgress.Location.Local, null);
                }
            }
            else
            {
                num = GameProgress.GetInt("cake_race_gold_trophies_won", 0, GameProgress.Location.Local, null);
            }
            this.trophyIcons[i].gameObject.SetActive(num > 0);
            TextMeshHelper.UpdateTextMeshes(this.trophyAmountLabels[i], (num <= 0) ? string.Empty : num.ToString(), false);
        }
        int @int = GameProgress.GetInt("cake_race_coins_won", 0, GameProgress.Location.Local, null);

        TextMeshHelper.UpdateTextMeshes(this.totalCoinsWonLabel, string.Format("[snout] {0}", @int), false);
        TextMeshSpriteIcons.EnsureSpriteIcon(this.totalCoinsWonLabel);
        int int2 = GameProgress.GetInt("cake_race_highest_rank", 0, GameProgress.Location.Local, null);

        TextMeshHelper.UpdateTextMeshes(this.highestRankLabel, (int2 <= 0) ? "-" : int2.ToString(), false);
    }
Esempio n. 3
0
    public void RebuildTexts()
    {
        string text = string.Format("[snout] {0}", this.cost);

        TextMesh[] componentsInChildren = this.costTextEnabled.gameObject.GetComponentsInChildren <TextMesh>(true);
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            componentsInChildren[i].text = text;
            TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
        }
    }
Esempio n. 4
0
 public static void EnsureSpriteIcon(TextMesh[] target)
 {
     if (target == null || target.Length <= 0)
     {
         return;
     }
     for (int i = 0; i < target.Length; i++)
     {
         TextMeshSpriteIcons.EnsureSpriteIcon(target[i]);
     }
 }
Esempio n. 5
0
 public void UpdateTextMeshSpriteIcons()
 {
     TextMesh[] componentsInChildren = base.gameObject.GetComponentsInChildren <TextMesh>(true);
     if (componentsInChildren == null || componentsInChildren.Length == 0)
     {
         return;
     }
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
     }
 }
Esempio n. 6
0
    private void AddUnlockPopup(Button button, string levelName, string collectable, int collected, int required, int cost, Func <bool> requirements)
    {
        GameData gameData = Singleton <GameManager> .Instance.gameData;

        if (gameData.m_specialSandboxUnlockDialog != null && gameData.m_genericButtonPrefab != null)
        {
            GameObject gameObject             = UnityEngine.Object.Instantiate <GameObject>(gameData.m_specialSandboxUnlockDialog);
            SpecialSandboxUnlockDialog dialog = gameObject.GetComponent <SpecialSandboxUnlockDialog>();
            gameObject.transform.position = new Vector3(0f, 0f, -10f);
            button.MethodToCall.SetMethod(dialog, "Open");
            dialog.Type               = ((!collectable.Equals("Skulls")) ? SpecialSandboxUnlockDialog.UnlockType.Statue : SpecialSandboxUnlockDialog.UnlockType.Skull);
            dialog.Collected          = collected;
            dialog.Required           = required;
            dialog.Cost               = cost;
            dialog.ShowConfirmEnabled = (() => true);
            dialog.RebuildTexts();
            dialog.Close();
            CompactEpisodeTarget target = base.GetComponent <CompactEpisodeTarget>();
            dialog.SetOnConfirm(delegate
            {
                if (!GameProgress.GetSandboxUnlocked(levelName) && requirements() && GameProgress.UseSnoutCoins(cost))
                {
                    GameProgress.SetSandboxUnlocked(levelName, true);
                    GameProgress.SetButtonUnlockState("SandboxLevelButton_" + levelName, GameProgress.ButtonUnlockState.Locked);
                    target.SetAsLastTarget();
                    Singleton <GameManager> .Instance.ReloadCurrentLevel(true);
                    EventManager.Connect(new EventManager.OnEvent <LevelLoadedEvent>(this.DelayedPurchaseSound));
                    dialog.Close();
                }
                else if (!requirements() && Singleton <IapManager> .IsInstantiated())
                {
                    dialog.Close();
                    Singleton <IapManager> .Instance.OpenShopPage(new Action(dialog.Open), "SnoutCoinShop");
                }
                else
                {
                    dialog.Close();
                }
            });
        }
        if (this.collectSet != null)
        {
            string     text = string.Format("[snout] {0}", cost);
            TextMesh[] componentsInChildren = this.collectSet.GetComponentsInChildren <TextMesh>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                componentsInChildren[i].text = text;
                TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
            }
        }
    }
Esempio n. 7
0
    private void AddSMSandboxUnlockDialog(Button button, int cost, string levelIdentifier, Func <bool> requirements)
    {
        GameData gameData = Singleton <GameManager> .Instance.gameData;

        if (gameData.m_lpaUnlockDialog != null)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(gameData.m_lpaUnlockDialog);
            TextDialog dialog     = gameObject.GetComponent <TextDialog>();
            gameObject.transform.position = new Vector3(0f, 0f, -10f);
            button.MethodToCall.SetMethod(dialog, "Open");
            dialog.ConfirmButtonText = string.Format("[snout] {0}", cost);
            dialog.Close();
            dialog.ShowConfirmEnabled = (() => true);
            dialog.SetOnConfirm(delegate
            {
                if (!GameProgress.GetSandboxUnlocked(levelIdentifier) && requirements() && GameProgress.UseSnoutCoins(cost))
                {
                    GameProgress.SetSandboxUnlocked(levelIdentifier, true);
                    GameProgress.SetButtonUnlockState("SandboxLevelButton_" + levelIdentifier, GameProgress.ButtonUnlockState.Locked);
                    Singleton <GameManager> .Instance.ReloadCurrentLevel(true);
                    this.ReportUnlockSandbox(cost, levelIdentifier);
                    UnityEngine.Object.DontDestroyOnLoad(Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.snoutCoinUse));
                }
                else if (!requirements() && Singleton <IapManager> .IsInstantiated())
                {
                    dialog.Close();
                    Singleton <IapManager> .Instance.OpenShopPage(new Action(dialog.Open), "SnoutCoinShop");
                }
                else
                {
                    dialog.Close();
                }
            });
        }
        if (this.priceLabels != null && this.priceLabels.Length > 0)
        {
            string text = string.Format("[snout] {0}", cost);
            for (int i = 0; i < this.priceLabels.Length; i++)
            {
                this.priceLabels[i].text = text;
                TextMeshSpriteIcons.EnsureSpriteIcon(this.priceLabels[i]);
            }
        }
    }
Esempio n. 8
0
 private void RefreshTexts(GameObject target, string text, bool updateLocale, bool updateSprites)
 {
     TextMesh[] componentsInChildren = target.GetComponentsInChildren <TextMesh>(true);
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         componentsInChildren[i].text = text;
         if (updateLocale)
         {
             TextMeshLocale textMeshLocale = componentsInChildren[i].GetComponent <TextMeshLocale>();
             if (textMeshLocale == null)
             {
                 textMeshLocale = componentsInChildren[i].gameObject.AddComponent <TextMeshLocale>();
             }
             textMeshLocale.RefreshTranslation(null);
             textMeshLocale.enabled = false;
         }
         if (updateSprites)
         {
             TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
         }
     }
 }
Esempio n. 9
0
    private void RefreshLocalization()
    {
        for (int i = 0; i < this.texts.Length; i++)
        {
            this.texts[i].textMesh.text = this.texts[i].localizationKey;
            TextMeshLocale component = this.texts[i].textMesh.gameObject.GetComponent <TextMeshLocale>();
            if (component != null)
            {
                component.RefreshTranslation(null);
                string text = this.texts[i].textMesh.text;
                if (this.texts[i].textMesh.name.Equals("ScrapLabel") && text.Contains("{0}") && text.Contains("{1}"))
                {
                    string arg = string.Empty;
                    switch (this.partTier)
                    {
                    case BasePart.PartTier.Common:
                        arg = "[common_star]";
                        break;

                    case BasePart.PartTier.Rare:
                        arg = "[rare_star][rare_star]";
                        break;

                    case BasePart.PartTier.Epic:
                        arg = "[epic_star][epic_star][epic_star]";
                        break;

                    case BasePart.PartTier.Legendary:
                        arg = "[legendary_icon]";
                        break;
                    }
                    this.texts[i].textMesh.text = string.Format(text, this.buyScrapAmount, arg);
                }
                component.enabled = false;
                TextMeshSpriteIcons.EnsureSpriteIcon(this.texts[i].textMesh);
                TextMeshHelper.Wrap(this.texts[i].textMesh, (!TextMeshHelper.UsesKanjiCharacters()) ? this.maxCharactersInLine : this.maxKanjiCharacterInLine, false);
            }
        }
    }
Esempio n. 10
0
    public void SetCrateRankAndReward(LootCrateType crateType, int rank, int reward)
    {
        this.reward = reward;
        Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.rankLocalizationKey, null);

        TextMeshHelper.UpdateTextMeshes(this.rankLabel, string.Format(localeParameters.translation, rank), false);
        TextMeshHelper.Wrap(this.rankLabel, 15);
        Localizer.LocaleParameters localeParameters2 = Singleton <Localizer> .Instance.Resolve(this.snoutRewardLocalizationKey, null);

        TextMeshHelper.UpdateTextMeshes(this.rewardLabel, string.Format(localeParameters2.translation, reward), false);
        TextMeshSpriteIcons.EnsureSpriteIcon(this.rewardLabel);
        TextMeshHelper.Wrap(this.rewardLabel, 15);
        this.lootCrate.gameObject.SetActive(crateType != LootCrateType.None);
        this.barrelContainer.SetActive(crateType == LootCrateType.None);
        if (crateType != LootCrateType.None)
        {
            this.lootCrate.initialSkinName = crateType.ToString();
            this.lootCrate.Initialize(true);
            this.lootCrate.state.SetAnimation(0, "Idle", true);
            this.lootCrate.Update(Time.deltaTime);
        }
        this.SetLoading(false);
    }
Esempio n. 11
0
    public void InitPopup(int price, int secondsLeft, GameObject cratePrefab, LootCrateType lootCrate)
    {
        this.currentCrateType = lootCrate;
        this.SnoutCoinPrice   = price;
        if (this.priceLabel)
        {
            TextMesh[] componentsInChildren = this.priceLabel.gameObject.GetComponentsInChildren <TextMesh>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                componentsInChildren[i].text = string.Format("[snout] {0}", this.SnoutCoinPrice);
                TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
            }
        }
        string formattedTimeFromSeconds = LootCrateSlot.GetFormattedTimeFromSeconds(secondsLeft);

        if (this.timerLabel)
        {
            TextMesh[] componentsInChildren2 = this.timerLabel.gameObject.GetComponentsInChildren <TextMesh>();
            TextMeshHelper.UpdateTextMeshes(componentsInChildren2, formattedTimeFromSeconds, false);
        }
        if (this.unlockNowControls != null)
        {
            Transform transform = this.unlockNowControls.transform.Find("StartUnlockButton/TimeLabel");
            if (transform != null)
            {
                TextMesh[] componentsInChildren3 = transform.gameObject.GetComponentsInChildren <TextMesh>();
                TextMeshHelper.UpdateTextMeshes(componentsInChildren3, formattedTimeFromSeconds, false);
            }
        }
        if (this.skeletonAnimation)
        {
            this.skeletonAnimation.initialSkinName = lootCrate.ToString();
            this.skeletonAnimation.Initialize(true);
            this.skeletonAnimation.state.AddAnimation(0, "Idle", true, 0f);
        }
        this.InitRewardItems(lootCrate);
    }