Example #1
0
        public void Hide()
        {
            if (!isShow)
            {
                return;
            }

            isShow = false;
            IsBusy = true;
            if (showPanelTransit != null)
            {
                showPanelTransit.transit(false, () => { IsBusy = false; });
                for (int i = 0; i < itemList.Count; i++)
                {
                    BlockListItem item = itemList[i];
                    if (item.gameObject.activeSelf)
                    {
                        item.showTransit.transit(false, null);
                    }
                }
            }
            else
            {
                gameObject.SetActive(false);
                IsBusy = false;
            }
        }
Example #2
0
        public void Show()
        {
            if (isShow)
            {
                return;
            }

            isShow = true;
            IsBusy = true;

            if (showPanelTransit != null)
            {
                showPanelTransit.transit(true, () => { IsBusy = false; });
                if (showItemTransit != null)
                {
                    for (int i = 0; i < itemList.Count; i++)
                    {
                        BlockListItem item = itemList[i];
                        item.showTransit.resetTransit(true);
                        item.gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                gameObject.SetActive(true);
                IsBusy = false;
            }
        }
Example #3
0
        private void CalItemPos(BlockListItem item, int x, int y)
        {
            Transform trans = item.transform;

            float widthTotalHalf  = CountX * BlockListItem.ITEM_WIDTH / 2;
            float heightTotalHalf = CountY * BlockListItem.ITEM_HEIGHT / 2;

            float xx = ((float)x + 0.5f) * BlockListItem.ITEM_WIDTH - widthTotalHalf;
            float yy = -((float)y + 0.5f) * BlockListItem.ITEM_HEIGHT + heightTotalHalf;

            trans.localPosition = new Vector3(xx, yy, 0);
        }
Example #4
0
        public void OnClick(BlockListItem item)
        {
            if (IsBusy)
            {
                return;
            }

            if (cbClick != null)
            {
                cbClick(item.data);
            }
        }
Example #5
0
        public void Show()
        {
            IsBusy = true;
            showPanelTransit.transit(true, () => { IsBusy = false; });

            for (int i = 0; i < itemList.Count; i++)
            {
                BlockListItem item = itemList[i];
                item.showTransit.resetTransit(true);
                item.gameObject.SetActive(false);
            }
        }
Example #6
0
        public void Hide()
        {
            IsBusy = true;
            showPanelTransit.transit(false, () => { IsBusy = false; });

            for (int i = 0; i < itemList.Count; i++)
            {
                BlockListItem item = itemList[i];
                if (item.gameObject.activeSelf)
                {
                    item.showTransit.transit(false, null);
                }
            }
        }
Example #7
0
        public void ChangePage(int page)
        {
            if (page < 0)
            {
                page = 0;
            }
            if (page > PageCount)
            {
                page = PageCount;
            }

            if (isChangingPage)
            {
                return;
            }

            curPage = page;

            isChangingPage = true;


            for (int i = 0; i < countPerPage; i++)
            {
                BlockListItem item = itemList[i];
                if (item.gameObject.activeSelf)
                {
                    item.showTransit.delayTime = 0;
                }
            }

            showItemTransit.transit(false, HideOK);

            pageText.text = "" + curPage + " / " + pageCount;

            if (pageCount > 1)
            {
                prevReceiver.gameObject.SetActive(true);
                nextReceiver.gameObject.SetActive(true);
            }
            else
            {
                prevReceiver.gameObject.SetActive(false);
                nextReceiver.gameObject.SetActive(false);
            }
        }
Example #8
0
        private void HideOK()
        {
            if (showItemTransit != null)
            {
                int count = dataList.Count;
                for (int i = 0; i < countPerPage; i++)
                {
                    BlockListItem item = itemList[i];
                    if (i < count)
                    {
                        item.gameObject.SetActive(false);
                        item.showTransit.delayTime    = Random.Range(0f, 0.4f);
                        item.showTransit.transitGroup = 0;
                        item.data = dataList[i];
                    }
                    else
                    {
                        item.showTransit.transitGroup = 999;
                    }
                }

                showItemTransit.transit(true, () => { isChangingPage = false; });
            }
            else
            {
                int count = dataList.Count;
                for (int i = 0; i < countPerPage; i++)
                {
                    BlockListItem item = itemList[i];
                    if (i < count)
                    {
                        item.data = dataList[i];
                        item.gameObject.SetActive(true);
                    }
                    else
                    {
                        item.gameObject.SetActive(false);
                    }
                }
                isChangingPage = false;
            }
        }
Example #9
0
        public void Init()
        {
            Clear();

            for (int j = 0; j < CountY; j++)
            {
                for (int i = 0; i < CountX; i++)
                {
                    GameObject    obj  = PrefabUtils.CreateGameObjectToParent(grid, itemPrefab);
                    BlockListItem item = obj.GetComponent <BlockListItem>();
                    item.Init(this);

                    itemList.Add(item);

                    CalItemPos(item, i, j);
                }
            }

            countPerPage = CountX * CountY;

            prevReceiver.cbEnter = OnButtonEnter;
            prevReceiver.cbExit  = OnButtonExit;
            prevReceiver.cbTap   = OnTapPrev;

            nextReceiver.cbEnter = OnButtonEnter;
            nextReceiver.cbExit  = OnButtonExit;
            nextReceiver.cbTap   = OnTapNext;

            closeReceiver.cbEnter = OnButtonEnter;
            closeReceiver.cbExit  = OnButtonExit;
            closeReceiver.cbTap   = OnTapClose;

            loadingObj.SetActive(false);
            prevReceiver.gameObject.SetActive(false);
            nextReceiver.gameObject.SetActive(false);

            pageText.text = "";

            gameObject.SetActive(false);
        }