Esempio n. 1
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. 2
0
    private void AddRoadHogsUnlockDialog(Button button, string levelIdentifier, int price, Func <bool> requirements)
    {
        GameData gameData = Singleton <GameManager> .Instance.gameData;

        if (gameData.m_roadHogsUnlockDialog != null && gameData.m_genericButtonPrefab != null)
        {
            GameObject gameObject = base.transform.Find("Finger").gameObject;
            gameObject.GetComponent <Renderer>().enabled = true;
            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameData.m_roadHogsUnlockDialog);
            gameObject2.transform.position = new Vector3(0f, 0f, -15f);
            GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(gameData.m_genericButtonPrefab);
            gameObject3.transform.parent                  = base.transform;
            gameObject3.transform.localPosition           = Vector3.zero + new Vector3(0f, 0f, -1f);
            gameObject3.transform.localRotation           = Quaternion.identity;
            gameObject3.GetComponent <BoxCollider>().size = base.gameObject.GetComponent <BoxCollider>().size;
            TextDialog dialog = gameObject2.GetComponent <TextDialog>();
            button.MethodToCall.SetMethod(dialog, "Open");
            gameObject3.GetComponent <Button>().MethodToCall.SetMethod(dialog, "Open");
            dialog.ConfirmButtonText  = string.Format("[snout] {0}", price);
            dialog.ShowConfirmEnabled = (() => true);
            dialog.Close();
            dialog.SetOnConfirm(delegate
            {
                if (!GameProgress.GetRaceLevelUnlocked(levelIdentifier) && !GameProgress.IsLevelAdUnlocked(levelIdentifier) && requirements() && GameProgress.UseSnoutCoins(price))
                {
                    GameProgress.SetRaceLevelUnlocked(levelIdentifier, true);
                    GameProgress.SetButtonUnlockState("RaceLevelButton_" + levelIdentifier, GameProgress.ButtonUnlockState.Locked);
                    Singleton <GameManager> .Instance.ReloadCurrentLevel(true);
                    EventManager.Connect(new EventManager.OnEvent <LevelLoadedEvent>(this.DelayedPurchaseSound));
                }
                else if (!requirements() && Singleton <IapManager> .IsInstantiated())
                {
                    dialog.Close();
                    Singleton <IapManager> .Instance.OpenShopPage(new Action(dialog.Open), "SnoutCoinShop");
                }
                else
                {
                    dialog.Close();
                }
            });
        }
    }