Beispiel #1
0
    private void Start()
    {
        bool flag       = false;
        bool flag2      = false;
        bool flag3      = GameProgress.GetRaceLevelUnlocked(this.m_raceLevelIdentifier) || GameProgress.AllLevelsUnlocked();
        bool flag4      = LevelInfo.IsContentLimited(-1, this.m_levelNumber);
        bool flag5      = GameProgress.IsLevelAdUnlocked(this.m_raceLevelIdentifier);
        int  levelIndex = this.m_raceLevelSelector.m_raceLevels.GetLevelIndex(this.m_raceLevelIdentifier);

        if (levelIndex > 0)
        {
            RaceLevels.LevelData levelData = this.m_raceLevelSelector.m_raceLevels.Levels[levelIndex - 1];
            int @int = GameProgress.GetInt(levelData.SceneName + "_stars", 0, GameProgress.Location.Local, null);
            if (GameProgress.GetRaceLevelUnlocked(levelData.m_identifier) && @int > 0)
            {
                flag = true;
            }
            if (GameProgress.GetRaceLevelUnlocked(levelData.m_identifier) || GameProgress.AllLevelsUnlocked())
            {
                flag2 = true;
            }
        }
        if (!Singleton <BuildCustomizationLoader> .Instance.IsOdyssey && flag2 && !flag3)
        {
            int cost = Singleton <VirtualCatalogManager> .Instance.GetProductPrice("road_hogs_level_unlock");

            this.AddRoadHogsUnlockDialog(base.GetComponent <Button>(), this.m_raceLevelIdentifier, cost, () => GameProgress.SnoutCoinCount() >= cost);
        }
        else if (!flag3)
        {
            Animation animation = base.gameObject.AddComponent <Animation>();
            animation.AddClip(this.shake, this.shake.name);
            ButtonAnimation buttonAnimation = base.gameObject.AddComponent <ButtonAnimation>();
            buttonAnimation.PlayWholeAnimation    = true;
            buttonAnimation.ActivateAnimationName = this.shake.name;
            base.gameObject.AddComponent <InactiveButton>();
        }
        if (!flag4 && flag && !flag3)
        {
            GameProgress.SetRaceLevelUnlocked(this.m_raceLevelIdentifier, true);
        }
        if (flag4 && (flag || flag2 || flag5))
        {
            flag4 = false;
        }
        GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("RaceLevelButton_" + this.m_raceLevelIdentifier);
        if (flag3 && buttonUnlockState == GameProgress.ButtonUnlockState.Locked && !flag4)
        {
            base.StartCoroutine(this.UnlockNowSequence());
        }
        if ((flag3 && !flag4) || !base.transform.Find("Lock"))
        {
            Button component = base.GetComponent <Button>();
            component.MethodToCall.SetMethod(this.m_raceLevelSelector.gameObject.GetComponent <RaceLevelSelector>(), "LoadRaceLevel", this.m_raceLevelIdentifier);
            string       sceneName = WPFMonoBehaviour.gameData.FindRaceLevel(this.m_raceLevelIdentifier).SceneName;
            int          int2      = GameProgress.GetInt(this.m_raceLevelSelector.FindLevelFile(this.m_raceLevelIdentifier) + "_stars", 0, GameProgress.Location.Local, null);
            bool         flag6     = GameProgress.HasCollectedSnoutCoins(sceneName, 0);
            bool         flag7     = GameProgress.HasCollectedSnoutCoins(sceneName, 1);
            bool         flag8     = GameProgress.HasCollectedSnoutCoins(sceneName, 2);
            GameObject[] array     = new GameObject[]
            {
                component.transform.Find("StarSet/Star1").gameObject,
                component.transform.Find("StarSet/Star2").gameObject,
                component.transform.Find("StarSet/Star3").gameObject,
                component.transform.Find("CoinSet/Star1").gameObject,
                component.transform.Find("CoinSet/Star2").gameObject,
                component.transform.Find("CoinSet/Star3").gameObject
            };
            int num = 0;
            if (flag6)
            {
                num++;
            }
            if (flag7)
            {
                num++;
            }
            if (flag8)
            {
                num++;
            }
            for (int i = 0; i < 3; i++)
            {
                bool flag9  = i + 1 <= int2;
                bool flag10 = i + 1 <= num || Singleton <BuildCustomizationLoader> .Instance.IsOdyssey;
                array[i].SetActive(flag9 && !flag10);
                array[i + 3].SetActive(flag9 && flag10);
            }
            string sceneName2 = this.m_raceLevelSelector.m_raceLevels.GetLevelData(this.m_raceLevelIdentifier).SceneName;
            if (GameProgress.HasBestTime(sceneName2))
            {
                float    num2     = Mathf.Clamp(GameProgress.GetBestTime(sceneName2), 0f, 3599.99f);
                TimeSpan timeSpan = TimeSpan.FromSeconds((double)num2);
                base.transform.Find("BestTime").GetComponent <TextMesh>().text = string.Format("{0:D2}:{1:D2}.{2:D2}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds / 10);
                base.transform.Find("BestTime").gameObject.SetActive(true);
                base.transform.Find("TimeBG").gameObject.SetActive(true);
            }
        }
        else
        {
            base.transform.Find("StarSet").gameObject.SetActive(false);
            base.transform.Find("CoinSet").gameObject.SetActive(false);
            base.transform.Find("BestTime").gameObject.SetActive(false);
            base.transform.Find("TimeBG").gameObject.SetActive(false);
        }
    }