Ejemplo n.º 1
0
    //初始化所有章
    private void InitChapters(SubSceneType subType)
    {
        m_ChapterList.Clear();
        if (subType == SubSceneType.Common)
        {
            m_SubSceneType = SubSceneType.Common;
            SetButtonSprite(true);
        }
        else
        {
            m_SubSceneType = SubSceneType.Master;
            SetButtonSprite(false);
        }
        //初始化一些数据
        UICurrentChapter.m_UnLockNextScene = false;
        if (goChapter == null || centerOnChild == null)
        {
            return;
        }
        //应该读取所有章节信息
        UIGrid grid = centerOnChild.GetComponent <UIGrid>();

        if (grid == null)
        {
            return;
        }
        int chapterIndex = 1;

        int[] chapterInfo = new int[c_ScenePerChapter];
        ClearArr(chapterInfo);
        int  UnlockChapterMax    = -1;
        bool isNextChapterUnlock = true;

        while (GetChapterInfo(chapterIndex, chapterInfo, subType) && isNextChapterUnlock)
        {
            UnityEngine.GameObject go             = AddChapter(centerOnChild.gameObject, goChapter, chapterIndex - 1);
            UICurrentChapter       currentChapter = go.GetComponent <UICurrentChapter>();
            if (currentChapter != null)
            {
                bool isLockChapter = currentChapter.InitChapterById(chapterIndex, chapterInfo, subType, ref isNextChapterUnlock);
                m_ChapterList.Add(currentChapter);
                if (!isLockChapter && chapterIndex > UnlockChapterMax)
                {
                    UnlockChapterMax = chapterIndex;
                }
            }
            m_UnlockChapterMax = UnlockChapterMax;
            if (m_SubSceneType == SubSceneType.Common)
            {
                m_UnlockCommonChapterMax = UnlockChapterMax;
            }
            else
            {
                m_UnlockMasterChapterMax = UnlockChapterMax;
            }
            ClearArr(chapterInfo);
            grid.Reposition();
            chapterIndex++;
        }
        CenterOnChild(UnlockChapterMax);
        //删除多余章节
        DelChapter(centerOnChild.gameObject, chapterIndex);
        m_ChapterNumber = chapterIndex - 1;
    }