Exemplo n.º 1
0
    bool ShowSingleCard()
    {
        if (dataManager.IsSingleShowCard(m_uGotoCopyID))
        {
            m_scrollview_FbScrollView.gameObject.SetActive(false);
            m_widget_Panel.gameObject.SetActive(true);
            m_widget_FBCard.gameObject.SetActive(true);

            FBCard fb = m_widget_FBCard.gameObject.GetComponent <FBCard>();
            if (fb == null)
            {
                fb = m_widget_FBCard.gameObject.AddComponent <FBCard>();
            }
            //fb.DestroyScrollChild();
            CopyDataBase showDb = GameTableManager.Instance.GetTableItem <CopyDataBase>(m_uGotoCopyID);

            if (showDb != null)
            {
                fb.InitByCopyData(showDb);
            }
            UIEventListener.Get(m_widget_FBCard.gameObject).onClick = null;
            return(true);
        }
        return(false);
    }
Exemplo n.º 2
0
    void OnShowItemPanel(string itemName)
    {
        if (string.IsNullOrEmpty(itemName))
        {
            return;
        }
        Transform itemTrans = m_grid_FbGrid.transform.Find(itemName);

        if (itemTrans == null)
        {
            return;
        }
        GameObject go    = itemTrans.gameObject;
        int        index = 0;

        if (int.TryParse(itemName, out index))
        {
            m_nItemIndex = index;
        }

        if (IsTweening)
        {
            return;
        }
        IsTweening = true;

        List <CopyDataBase> copyList = dataManager.GetCopyListByCopyByCopyID(m_uGotoCopyID);

        if (index < copyList.Count)
        {
            CopyDataBase db = copyList[index];
            if (db != null)
            {
                FBCard fb = go.GetComponent <FBCard>();
                if (fb == null)
                {
                    fb = m_widget_FBCard.gameObject.AddComponent <FBCard>();
                }

                fb.InitByCopyData(db);
            }
        }
        UIDragScrollView drag = go.GetComponent <UIDragScrollView>();

        InitCopyNum();
        Transform subPanel = go.transform.Find("Panel");

        if (!bShowInfo)
        {
            drag.enabled = false;

            subPanel.DOScaleX(0, 0);
            m_endPos = GetScrollItemPosOnParent(go.transform.localPosition, index);
            subPanel.DOScaleX(1, m_fbackTime).OnComplete(() =>
            {
                bShowInfo  = true;
                IsTweening = false;
            });
            Log.LogGroup("ZDY", " pos is {0}", m_endPos);
            for (int i = 0; i <= index; i++)
            {
                string    itemname = string.Format("{0:D2}", i);
                Transform item     = m_grid_FbGrid.transform.Find(itemname);
                if (item != null)
                {
                    float offset = item.localPosition.x - m_endPos.x;
                    item.DOLocalMoveX(offset, m_fbackTime);
                }
            }
            int totoalCount = m_grid_FbGrid.transform.childCount;
            for (int j = index + 1; j < totoalCount; j++)
            {
                string    itemname = string.Format("{0:D2}", j);
                Transform item     = m_grid_FbGrid.transform.Find(itemname);
                if (item != null)
                {
                    float offset = item.localPosition.x + ((3 * (itemWidth + 12)) - m_endPos.x);
                    item.DOLocalMoveX(offset, m_fbackTime);
                }
            }
        }
        else
        {
            subPanel.DOScaleX(0, m_fbackTime).OnComplete(() =>
            {
                bShowInfo    = false;
                IsTweening   = false;
                drag.enabled = true;
            });
            for (int i = 0; i <= index; i++)
            {
                string    itemname = string.Format("{0:D2}", i);
                Transform item     = m_grid_FbGrid.transform.Find(itemname);
                if (item != null)
                {
                    float offset = item.localPosition.x + m_endPos.x;
                    item.DOLocalMoveX(offset, m_fbackTime);
                }
            }
            int totoalCount = m_grid_FbGrid.transform.childCount;
            for (int j = index + 1; j < totoalCount; j++)
            {
                string    itemname = string.Format("{0:D2}", j);
                Transform item     = m_grid_FbGrid.transform.Find(itemname);
                if (item != null)
                {
                    float offset = item.localPosition.x - ((3 * (12 + itemWidth)) - m_endPos.x);
                    item.DOLocalMoveX(offset, m_fbackTime);
                }
            }
        }
    }
Exemplo n.º 3
0
    void InitFbScroll()
    {
        UpdateExchangeBtnVisbile();
        if (ShowSingleCard())
        {
            return;
        }
        m_grid_FbGrid.transform.DestroyChildren();
        m_scrollview_FbScrollView.gameObject.SetActive(true);
        float y = m_scrollview_FbScrollView.transform.localPosition.y;

        m_scrollview_FbScrollView.transform.localPosition = new Vector3(m_fScrollInitX, y, 0);
        m_scrollview_FbScrollView.panel.clipOffset        = Vector2.zero;

        List <CopyDataBase> copyList = dataManager.GetCopyListByCopyByCopyID(m_uGotoCopyID);

        if (copyList == null)
        {
            return;
        }
        int chidlCount = m_grid_FbGrid.transform.childCount;

        if (chidlCount > copyList.Count)
        {
            for (int i = copyList.Count; i < chidlCount; i++)
            {
                string name = string.Format("{0:D2}", i);

                Transform itemTrans = m_grid_FbGrid.transform.Find(name);
                if (itemTrans != null)
                {
                    itemTrans.gameObject.SetActive(false);
                }
            }
        }
        for (int i = 0; i < copyList.Count; i++)
        {
            string     name = string.Format("{0:D2}", i);
            GameObject item = null;

            Transform itemTrans = m_grid_FbGrid.transform.Find(name);
            if (itemTrans == null)
            {
                item = NGUITools.AddChild(m_grid_FbGrid.gameObject, m_widget_FBCard.gameObject);
                item.SetActive(true);
                item.name = name;
                Vector3 localPos = new Vector3(i * itemWidth, 0, 0);
                item.transform.localPosition = localPos;
            }
            else
            {
                item = itemTrans.gameObject;
            }
            item.gameObject.SetActive(true);
            Transform subPanel = item.transform.Find("Panel");
            if (subPanel != null)
            {
                subPanel.gameObject.SetActive(true);
                subPanel.DOScaleX(0, 0);
            }
            CopyDataBase cdb = copyList[i];
            FBCard       fb  = item.GetComponent <FBCard>();
            if (fb == null)
            {
                fb = item.AddComponent <FBCard>();
            }
            fb.DestroyScrollChild();
            fb.InitByCopyData(cdb);

            UIEventListener.Get(item).onClick = OnItemClick;
        }

        m_grid_FbGrid.Reposition();
    }