コード例 #1
0
ファイル: UIGridPage.cs プロジェクト: coolape/mibao
        void resetCell(bool isForce)
        {
            if (currCell > 0)
            {
                NGUITools.SetActive(currPage.prev.data.gameObject, true);
            }
            //处理边界
            int pageCount = dataList.Length;

            //移动位置
            UIDragPageContents cell;
            Vector3            toPos = Vector3.zero;

            if (oldCurrCell < currCell)
            {
                cell = currPage.prev.data;
                if (arrangement == UIGrid.Arrangement.Horizontal)
                {
                    toPos    = currPage.data.transform.localPosition;
                    toPos.x += flag * cellWidth * 2;
                }
                else
                {
                    toPos    = currPage.data.transform.localPosition;
                    toPos.y -= flag * cellHeight * 2;
                }
            }
            else
            {
                cell = currPage.next.data;
                if (arrangement == UIGrid.Arrangement.Horizontal)
                {
                    toPos    = currPage.data.transform.localPosition;
                    toPos.x -= flag * cellWidth * 2;
                }
                else
                {
                    toPos    = currPage.data.transform.localPosition;
                    toPos.y += flag * cellHeight * 2;
                }
            }
            cell.transform.localPosition = toPos;
            if (isLimitless || (!isLimitless && (oldCurrCell != -1 || currCell != 0)))
            {
                if (oldCurrCell < currCell)
                {
                    currPage = currPage.next;
                }
                else
                {
                    currPage = currPage.prev;
                }
            }
        }
コード例 #2
0
ファイル: UIGridPage.cs プロジェクト: coolape/mibao
        void _init()
        {
            if (isFinishInit)
            {
                return;
            }
            isFinishInit         = true;
            dragSensitivity      = dragSensitivity <= 0 ? 1 : dragSensitivity;
            pages                = new LoopPage();
            pages.data           = page1;
            pages.next           = new LoopPage();
            pages.next.data      = page2;
            pages.next.next      = new LoopPage();
            pages.next.next.data = page3;
            pages.next.next.next = pages;

            pages.prev           = pages.next.next;
            pages.next.prev      = pages;
            pages.next.next.prev = pages.next;
            currPage             = pages;
        }
コード例 #3
0
ファイル: UIGridPage.cs プロジェクト: coolape/mibao
        void initCellPos(int index)
        {
            NGUITools.SetActive(page1.gameObject, true);
            NGUITools.SetActive(page2.gameObject, true);
            NGUITools.SetActive(page3.gameObject, true);

            Update();
            repositionNow = true;
            Update();

            currPage = pages;

            int pageCount = dataList.Length;

            if (pageCount <= 3)
            {
                #region
                //此段处理是为了让ngpc这种三个页面显示的数据不同的那种,让三个页面的位置固定
                switch (currCell)
                {
                case 0:
                    currPage = pages;
                    NGUITools.SetActive(page1.gameObject, true);
                    break;

                case 1:
                    currPage = pages.next;
                    break;

                case 2:
                    currPage = pages.prev;
                    break;

                default:
                    break;
                }

                switch (pageCount)
                {
                case 1:
                    NGUITools.SetActive(page1.gameObject, true);
                    NGUITools.SetActive(page2.gameObject, false);
                    NGUITools.SetActive(page3.gameObject, false);
                    break;

                case 2:
                    NGUITools.SetActive(page1.gameObject, true);
                    NGUITools.SetActive(page2.gameObject, true);
                    NGUITools.SetActive(page3.gameObject, false);
                    break;

                case 3:
                    NGUITools.SetActive(page1.gameObject, true);
                    NGUITools.SetActive(page2.gameObject, true);
                    NGUITools.SetActive(page3.gameObject, true);
                    break;

                default:
                    NGUITools.SetActive(page1.gameObject, false);
                    NGUITools.SetActive(page2.gameObject, false);
                    NGUITools.SetActive(page3.gameObject, false);
                    break;
                }
                #endregion
            }
            else
            {
                Vector3 toPos = Vector3.zero;
                if (arrangement == UIGrid.Arrangement.Horizontal)
                {
                    toPos.x = flag * cellWidth * (index);
                    currPage.data.transform.localPosition = toPos;
                    toPos.x = flag * cellWidth * (index - 1);
                    currPage.prev.data.transform.localPosition = toPos;
                    toPos.x = flag * cellWidth * (index + 1);
                    currPage.next.data.transform.localPosition = toPos;
                }
                else
                {
                    toPos.y = -flag * cellHeight * index;
                    currPage.data.transform.localPosition = toPos;
                    toPos.y = -flag * cellHeight * (index - 1);
                    currPage.prev.data.transform.localPosition = toPos;
                    toPos.y = -flag * cellHeight * (index + 1);
                    currPage.next.data.transform.localPosition = toPos;
                }
            }
            oldCurrCell = currCell;
            moveToCell.moveTo(index, isReverse, false);

            //刷新数据
            if (currCell <= 0)
            {
                NGUITools.SetActive(currPage.prev.data.gameObject, false);
            }

            if (currCell - 1 >= 0 && currCell - 1 < pageCount)
            {
                currPage.prev.data.init(dataList [currCell - 1], currCell - 1);                 //刷新数据
            }
            else
            {
                currPage.prev.data.init(null, currCell - 1);                 //刷新数据
            }
            if (currCell + 1 < pageCount && (currCell + 1) >= 0)
            {
                currPage.next.data.init(dataList [currCell + 1], currCell + 1);                 //刷新数据
            }
            else
            {
                currPage.next.data.init(null, currCell + 1);                 //刷新数据
            }

            if (dataList.Length > currCell && currCell >= 0)
            {
                currPage.data.refreshCurrent(currCell, dataList [currCell]);                 //刷新数据(放在最后)
                doCallback(dataList [currCell]);
            }
            else
            {
                currPage.data.refreshCurrent(currCell, null);                 //刷新数据(放在最后)
                doCallback(null);
            }
        }