Example #1
0
        private void Refresh(bool doInitialize, bool autoCategorySelection, bool changeCategory = false)
        {
            string category;

            if (autoCategorySelection)
            {
                category = ChallengeMission.GetTopMostPriorityCategory(this.mCategories);
                int index = Array.FindIndex <ChallengeCategoryParam>(this.mCategories, (Predicate <ChallengeCategoryParam>)(cat => cat.iname == category));
                this.mCurrentCategoryIndex = index >= 0 ? index : 0;
            }
            else
            {
                category = this.mCategories[this.mCurrentCategoryIndex].iname;
            }
            for (int index = 0; index < this.mCategoryButtons.Count; ++index)
            {
                ((Component)this.mCategoryButtons[index].SelectionFrame).get_gameObject().SetActive(index == this.mCurrentCategoryIndex);
            }
            if (doInitialize)
            {
                for (int index = 0; index < this.mCategories.Length && index < this.mCategoryButtons.Count; ++index)
                {
                    bool        flag1             = false;
                    bool        flag2             = true;
                    TrophyParam currentRootTrophy = ChallengeMission.GetCurrentRootTrophy(this.mCategories[index].iname);
                    bool        flag3;
                    if (currentRootTrophy != null)
                    {
                        foreach (TrophyParam childeTrophy in ChallengeMission.GetChildeTrophies(currentRootTrophy))
                        {
                            TrophyState trophyCounter = ChallengeMission.GetTrophyCounter(childeTrophy);
                            if (!trophyCounter.IsEnded)
                            {
                                flag2 = false;
                                if (trophyCounter.IsCompleted)
                                {
                                    flag1 = true;
                                    break;
                                }
                            }
                        }
                        TrophyState trophyCounter1 = ChallengeMission.GetTrophyCounter(currentRootTrophy);
                        flag3 = flag1 || flag2 && !trophyCounter1.IsEnded;
                    }
                    else
                    {
                        flag3 = false;
                    }
                    ((Component)this.mCategoryButtons[index].Badge).get_gameObject().SetActive(flag3);
                }
            }
            TrophyParam[] rootTropies       = ChallengeMission.GetRootTropies(category);
            int           activeTrophyIndex = ChallengeMission.GetCurrentActiveTrophyIndex(rootTropies);

            if (doInitialize || changeCategory)
            {
                this.mCurrentPage = activeTrophyIndex;
            }
            TrophyParam trophyParam = rootTropies[this.mCurrentPage];

            this.mRootCount = rootTropies.Length;
            this.PageNumText.set_text((this.mCurrentPage + 1).ToString());
            this.PageMaxNumText.set_text(this.mRootCount.ToString());
            this.ChangeRewardImage(trophyParam);
            this.PageDotTemplate.SetActive(false);
            using (List <GameObject> .Enumerator enumerator = this.mDotsList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    UnityEngine.Object.Destroy((UnityEngine.Object)enumerator.Current);
                }
            }
            this.mDotsList.Clear();
            for (int index = 0; index < this.mRootCount; ++index)
            {
                GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.PageDotTemplate);
                this.mDotsList.Add(gameObject);
                gameObject.SetActive(true);
                ((Toggle)gameObject.GetComponent <Toggle>()).set_isOn(index == this.mCurrentPage);
                gameObject.get_transform().SetParent(this.PageDotsHolder.get_transform(), false);
            }
            ((Selectable)this.BackPageButton).set_interactable(true);
            ((Selectable)this.NextPageButton).set_interactable(true);
            if (this.mCurrentPage <= 0)
            {
                ((Selectable)this.BackPageButton).set_interactable(false);
            }
            if (this.mCurrentPage >= this.mRootCount - 1)
            {
                ((Selectable)this.NextPageButton).set_interactable(false);
            }
            if (this.mCurrentPage > activeTrophyIndex)
            {
                this.OpenNonAchievedPage(this.mCurrentPage);
            }
            else
            {
                this.OpenNewPage(trophyParam, doInitialize);
            }
        }