示例#1
0
 void SortAndRename(List <FCUIStoreItem> items)
 {
     uiDraggablePanel.DisableSpring();
     items.Sort(delegate(FCUIStoreItem left, FCUIStoreItem right)
     {
         int leftWeight  = 0;
         int rightWeight = 0;
         if (null != left.StoreData)
         {
             leftWeight  = left.StoreData.IsDiscount ? left.StoreData.order + 100000 : left.StoreData.order;
             rightWeight = right.StoreData.IsDiscount ? right.StoreData.order + 100000 : right.StoreData.order;
         }
         else if (null != left.StoreSCExchangeData)
         {
             leftWeight  = left.StoreSCExchangeData.Type;
             rightWeight = right.StoreSCExchangeData.Type;
         }
         return(leftWeight - rightWeight);
     });
     for (int i = 0, count = items.Count; i < count; ++i)
     {
         FCUIStoreItem item = items[i];
         item.name = i.ToString("000") + "(just4sort)";
     }
     grid.repositionNow = true;
     Reposition();
 }
    void Refresh()
    {
        float originaly = uiPanel.clipRange.w / 2 - gridOfferingGroup.cellHeight / 2 - 10;

        uiPanel.clipRange = new Vector4(uiPanel.clipRange.x,
                                        -originaly,
                                        uiPanel.clipRange.z,
                                        uiPanel.clipRange.w);
        uiPanel.transform.localPosition = new Vector3(uiPanel.clipRange.x,
                                                      originaly,
                                                      uiPanel.transform.localPosition.z);
        bonusDraggablePanel.DisableSpring();
        for (int i = 0; i < _offeringGroup.groupList.Count; i++)
        {
            SingleGroup sg       = _offeringGroup.groupList[i];
            ItemData    itemData = DataManager.Instance.ItemDataManager.GetItemData(sg.item);

            if (null == itemData)
            {
                continue;
            }

            GameObject clone = null;
            if (_offeringGroupList.ContainsKey(i))
            {
                clone = _offeringGroupList[i].gameObject;
            }
            else
            {
                clone = NGUITools.AddChild(gridOfferingGroup.gameObject, sampleBonusItem.gameObject);
                clone.transform.localPosition = sampleBonusItem.transform.localPosition;
                clone.SetActive(true);
                _offeringGroupList[i] = clone.GetComponent <OfferingGropSlot>();
            }
            OfferingGropSlot slot = clone.GetComponent <OfferingGropSlot>();
            slot.ItemData = itemData;
        }

        UIGrid uigrid = gridOfferingGroup.GetComponent <UIGrid>();

        uigrid.repositionNow = true;
        anchor.enabled       = true;
    }
示例#3
0
 public void RepositionEx(bool isX = false)
 {
     if (_ParentPanel != null)
     {
         Transform tmpTrans = _ParentPanel.GetComponent <Transform>();
         if (tmpTrans != null)
         {
             Vector3 deta = _InitPosition - tmpTrans.localPosition;
             Vector3 move = Vector3.zero;
             //暂时默认没有同时移动x跟y的拖动
             if (isX)
             {
                 move = new Vector3(deta.x, 0, 0);
             }
             else
             {
                 move = new Vector3(0, deta.y, 0);
             }
             _ParentPanel.DisableSpring();
             _ParentPanel.MoveRelative(move);
         }
     }
 }
示例#4
0
    public void OnShowRankMenu()
    {
        gameObject.SetActive(true);
        m_CharmFlowerBt.SetActive(GlobalData.IsOpenCharmRankFlag);
        m_CharmEggBt.SetActive(GlobalData.IsOpenCharmRankFlag);
        UIDraggablePanel panelDragble = m_MenuPanel.GetComponent <UIDraggablePanel>();

        if (panelDragble != null)
        {
            //Transform tmpTrans = panelDragble.GetComponent<Transform>();
            Transform panelDragTrans = m_MenuPanel.GetComponent <Transform>();
            if (panelDragTrans != null)
            {
                Vector3 deta = m_MenuPanelPos - panelDragTrans.localPosition;
                Vector3 move = Vector3.zero;
                move = new Vector3(0, deta.y, 0);
                panelDragble.DisableSpring();
                panelDragble.MoveRelative(move);
            }
        }


        //m_UIGrid.repositionNow = true;
    }
示例#5
0
    private void SwitchTab(object obj)
    {
        if (currentTab == (AwardTab)obj)
        {
            return;
        }

        SoundManager.Instance.PlaySoundEffect("Sound_Button_PVG_ListAwardIntroductionChange");
        currentTab = (AwardTab)obj;
        // 更改按钮显示
        DailyAwardTab.spriteSwithList.ApplyAllItem(P => P.ChangeSprite(currentTab == AwardTab.Daily? 2: 1));
        SeasonAwardTab.spriteSwithList.ApplyAllItem(P => P.ChangeSprite(currentTab == AwardTab.Season? 2: 1));
        LevelDescriptionTab.spriteSwithList.ApplyAllItem(P => P.ChangeSprite(currentTab == AwardTab.LevelDescription? 2: 1));

        RightTableHeader.text = (currentTab == AwardTab.LevelDescription)? "晋升条件": "奖励";

        // 列表中item只创建一次
        if (awardSingleItemList != null && awardSingleItemList.Count == 0)
        {
            for (int index = 0, imax = PvpUiPanelManager.Instance.GroupConfigDatabase._dataTable.Length; index < imax; index++)
            {
                GameObject item = NGUITools.AddChild(Grid.gameObject, PVPAwardSingleItemPrefab);
                item.name = PVPAwardSingleItemPrefab.name + index.ToString().PadLeft(2, '0');
                PVPAwardSingleItem itemScript = item.GetComponent <PVPAwardSingleItem>();
                awardSingleItemList.Add(itemScript);
            }

            Grid.sorted = true;
            Grid.Reposition();
        }

        DraggablePanel.DisableSpring();
        DraggablePanel.ResetPosition();

        UpdateSingleItem();
    }
示例#6
0
    /// <summary>
    /// Recenter the draggable list on the center-most child.
    /// </summary>

    public void Recenter(bool bResetToTop)
    {
        if (mDrag == null)
        {
            mDrag = NGUITools.FindInParents <UIDraggablePanel>(gameObject);

            if (mDrag == null)
            {
                LogModule.WarningLog(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
                enabled = false;
                return;
            }
            else
            {
                mDrag.onDragFinished += OnDragFinished;
                mPanelStartPos        = mDrag.transform.localPosition;
                UIPanel curPanel = mDrag.gameObject.GetComponent <UIPanel>();
                if (null != curPanel)
                {
                    mClipStartCenter = new Vector2(curPanel.clipRange.x, curPanel.clipRange.y);
                }
                if (mDrag.horizontalScrollBar != null)
                {
                    mDrag.horizontalScrollBar.onDragFinished = OnDragFinished;
                }

                if (mDrag.verticalScrollBar != null)
                {
                    mDrag.verticalScrollBar.onDragFinished = OnDragFinished;
                }
            }
        }
        if (mDrag.panel == null)
        {
            return;
        }

        if (bResetToTop)
        {
            mDrag.DisableSpring();
            mDrag.transform.localPosition = mPanelStartPos;
            Vector4 curRange = mDrag.panel.clipRange;
            curRange.x               = mClipStartCenter.x;
            curRange.y               = mClipStartCenter.y;
            mDrag.panel.clipRange    = curRange;
            mDrag.repositionClipping = true;
            return;
        }
        // Calculate the panel's center in world coordinates
        Vector4   clip = mDrag.panel.clipRange;
        Transform dt   = mDrag.panel.cachedTransform;

        Vector3 panelPos = dt.localPosition;
        Vector3 top      = panelPos;
        Vector3 bottom   = panelPos;

        if (mDrag.scale.y > 0)
        {
            top.y  = panelPos.y + clip.w * 0.5f - cellSize * 0.5f;
            top.x += clip.x;
            top.y += clip.y;
            top    = dt.parent.TransformPoint(top);

            if (transform.childCount * cellSize > clip.w)
            {
                bottom.y = panelPos.y - clip.w * 0.5f + cellSize * 0.5f;
            }
            else
            {
                bottom.y = panelPos.y + clip.w * 0.5f - cellSize * (transform.childCount - 0.5f);
            }

            bottom.x += clip.x;
            bottom.y += clip.y;
            bottom    = dt.parent.TransformPoint(bottom);

            //
            if (transform.childCount > 0)
            {
                if (transform.GetChild(transform.childCount - 1).position.y > bottom.y)
                {
                    top = bottom;
                }
            }
        }
        else
        {
            top.x  = panelPos.x - clip.z * 0.5f + cellSize * 0.5f;
            top.x += clip.x;
            top.y += clip.y;
            top    = dt.parent.TransformPoint(top);

            if (transform.childCount * cellSize > clip.z)
            {
                bottom.x = panelPos.x + clip.z * 0.5f - cellSize * 0.5f;
            }
            else
            {
                bottom.x = panelPos.x - clip.z * 0.5f + cellSize * (transform.childCount - 0.5f);
            }

            bottom.x += clip.x;
            bottom.y += clip.y;
            bottom    = dt.parent.TransformPoint(bottom);

            //
            if (transform.childCount > 0)
            {
                if (transform.GetChild(transform.childCount - 1).position.x < bottom.x)
                {
                    top = bottom;
                }
            }
        }

        // Offset this value by the momentum
        Vector3 offsetCenter = top - mDrag.currentMomentum * (mDrag.momentumAmount * 0.1f);

        mDrag.currentMomentum = Vector3.zero;

        float     min     = float.MaxValue;
        Transform closest = null;
        Transform trans   = transform;

        // Determine the closest child
        for (int i = 0, imax = trans.childCount; i < imax; ++i)
        {
            Transform t       = trans.GetChild(i);
            float     sqrDist = Vector3.SqrMagnitude(t.position - offsetCenter);

            if (sqrDist < min)
            {
                min     = sqrDist;
                closest = t;
            }
        }

        if (closest != null)
        {
            mCenteredObject = closest.gameObject;

            // Figure out the difference between the chosen child and the panel's center in local coordinates
            Vector3 cp     = dt.InverseTransformPoint(closest.position);
            Vector3 cc     = dt.InverseTransformPoint(top);
            Vector3 offset = cp - cc;

            // Offset shouldn't occur if blocked by a zeroed-out scale
            if (mDrag.scale.x == 0f)
            {
                offset.x = 0f;
            }
            if (mDrag.scale.y == 0f)
            {
                offset.y = 0f;
            }
            if (mDrag.scale.z == 0f)
            {
                offset.z = 0f;
            }

            // Spring the panel to this calculated position
            SpringPanel.Begin(mDrag.gameObject, dt.localPosition - offset, springStrength).onFinished = onFinished;
        }
        else
        {
            mCenteredObject = null;
        }
    }