Ejemplo n.º 1
0
    //设置章节名
    public void SetChapterName(int chapterId)
    {
        int sceneId = -1;

        if (m_ChapterList != null)
        {
            for (int index = 0; index < m_ChapterList.Count; ++index)
            {
                if (m_ChapterList[index] != null && m_ChapterList[index].m_ChapterId == chapterId)
                {
                    UICurrentChapter uiChapter = m_ChapterList[index];
                    int j = 0;
                    for (j = 0; j < uiChapter.sceneArr.Length; ++j)
                    {
                        if (uiChapter.sceneArr[j] != null && uiChapter.sceneArr[j].GetSceneId() != -1)
                        {
                            sceneId = uiChapter.sceneArr[j].GetSceneId();
                            break;
                        }
                    }
                    if (j < uiChapter.sceneArr.Length)
                    {
                        break;
                    }
                }
            }
        }
        Data_SceneConfig sceneCfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);

        //todo:根据Id读取章节名
        if (lblName != null && sceneCfg != null)
        {
            lblName.text = sceneCfg.m_ChapterName;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Center the panel on the specified target.
    /// </summary>

    void CenterOn(UnityEngine.Transform target, UnityEngine.Vector3 panelCenter)
    {
        if (target != null && mScrollView != null && mScrollView.panel != null)
        {
            UnityEngine.Transform panelTrans = mScrollView.panel.cachedTransform;
            mCenteredObject = target.gameObject;
            //通知翻页
            UICurrentChapter currentChapter = mCenteredObject.GetComponent <UICurrentChapter>();
            UISceneSelect    sceneSelect    = NGUITools.FindInParents <UISceneSelect>(this.gameObject);
            if (sceneSelect != null && currentChapter != null)
            {
                sceneSelect.SetCurrentChapter(currentChapter.m_ChapterId);
            }
            // Figure out the difference between the chosen child and the panel's center in local coordinates
            UnityEngine.Vector3 cp          = panelTrans.InverseTransformPoint(target.position);
            UnityEngine.Vector3 cc          = panelTrans.InverseTransformPoint(panelCenter);
            UnityEngine.Vector3 localOffset = cp - cc;

            // Offset shouldn't occur if blocked
            if (!mScrollView.canMoveHorizontally)
            {
                localOffset.x = 0f;
            }
            if (!mScrollView.canMoveVertically)
            {
                localOffset.y = 0f;
            }
            localOffset.z = 0f;

            // Spring the panel to this calculated position
            SpringPanel.Begin(mScrollView.panel.cachedGameObject,
                              panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
        }
        else
        {
            mCenteredObject = null;
        }
    }
Ejemplo n.º 3
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;
    }