Example #1
0
 private void OnEnable()
 {
     if (this.m_sandboxSelector != null && this.m_sandboxIdentifier.Equals("S-F") && GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier))
     {
         UnlockSandboxSequence          component         = base.GetComponent <UnlockSandboxSequence>();
         GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier);
         if (component == null && buttonUnlockState == GameProgress.ButtonUnlockState.Locked)
         {
             base.gameObject.AddComponent <UnlockSandboxSequence>();
         }
         Button component2 = base.GetComponent <Button>();
         component2.MethodToCall.SetMethod(this.m_sandboxSelector, "LoadSandboxLevel", this.m_sandboxIdentifier);
         string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
         this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str;
         for (int i = 0; i < this.hideOnContentUnlocked.Length; i++)
         {
             this.hideOnContentUnlocked[i].SetActive(false);
         }
         for (int j = 0; j < this.hideOnContentLocked.Length; j++)
         {
             this.hideOnContentLocked[j].SetActive(true);
         }
     }
 }
Example #2
0
    private void Start()
    {
        if (this.isBigSandboxButton && base.transform.parent != null)
        {
            this.m_sandboxSelector = base.transform.parent.GetComponent <SandboxSelector>();
        }
        if (this.m_sandboxSelector == null && base.transform.parent != null && base.transform.parent.parent != null)
        {
            this.m_sandboxSelector = base.transform.parent.parent.GetComponent <SandboxSelector>();
        }
        this.starSet = base.transform.Find("StarSet");
        if (this.starSet != null && !this.isBigSandboxButton)
        {
            this.starSet.parent = base.transform.parent;
        }
        UnlockSandboxSequence component = base.GetComponent <UnlockSandboxSequence>();
        bool flag      = GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier);
        bool isOdyssey = Singleton <BuildCustomizationLoader> .Instance.IsOdyssey;

        if (isOdyssey && (this.m_sandboxIdentifier.Equals("S-M") || this.m_sandboxIdentifier.Equals("S-F")))
        {
            flag = true;
        }
        if (!flag && this.m_sandboxIdentifier.Equals("S-M"))
        {
            UnityEngine.Debug.LogError("SandboxLevelButton S-M");
            int cost = this.GetUnlockPrice(this.m_sandboxIdentifier);
            this.AddSMSandboxUnlockDialog(base.GetComponent <Button>(), cost, this.m_sandboxIdentifier, () => GameProgress.SnoutCoinCount() >= cost);
        }
        else if (!flag && this.m_sandboxIdentifier.Equals("S-F"))
        {
            this.AddBuyFieldOfDreamsButton(base.GetComponent <Button>());
        }
        else if (!flag && !isOdyssey)
        {
            if (SandboxLevelButton.sandboxUnlockDialog == null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Singleton <GameManager> .Instance.gameData.m_sandboxUnlockDialog);
                gameObject.transform.position          = new Vector3(0f, 0f, -10f);
                SandboxLevelButton.sandboxUnlockDialog = gameObject.GetComponent <SandboxUnlockDialog>();
                SandboxLevelButton.sandboxUnlockDialog.Close();
            }
            int cost = this.GetUnlockPrice(this.m_sandboxIdentifier);
            this.AddSandboxUnlockDialog(base.GetComponent <Button>(), SandboxLevelButton.sandboxUnlockDialog, this.m_sandboxIdentifier, cost, () => GameProgress.SnoutCoinCount() >= cost);
        }
        else if (!flag && isOdyssey)
        {
            TooltipInfo component2 = base.GetComponent <TooltipInfo>();
            if (component2 != null)
            {
                this.setTooltipButton = base.GetComponent <Button>();
                this.setTooltipButton.MethodToCall.SetMethod(component2, "Show");
            }
        }
        GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier);
        if (flag)
        {
            if (component == null && buttonUnlockState == GameProgress.ButtonUnlockState.Locked)
            {
                base.gameObject.AddComponent <UnlockSandboxSequence>();
            }
            Button component3 = base.GetComponent <Button>();
            component3.MethodToCall.SetMethod(this.m_sandboxSelector, "LoadSandboxLevel", this.m_sandboxIdentifier);
            string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
            this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str;
            for (int i = 0; i < this.hideOnContentUnlocked.Length; i++)
            {
                this.hideOnContentUnlocked[i].SetActive(false);
            }
        }
        else if (!flag && this.m_starsText != null)
        {
            string arg = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
            this.m_starsText.text = string.Format("{0}/{1}", 0, arg);
            for (int j = 0; j < this.hideOnContentLocked.Length; j++)
            {
                this.hideOnContentLocked[j].SetActive(false);
            }
        }
    }