Begin() static public method

Start the tweening process.
static public Begin ( GameObject go, Vector3 pos, float strength ) : SpringPanel,
go GameObject
pos Vector3
strength float
return SpringPanel,
Beispiel #1
0
    /// <summary>
    /// Restrict the scroll view's contents to be within the scroll view's bounds.
    /// </summary>

    public bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical)
    {
        Bounds  b          = bounds;
        Vector3 constraint = mPanel.CalculateConstrainOffset(b.min, b.max);

        if (!horizontal)
        {
            constraint.x = 0f;
        }
        if (!vertical)
        {
            constraint.y = 0f;
        }

        if (constraint.sqrMagnitude > 1f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
                Vector3 pos = mTrans.localPosition + constraint;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(mPanel.gameObject, pos, 13f);
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);
                mMomentum = Vector3.zero;
                mScroll   = 0f;
            }
            if (constraint.x > 0)
            {
                if (OnRightEdge != null)
                {
                    OnRightEdge();
                }
            }
            else if (constraint.x < 0)
            {
                if (OnLeftEdge != null)
                {
                    OnLeftEdge();
                }
            }
            if (constraint.y > 0)
            {
                if (OnTopEdge != null)
                {
                    OnTopEdge();
                }
            }
            else if (constraint.y < 0)
            {
                if (OnBottomEdge != null)
                {
                    OnBottomEdge();
                }
            }
            return(true);
        }
        return(false);
    }
Beispiel #2
0
    void InitUI()
    {
        m_btnBack.TextID   = 5195;
        m_btnReplay.TextID = 5194;
        m_txtSpecial.text  = "";
        //		m_txtTip.text = "";

        BattleSequence       battle = Core.Data.temper.warBattle;
        List <GPSRewardData> list   = new List <GPSRewardData> ();

        for (int i = 0; i < m_gridEnermy.transform.childCount; i++)
        {
            Transform tf = m_gridEnermy.transform.GetChild(i);
            tf.parent = null;
            Destroy(tf.gameObject);
        }

        for (int i = 0; i < m_gridReward.transform.childCount; i++)
        {
            Transform tf = m_gridReward.transform.GetChild(i);
            tf.parent = null;
            Destroy(tf.gameObject);
        }

        if (battle.reward != null && battle.reward.p != null)
        {
            battle.reward.p = AnalysisReward(battle.reward.p);

            for (int i = 0; i < battle.reward.p.Length; i++)
            {
                GPSRewardData rd = new GPSRewardData();
                rd.reward    = battle.reward.p [i];
                rd.IsSpecial = false;
                list.Add(rd);
            }
        }

        if (battle.radarReward != null && battle.radarReward.p != null)
        {
            for (int i = 0; i < battle.radarReward.p.Length; i++)
            {
                GPSRewardData rd = new GPSRewardData();
                rd.reward    = battle.radarReward.p [i];
                rd.IsSpecial = true;
                list.Add(rd);
            }
        }

        if (m_prefabReward == null)
        {
            m_prefabReward = PrefabLoader.loadFromPack("ZQ/GPSRewardItem");
        }
        if (m_prefabEmermy == null)
        {
            m_prefabEmermy = PrefabLoader.loadFromPack("ZQ/GPSEnermyItem");
        }
        for (int i = 0; i < list.Count; i++)
        {
            GameObject objRwd = Instantiate(m_prefabReward) as GameObject;
            RED.AddChild(objRwd, m_gridReward.gameObject);

            GPSRewardItem item = objRwd.GetComponent <GPSRewardItem>();
            item.SetGPSRewardData(list [i]);
        }

        List <int> enermys = BanBattleManager.Instance.GetDeadEnmeyList();

        if (enermys != null)
        {
            for (int i = 0; i < enermys.Count; i++)
            {
                Monster mon = new Monster();
                mon.config = Core.Data.monManager.getMonsterByNum(enermys [i]);

                GameObject objEmy = Instantiate(m_prefabEmermy) as GameObject;
                RED.AddChild(objEmy, m_gridEnermy.gameObject);
                GPSEnermyItem item = objEmy.GetComponent <GPSEnermyItem> ();
                item.SetEnermyData(mon);
            }
        }

        m_gridEnermy.Reposition();
        m_gridReward.Reposition();

        if (battle.radarReward != null && battle.radarReward.p != null)
        {
            string strName = "";
            for (int i = 0; i < Core.Data.gpsWarManager.curRoom.members.Length; i++)
            {
                if (Core.Data.gpsWarManager.curRoom.members [i].memberId == battle.radarReward.user_id)
                {
                    strName = Core.Data.gpsWarManager.curRoom.members [i].memberName;
                    break;
                }
            }

            string strText = Core.Data.stringManager.getString(5196);
            strText           = string.Format(strText, strName);
            m_txtSpecial.text = strText;
        }


        Vector3 tpos = Vector3.up * enermys.Count * 100;

        tpos.y -= 330;
        SpringPanel.Begin(m_gridEnermy.transform.parent.gameObject, tpos, 5.0f);

//		tpos = Vector3.up * list.Count * 100;
//		tpos.y -= 330;
//		SpringPanel.Begin(m_gridReward.transform.parent.gameObject, tpos, 5.0f);
    }
Beispiel #3
0
 private void ResetPosition()
 {
     SpringPanel.Begin(_showPanel.gameObject, Vector3.zero, 10000);
 }
Beispiel #4
0
    public override void tapButtonEventBase(GameObject gameObj, bool enable)
    {
        if (!enable)
        {
            return;
        }

        MaskWindow.LockUI();
        TapButtonBase[] buttons = tapContent.tapButtonList;

        //大于5个才进行居中
        if (buttons.Length > 5)
        {
            //选中的居中,排除头尾首2个
            if (gameObj != buttons [0].gameObject && gameObj != buttons [1].gameObject &&
                gameObj != buttons [buttons.Length - 1].gameObject && gameObj != buttons [buttons.Length - 2].gameObject)
            {
                SpringPanel.Begin(tapContent.gameObject, new Vector3(-gameObj.transform.localPosition.x, tapContent.transform.localPosition.y, tapContent.transform.localPosition.z), 9);
            }
            else if (gameObj == buttons [buttons.Length - 1].gameObject || gameObj == buttons [buttons.Length - 2].gameObject)
            {
                GameObject tempObj = buttons [buttons.Length - 3].gameObject;
                SpringPanel.Begin(tapContent.gameObject, new Vector3(-tempObj.transform.localPosition.x, tapContent.transform.localPosition.y, tapContent.transform.localPosition.z), 9);
            }
            else if (gameObj == buttons [0].gameObject || gameObj == buttons [1].gameObject)
            {
                GameObject tempObj = buttons [2].gameObject;
                SpringPanel.Begin(tapContent.gameObject, new Vector3(-tempObj.transform.localPosition.x, tapContent.transform.localPosition.y, tapContent.transform.localPosition.z), 9);
            }
        }

        updateArrow();

        if (gameObj == tapContent.tapButtonList [0].gameObject)
        {
            initTap(RankManagerment.TYPE_COMBAT, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_COMBAT);
                content.init(RankManagerment.TYPE_COMBAT, RankManagerment.Instance.combatList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 0;
            });
        }
        else if (gameObj == tapContent.tapButtonList [1].gameObject)
        {
            initTap(RankManagerment.TYPE_PVP, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_PVP);
                content.init(RankManagerment.TYPE_PVP, RankManagerment.Instance.pvpList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 1;
            });
        }
        else if (gameObj == tapContent.tapButtonList [2].gameObject)
        {
            initTap(RankManagerment.TYPE_ROLE, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_ROLE);
                content.init(RankManagerment.TYPE_ROLE, RankManagerment.Instance.roleList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 2;
            });
        }
        else if (gameObj == tapContent.tapButtonList [3].gameObject)
        {
            initTap(RankManagerment.TYPE_MONEY, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_MONEY);
                content.init(RankManagerment.TYPE_MONEY, RankManagerment.Instance.moneyList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 3;
            });
        }
        else if (gameObj == tapContent.tapButtonList [5].gameObject)
        {
            initTap(RankManagerment.TYPE_ROLE_LV, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_ROLE_LV);
                content.init(RankManagerment.TYPE_ROLE_LV, RankManagerment.Instance.roleLvList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 5;
            });
        }
        else if (gameObj == tapContent.tapButtonList [6].gameObject)
        {
            initTap(RankManagerment.TYPE_GODDESS, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_GODDESS);
                content.init(RankManagerment.TYPE_GODDESS, RankManagerment.Instance.goddessList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 6;
            });
        }
        else if (gameObj == tapContent.tapButtonList [7].gameObject)
        {
            initTap(RankManagerment.TYPE_LADDER, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_LADDER);
                content_ladder.fatherWindow = this;
                content_ladder.reLoad(RankManagerment.Instance.ladderList);

                if (RankManagerment.Instance.ladderList.Count > 0)
                {
                    label_tip.gameObject.SetActive(false);
                }
                else
                {
                    label_tip.gameObject.SetActive(true);
                }
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);

                tapIndex = 7;
                MaskWindow.UnlockUI();
            });
        }
        else if (gameObj == tapContent.tapButtonList [8].gameObject)
        {
            initTap(RankManagerment.TYPE_GUILD_FIGHT, () => {
                myRank = RankManagerment.Instance.getMyRank(RankManagerment.TYPE_GUILD_FIGHT);
                content.init(RankManagerment.TYPE_GUILD_FIGHT, RankManagerment.Instance.guildFightJudgeList, this);
                showMyRank(string.Empty);
                lab_intro.gameObject.SetActive(true);
                tapIndex = 8;
            });
        }

        //公会特殊
        if (gameObj == tapContent.tapButtonList [4].gameObject)
        {
            //显示我的排名
            string str = "";
            initTap(RankManagerment.TYPE_GUILD, () => {
                if (GuildManagerment.Instance.getGuild() == null)
                {
                    myRank = 0;
                    str    = LanguageConfigManager.Instance.getLanguage("s0417");
                }
                else
                {
                    myRank = RankManagerment.Instance.getMyGuildRank();
                    if (myRank == 0)
                    {
                        str = string.Format(LanguageConfigManager.Instance.getLanguage("s0415"), 100);
                    }
                    else
                    {
                        str = string.Format(LanguageConfigManager.Instance.getLanguage("s0416"), myRank);
                    }
                }
                content.init(RankManagerment.TYPE_GUILD, RankManagerment.Instance.guildList, this);
                showMyRank(str);
                tapIndex = 4;
            });
        }
    }
Beispiel #5
0
    /// <summary>
    /// Recenter the draggable list on the center-most child.
    /// </summary>

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

            if (mDrag == null)
            {
                Debug.LogWarning(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
                enabled = false;
                return;
            }
            else
            {
                mDrag.onDragFinished = OnDragFinished;

                if (mDrag.horizontalScrollBar != null)
                {
                    mDrag.horizontalScrollBar.onDragFinished = OnDragFinished;
                }

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

        // Calculate the panel's center in world coordinates
        Vector4   clip   = mDrag.panel.clipRange;
        Transform dt     = mDrag.panel.cachedTransform;
        Vector3   center = dt.localPosition;

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

        // Offset this value by the momentum
        Vector3 offsetCenter = center - 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 (setClosestTrans != null)
        {
            closest         = setClosestTrans;
            setClosestTrans = null;
        }

        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(center);
            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
            //if (setClosestTrans != null)
            //{
            //    Vector3 before = mDrag.gameObject.transform.localPosition;
            //    Vector3 after = dt.localPosition - offset;

            //    mDrag.gameObject.transform.localPosition = after;
            //    Vector3 off = after - before;
            //    Vector4 cr = mDrag.GetComponent<UIPanel>().clipRange;
            //    cr.x -= off.x;
            //    cr.y -= off.y;
            //    mDrag.GetComponent<UIPanel>().clipRange = cr;

            //    setClosestTrans = null;
            //}
            //else
            //{
            SpringPanel.Begin(mDrag.gameObject, dt.localPosition - offset, springStrength).onFinished = onFinished;
            //}
        }
        else
        {
            mCenteredObject = null;
        }
    }
Beispiel #6
0
    void onDragFinished()
    {
        Vector3 pos  = m_PetTeamPanel.gameObject.transform.localPosition;
        float   x    = pos.x - m_PetTeamPanelPos;
        float   step = 100.0f;

        if (x >= 0 || x < -800.0f)
        {
            // 默认的拖动效果..
        }
        else if (m_PetTeamIdx == 0)
        {
            if (x > -step)
            {
                x = 0.0f;
            }
            else if (x > -400.0f - step)
            {
                x = -400.0f;
            }
            else
            {
                x = -800.0f;
            }
        }
        else if (m_PetTeamIdx == 1)
        {
            if (x > -400.0f + step)
            {
                x = 0.0f;
            }
            else if (x > -400.0f - step)
            {
                x = -400.0f;
            }
            else
            {
                x = -800.0f;
            }
        }
        else if (m_PetTeamIdx == 2)
        {
            if (x > -400.0f + step)
            {
                x = 0.0f;
            }
            else if (x > -800.0f + step)
            {
                x = -400.0f;
            }
            else
            {
                x = -800.0f;
            }
        }

        if (x >= 0)
        {
            m_PetTeamIdx = 0;
        }
        else if (x == -400)
        {
            m_PetTeamIdx = 1;
        }
        else if (x <= -800)
        {
            m_PetTeamIdx = 2;
        }
        if (m_PetTeamIdx == 0)
        {
            m_spTeam1.spriteName = "d1"; m_spTeam2.spriteName = "d2"; m_spTeam3.spriteName = "d2";
        }
        else if (m_PetTeamIdx == 1)
        {
            m_spTeam1.spriteName = "d2"; m_spTeam2.spriteName = "d1"; m_spTeam3.spriteName = "d2";
        }
        else if (m_PetTeamIdx == 2)
        {
            m_spTeam1.spriteName = "d2"; m_spTeam2.spriteName = "d2"; m_spTeam3.spriteName = "d1";
        }

        if (x <= 0 && x >= -800.0f)
        {
            pos.x = x + m_PetTeamPanelPos;
            SpringPanel.Begin(m_PetTeamPanel.gameObject, pos, 13.0f);
        }
    }
Beispiel #7
0
    // Token: 0x06000079 RID: 121 RVA: 0x0001732C File Offset: 0x0001552C
    public void Recenter()
    {
        if (this.mDrag == null)
        {
            this.mDrag = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject);
            if (this.mDrag == null)
            {
                Debug.LogWarning(string.Concat(new object[]
                {
                    base.GetType(),
                    " requires ",
                    typeof(UIDraggablePanel),
                    " on a parent object in order to work"
                }), this);
                base.enabled = false;
                return;
            }
            this.mDrag.onDragFinished = new UIDraggablePanel.OnDragFinished(this.OnDragFinished);
            if (this.mDrag.horizontalScrollBar != null)
            {
                this.mDrag.horizontalScrollBar.onDragFinished = new UIScrollBar.OnDragFinished(this.OnDragFinished);
            }
            if (this.mDrag.verticalScrollBar != null)
            {
                this.mDrag.verticalScrollBar.onDragFinished = new UIScrollBar.OnDragFinished(this.OnDragFinished);
            }
        }
        if (this.mDrag.panel == null)
        {
            return;
        }
        Vector4   clipRange       = this.mDrag.panel.clipRange;
        Transform cachedTransform = this.mDrag.panel.cachedTransform;
        Vector3   vector          = cachedTransform.localPosition;

        vector.x += clipRange.x;
        vector.y += clipRange.y;
        vector    = cachedTransform.parent.TransformPoint(vector);
        Vector3 b = vector - this.mDrag.currentMomentum * (this.mDrag.momentumAmount * 0.1f);

        this.mDrag.currentMomentum = Vector3.zero;
        float     num        = float.MaxValue;
        Transform transform  = null;
        Transform transform2 = base.transform;
        int       i          = 0;
        int       childCount = transform2.childCount;

        while (i < childCount)
        {
            Transform child = transform2.GetChild(i);
            float     num2  = Vector3.SqrMagnitude(child.position - b);
            if (num2 < num && child.gameObject.activeSelf)
            {
                num       = num2;
                transform = child;
            }
            i++;
        }
        if (transform != null)
        {
            this.mCenteredObject = transform.gameObject;
            Vector3 a  = cachedTransform.InverseTransformPoint(transform.position);
            Vector3 b2 = cachedTransform.InverseTransformPoint(vector);
            Vector3 b3 = a - b2;
            if (this.mDrag.scale.x == 0f)
            {
                b3.x = 0f;
            }
            if (this.mDrag.scale.y == 0f)
            {
                b3.y = 0f;
            }
            if (this.mDrag.scale.z == 0f)
            {
                b3.z = 0f;
            }
            SpringPanel.Begin(this.mDrag.gameObject, cachedTransform.localPosition - b3, this.springStrength).onFinished = this.onFinished;
        }
        else
        {
            this.mCenteredObject = null;
        }
    }
Beispiel #8
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;
        }
    }
Beispiel #9
0
    public void ScorllToIndex(int index, int total)
    {
        if (index < 0)
        {
            index = 0;
        }
        mTotalItemLenght = total;
        if (index >= mTotalItemLenght)
        {
            return;
        }
        if (mScrollView.movement == UIScrollView.Movement.Vertical)
        {
//            if(index < mDisplayCount)
//            {
//                SpringPanel springPanel = gameObject.GetComponent<SpringPanel>();
//                if(springPanel != null)
//                    springPanel.enabled = false;
//                mPanel.clipOffset = new Vector2(mPanel.clipOffset.x , 0);
//                mScrollView.transform.localPosition = new Vector3(mScrollView.transform.localPosition.x , 0  , mScrollView.transform.localPosition.z);
//                SetUI(false);
//            }
            if (index < (mDisplayCount * 3))
            {
                mDisplayIdx = 0;
                int   pageIndex = index / mDisplayCount;
                float y         = 0;
                float detal     = 0;
                if (mPanel.GetViewSize().y >= mDisplayCount * mYSpace)
                {
                    detal = mPanel.GetViewSize().y - mDisplayCount * mYSpace;
                }
                if (index == 0)
                {
                    index = 0;
                }
                y = (mYSpace * index) + detal;
                SpringPanel springPanel = gameObject.GetComponent <SpringPanel>();
                if (springPanel != null)
                {
                    springPanel.enabled = false;
                }
//                mPanel.clipOffset = new Vector2(mPanel.clipOffset.x , -y);
//                mScrollView.transform.localPosition = new Vector3(mScrollView.transform.localPosition.x , y  , mScrollView.transform.localPosition.z);
//                mScrollView.contentPivot = UIWidget.Pivot.Bottom;
                SetUI(false);
                SpringPanel.Begin(mPanel.gameObject, new Vector3(mScrollView.transform.localPosition.x, y), 13.0f);
            }
            else
            {
                int   totalPage = Mathf.FloorToInt(mTotalItemLenght / mDisplayCount);
                int   curPage   = Mathf.FloorToInt(index / mDisplayCount);
                float indexY    = 0;
                int   pageCount = 0;
                if (curPage == totalPage)
                {
                    mDisplayIdx = (curPage - 2) * mDisplayCount;
                    int cutIndex = -((mTotalItemLenght - 1 - mDisplayIdx) % mDisplayCount) + 1;
                    indexY    = cutIndex * mYSpace;
                    pageCount = 2;
                }
                else
                {
                    mDisplayIdx = (curPage - 1) * mDisplayCount;
                    indexY      = Mathf.FloorToInt((index - mDisplayIdx) / mDisplayCount) * mDisplayCount * mYSpace;
                    pageCount   = 0;
                }
//                pageCount = Mathf.FloorToInt(index-mDisplayIdx)/mDisplayCount;
                float y     = 0;
                float detal = 0;
                if (mPanel.GetViewSize().y >= mDisplayCount * mYSpace)
                {
                    detal = mPanel.GetViewSize().y - mDisplayCount * mYSpace;
                }

                y = (pageCount * mYSpace * mDisplayCount) + indexY + detal;

                SpringPanel springPanel = gameObject.GetComponent <SpringPanel>();
                if (springPanel != null)
                {
                    springPanel.enabled = false;
                }

//                mScrollView.transform.localPosition = new Vector3(mScrollView.transform.localPosition.x , y  , mScrollView.transform.localPosition.z);
//                mPanel.clipOffset = new Vector2(mPanel.clipOffset.x , -y);
                SetUI(false);
                SpringPanel.Begin(mPanel.gameObject, new Vector3(mScrollView.transform.localPosition.x, y), 13.0f);
            }
        }
        else if (mScrollView.movement == UIScrollView.Movement.Horizontal)
        {
        }
    }
    public override void buttonEventBase(GameObject gameObj)
    {
        base.buttonEventBase(gameObj);
        if (gameObj.name == "close")
        {
            am.tapIndex = 0;
            UiManager.Instance.openMainWindow();
        }
        else if (gameObj.name == "buttonFinalAward")
        {
            UiManager.Instance.openWindow <ArenaAwardWindow> ((win) => {
                win.init(ArenaAwardWindow.TYPE_FINAL);
            });
        }
        else if (gameObj.name == "buttonGuessAward")
        {
            UiManager.Instance.openWindow <ArenaAwardWindow> ((win) => {
                win.init(ArenaAwardWindow.TYPE_GUESS);
            });
        }
        else if (gameObj.name == "buttonIntegralAward")
        {
            UiManager.Instance.openDialogWindow <ArenaIntegralAwardWindow> ((win) => {
                win.initUI();
            });
        }
        else if (gameObj.name == "buttonMeritShop")
        {
            UiManager.Instance.openWindow <MeritShopWindow> ();
        }
        else if (gameObj.name == "MyPosition")
        {
            if (myTeamIndex < 0)
            {
                UiManager.Instance.openDialogWindow <MessageWindow> ((win) => {
                    win.initWindow(1, Language("Arena70"), "", Language("Arena71"), null);
                });
                return;
            }
            if (am.tapIndex == myTeamIndex)
            {
                if (myPoint == null)
                {
                    MaskWindow.UnlockUI();
                    return;
                }
                SpringPanel.Begin(pointRoot, -myPoint.transform.localPosition, 9);
            }
            else
            {
                currentLookPositionType = LOOK_POSITION_MY_TYPE;
                tapContent.changeTapPage(tabButtons [myTeamIndex]);
            }
            MaskWindow.UnlockUI();
        }
        else if (gameObj.name == "focusCuess")
        {
            ArenaFocusGuess.FocusPointInfo pointInfo = focusGuess.focusCuessPoint();
            if (pointInfo == null)
            {
                if (guessTapIndex != -1)
                {
                    currentLookPositionType = LOOK_POSITION_CUESS_TYPE;
                    tapContent.changeTapPage(tabButtons [guessTapIndex]);
                }
            }
            else
            {
                if (am.tapIndex == pointInfo.getTapIndex())
                {
                    SpringPanel.Begin(pointRoot, -pointInfo.getFocusPoint(), 9);
                }
                else
                {
                    currentLookPositionType = LOOK_POSITION_CUESS_TYPE;
                    focusPointInfo          = pointInfo;
                    tapContent.changeTapPage(tabButtons [pointInfo.getTapIndex()]);
                }
            }
            MaskWindow.UnlockUI();
        }
        else if (gameObj.name == "buttonHelp")
        {
            UiManager.Instance.openDialogWindow <GeneralDesWindow>((win) => {
                string massTimeStr  = ArenaTimeSampleManager.Instance.getMassTimeString(ArenaManager.instance.state, ArenaManager.instance.stateEndTime);
                string finalTimeStr = ArenaTimeSampleManager.Instance.getFinalTimeString(ArenaManager.instance.state, ArenaManager.instance.stateEndTime);
                string rule         = LanguageConfigManager.Instance.getLanguage("Arena68", massTimeStr, finalTimeStr);
                win.initialize(rule, LanguageConfigManager.Instance.getLanguage("Arena69"), "");
            });
        }
        else if (gameObj.name == "next")
        {
            if (ArenaManager.instance.state == ArenaManager.STATE_RESET)
            {
                MaskWindow.UnlockUI();
                return;
            }

            UiManager.Instance.openDialogWindow <ArenaFinalPreduceTimeWindow>((win) => {
                win.initUI(ArenaManager.instance.getFinalPreduceDes());
            });
        }
    }
Beispiel #11
0
        public override void SetMenuData(object param)
        {
            if (param == null)
            {
                return;
            }

            base.SetMenuData(param);

            if (param is EB.IAP.Item)
            {
                curGiftType   = EGiftType.eCharge;
                curChargeData = param as EB.IAP.Item;

                //设置商品价钱
                if (MoneyPriceLab != null && curChargeData != null)
                {
                    MoneyPriceLab.text = curChargeData.localizedCost;
                }

                //设置奖励图标
                if (ShowItemList == null)
                {
                    //写死的密令奖励展示
                    string   str          = Data.NewGameConfigTemplateManager.Instance.GetGameConfigStrValue("BattlePassTips");
                    string[] allItemInfos = str.Split(',');
                    ShowItemList = new List <LTShowItem>();
                    string[] itemInfo;

                    if (ItemObj == null)
                    {
                        ItemObj = controller.transform.FindEx("Container/Content/Item").gameObject;
                    }

                    for (int i = 0; i < allItemInfos.Length; i++)
                    {
                        itemInfo = allItemInfos[i].Split(':');
                        GameObject itemObj  = GameObject.Instantiate(this.ItemObj, Grid.transform);
                        LTShowItem tempItem = itemObj.transform.Find("LTShowItem").GetMonoILRComponent <LTShowItem>();
                        itemObj.SetActive(true);
                        tempItem.LTItemData = new LTShowItemData(itemInfo[0], int.Parse(itemInfo[2]), itemInfo[1], false);
                        ShowItemList.Add(tempItem);
                    }

                    if (Grid != null)
                    {
                        Grid.enabled = true;
                        Grid.Reposition();
                    }

                    if (ScrollView != null)
                    {
                        SpringPanel.Begin(ScrollView.gameObject, new Vector3(0, -40, 0), 13.0f);
                        ScrollView.enabled = allItemInfos.Length > 12;
                    }
                }
            }
            else
            {
                EB.Debug.LogError("[{0}]为什么传入的数据类型不是 EB.IAP.Item? param.GetType():{1}", Time.frameCount, param.GetType());
            }
        }
    public void CenterOn(Transform target, Transform left, Transform right)
    {
        Vector3[] corners     = mScrollView.panel.worldCorners;
        Vector3   panelCenter = (corners[2] + corners[0]) * 0.5f;

        if (target != null && mScrollView != null && mScrollView.panel != null)
        {
            Transform panelTrans = mScrollView.panel.cachedTransform;
            mCenteredObject = target.gameObject;

            // Figure out the difference between the chosen child and the panel's center in local coordinates
            Vector3 cp       = panelTrans.InverseTransformPoint(target.position);
            Vector3 cc       = panelTrans.InverseTransformPoint(panelCenter);
            Vector3 leftSide = panelTrans.InverseTransformPoint(left.position);
            leftSide.x = leftSide.x - 55;

            Vector3 rightSide = panelTrans.InverseTransformPoint(right.position);
            rightSide.x = rightSide.x + 55;
            Vector3 corner0     = panelTrans.InverseTransformPoint(corners[0]);
            Vector3 corner2     = panelTrans.InverseTransformPoint(corners[2]);
            Vector3 localOffset = cp - cc;

            if (localOffset.x < 0)
            {
                if (leftSide.x < corner0.x)
                {
                    if (leftSide.x - corner0.x > localOffset.x)
                    {
                        localOffset.x = leftSide.x - corner0.x;
                    }
                }
                else
                {
                    localOffset.x = 0;
                }
            }
            else
            {
                if (rightSide.x > corner2.x)
                {
                    if (rightSide.x - corner2.x < localOffset.x)
                    {
                        localOffset.x = rightSide.x - corner2.x;
                    }
                }
                else
                {
                    localOffset.x = 0;
                }
            }
            // Offset shouldn't occur if blocked
            if (!mScrollView.canMoveHorizontally)
            {
                localOffset.x = 0f;
            }
            if (!mScrollView.canMoveVertically)
            {
                localOffset.y = 0f;
            }
            // Spring the panel to this calculated position
            SpringPanel.Begin(mScrollView.panel.cachedGameObject,
                              panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
        }
        else
        {
            mCenteredObject = null;
        }
    }
Beispiel #13
0
    /// <summary>
    /// Recenter the draggable list on the center-most child.
    /// </summary>

    public void CenterOn(Transform t)
    {
        if (mDrag == null)
        {
            mDrag = NGUITools.FindInParents <UIDraggablePanel>(gameObject);

            if (mDrag == null)
            {
                Debug.LogWarning(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
                enabled = false;
                return;
            }
            else
            {
                mDrag.onDragFinished = OnDragFinished;

                if (mDrag.horizontalScrollBar != null)
                {
                    mDrag.horizontalScrollBar.onDragFinished = OnDragFinished;
                }

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

        // ¬ычисление центра панели в мировых координатах
        Vector4   clip   = mDrag.panel.clipRange;
        Transform dt     = mDrag.panel.cachedTransform;
        Vector3   center = dt.localPosition;

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

        // —местить в зависимости от mDrag.currentMomentum
        //Vector3 offsetCenter = center - mDrag.currentMomentum * (mDrag.momentumAmount * 0.1f);
        mDrag.currentMomentum = Vector3.zero;

        mCenteredObject = t.gameObject;

        // ¬ычислить разницу между центром и иконкой в локальных координатах
        Vector3 cp     = dt.InverseTransformPoint(t.position);
        Vector3 cc     = dt.InverseTransformPoint(center);
        Vector3 offset = cp - cc;

        // ѕо каким то ос¤м нельз¤ трогать
        if (mDrag.scale.x == 0f)
        {
            offset.x = 0f;
        }
        if (mDrag.scale.y == 0f)
        {
            offset.y = 0f;
        }
        if (mDrag.scale.z == 0f)
        {
            offset.z = 0f;
        }

        // ѕереместить
        SpringPanel.Begin(mDrag.gameObject, dt.localPosition - offset, springStrength).onFinished = onFinished;
    }
Beispiel #14
0
    public void Recenter()
    {
        if (mDrag == null)
        {
            mDrag = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject);
            if (mDrag == null)
            {
                Debug.LogWarning(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
                base.enabled = false;
                return;
            }
            mDrag.onDragFinished = OnDragFinished;
            if (mDrag.horizontalScrollBar != null)
            {
                mDrag.horizontalScrollBar.onDragFinished = OnDragFinished;
            }
            if (mDrag.verticalScrollBar != null)
            {
                mDrag.verticalScrollBar.onDragFinished = OnDragFinished;
            }
        }
        if (mDrag.panel == null)
        {
            return;
        }
        Vector4   clipRange       = mDrag.panel.clipRange;
        Transform cachedTransform = mDrag.panel.cachedTransform;
        Vector3   vector          = cachedTransform.localPosition;

        vector.x += clipRange.x;
        vector.y += clipRange.y;
        vector    = cachedTransform.parent.TransformPoint(vector);
        Vector3 b = vector - mDrag.currentMomentum * (mDrag.momentumAmount * 0.1f);

        mDrag.currentMomentum = Vector3.zero;
        float     num        = float.MaxValue;
        Transform transform  = null;
        Transform transform2 = base.transform;
        int       i          = 0;

        for (int childCount = transform2.childCount; i < childCount; i++)
        {
            Transform child = transform2.GetChild(i);
            float     num2  = Vector3.SqrMagnitude(child.position - b);
            if (num2 < num)
            {
                num       = num2;
                transform = child;
            }
        }
        if (transform != null)
        {
            mCenteredObject = transform.gameObject;
            Vector3 a  = cachedTransform.InverseTransformPoint(transform.position);
            Vector3 b2 = cachedTransform.InverseTransformPoint(vector);
            Vector3 b3 = a - b2;
            if (mDrag.scale.x == 0f)
            {
                b3.x = 0f;
            }
            if (mDrag.scale.y == 0f)
            {
                b3.y = 0f;
            }
            if (mDrag.scale.z == 0f)
            {
                b3.z = 0f;
            }
            SpringPanel.Begin(mDrag.gameObject, cachedTransform.localPosition - b3, springStrength).onFinished = onFinished;
        }
        else
        {
            mCenteredObject = null;
        }
    }
Beispiel #15
0
 public void Recenter()
 {
     if (this.mDrag == null)
     {
         this.mDrag = NGUITools.FindInParents <UIDraggablePanel>(base.gameObject);
         if (this.mDrag == null)
         {
             Debug.LogWarning(string.Concat(new object[] { base.GetType(), " requires ", typeof(UIDraggablePanel), " on a parent object in order to work" }), this);
             base.enabled = false;
             return;
         }
         this.mDrag.onDragFinished = new UIDraggablePanel.OnDragFinished(this.OnDragFinished);
         if (this.mDrag.horizontalScrollBar != null)
         {
             this.mDrag.horizontalScrollBar.onDragFinished = new UIScrollBar.OnDragFinished(this.OnDragFinished);
         }
         if (this.mDrag.verticalScrollBar != null)
         {
             this.mDrag.verticalScrollBar.onDragFinished = new UIScrollBar.OnDragFinished(this.OnDragFinished);
         }
     }
     if (this.mDrag.panel != null)
     {
         Vector4   clipRange       = this.mDrag.panel.clipRange;
         Transform cachedTransform = this.mDrag.panel.cachedTransform;
         Vector3   localPosition   = cachedTransform.localPosition;
         localPosition.x += clipRange.x;
         localPosition.y += clipRange.y;
         localPosition    = cachedTransform.parent.TransformPoint(localPosition);
         Vector3 vector3 = localPosition - ((Vector3)(this.mDrag.currentMomentum * (this.mDrag.momentumAmount * 0.1f)));
         this.mDrag.currentMomentum = Vector3.zero;
         float     maxValue   = float.MaxValue;
         Transform transform2 = null;
         Transform transform  = base.transform;
         int       index      = 0;
         int       childCount = transform.childCount;
         while (index < childCount)
         {
             Transform child = transform.GetChild(index);
             float     num4  = Vector3.SqrMagnitude(child.position - vector3);
             if (num4 < maxValue)
             {
                 maxValue   = num4;
                 transform2 = child;
             }
             index++;
         }
         if (transform2 != null)
         {
             this.mCenteredObject = transform2.gameObject;
             Vector3 vector4 = cachedTransform.InverseTransformPoint(transform2.position);
             Vector3 vector5 = cachedTransform.InverseTransformPoint(localPosition);
             Vector3 vector6 = vector4 - vector5;
             if (this.mDrag.scale.x == 0f)
             {
                 vector6.x = 0f;
             }
             if (this.mDrag.scale.y == 0f)
             {
                 vector6.y = 0f;
             }
             if (this.mDrag.scale.z == 0f)
             {
                 vector6.z = 0f;
             }
             SpringPanel.Begin(this.mDrag.gameObject, cachedTransform.localPosition - vector6, this.springStrength).onFinished = this.onFinished;
         }
         else
         {
             this.mCenteredObject = null;
         }
     }
 }
Beispiel #16
0
    void CreateItemUI()
    {
        int i         = 0;
        int fastIndex = -1;
        //switch (curType)
        //{
        //    case 1:
        //        fastIndex = curLookMat;
        //        break;
        //    case 2:
        //        fastIndex = curLookPet;er
        //        break;
        //    case 3:
        //        fastIndex = curLookGem;
        //        break;
        //}
        List <BlendRef> listRef = ConfigMng.Instance.GetTypeBlend(curType);
        SynthesisItemUI ui      = null;

        uiiGrid.maxPerLine = listRef.Count;
        GameObject go      = null;
        UIToggle   itemTog = null;
        BlendRef   refa    = null;

        for (; i < listRef.Count; i++)
        {
            refa = listRef[i];
            if (list.Count <= i)
            {
                go = (GameObject)GameObject.Instantiate(uIGridItem);
                go.transform.parent        = uIGridItem.transform.parent;
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale    = Vector3.one;
                ui      = go.GetComponent <SynthesisItemUI>();
                itemTog = go.GetComponent <UIToggle>();

                if (ui != null)
                {
                    ui.RefData = refa;
                    list.Add(ui);
                }
            }
            else
            {
                ui         = list[i];
                ui.RefData = refa;
                itemTog    = ui.gameObject.GetComponent <UIToggle>();
            }
            itemTog.startsActive = false;
            itemTog.value        = false;
            EventDelegate.Remove(itemTog.onChange, ShowItemDes);
            EventDelegate.Add(itemTog.onChange, ShowItemDes);
            //UIEventListener.Get(itemTog.gameObject).onClick -= ShowItemDes;
            //UIEventListener.Get(itemTog.gameObject).onClick += ShowItemDes;
            //UIEventListener.Get(itemTog.gameObject).parameter = i;

            if (!uiTog.value)
            {
                ui.gameObject.SetActive(true);
                if (fastIndex < 0)
                {
                    fastIndex = i;
                }
            }
            else
            {
                ui.gameObject.SetActive(ui.num.enabled);
                if (fastIndex < 0 && ui.gameObject.activeSelf)
                {
                    fastIndex = i;
                }
            }
        }

        for (; i < list.Count; i++)
        {
            list[i].GetComponent <UIToggle>().value = false;
            list[i].gameObject.SetActive(false);
        }

        if (list.Count > fastIndex && fastIndex >= 0)
        {
            list[fastIndex].GetComponent <UIToggle>().startsActive = true;
            list[fastIndex].GetComponent <UIToggle>().value        = true;
        }
        uiiGrid.repositionNow = true;
        int listLenth = ConfigMng.Instance.GetTypeBlend(curType).Count;

        //Debug.Log("  listLenth  :  " + listLenth + "  curLookMat :  " + curLookMat + "    curLookPet  : " + curLookPet + "     curLookGem :  " + curLookGem);
        //switch (curType)
        //{
        //    case 1:
        //        if (listLenth > 5 && curLookMat > 0)
        //        {
        //            if (listLenth - curLookMat > 5)
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + curLookMat * 90, 0), 10f);
        //            }
        //            else
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + (listLenth - 5) * 90, 0), 10f);
        //            }
        //        }
        //        else
        //        {
        //            SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12, 0), 10f);
        //        }
        //        break;
        //    case 2:
        //        if (listLenth > 5 && curLookPet > 0)
        //        {
        //            if (listLenth - curLookPet > 5)
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + curLookPet * 90, 0), 10f);
        //            }
        //            else
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + (listLenth - 5) * 90, 0), 10f);
        //            }
        //        }
        //        else
        //        {
        //            SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12, 0), 10f);
        //        }
        //        break;
        //    case 3 :
        //        if (listLenth > 5 && curLookGem > 0)
        //        {
        //            if (listLenth - curLookGem > 5)
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + curLookGem * 90, 0), 10f);
        //            }
        //            else
        //            {
        //                SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12 + (listLenth - 5) * 90, 0), 10f);
        //            }
        //        }
        //        else
        //        {
        //            SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12, 0), 10f);
        //        }
        //        break;
        //}
        SpringPanel.Begin(uiiGrid.transform.parent.gameObject, new Vector3(72, 12, 0), 10f);
    }
    /// <summary>
    /// Center the panel on the specified target.
    /// </summary>

    void CenterOn(Transform target, Vector3 panelCenter)
    {
        if (target != null && mScrollView != null && mScrollView.panel != null)
        {
            Transform panelTrans = mScrollView.panel.cachedTransform;
            mCenteredObject = target.gameObject;

            // Figure out the difference between the chosen child and the panel's center in local coordinates
            Vector3 cp          = panelTrans.InverseTransformPoint(target.position);
            Vector3 cc          = panelTrans.InverseTransformPoint(panelCenter);
            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
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                panelTrans.localPosition = panelTrans.localPosition - localOffset;

                Vector4 co = mScrollView.panel.clipOffset;
                co.x += localOffset.x;
                co.y += localOffset.y;
                mScrollView.panel.clipOffset = co;
            }
            else
#endif
            {
                if (springStrength <= 0)
                {
                    panelTrans.localPosition = panelTrans.localPosition - localOffset;

                    Vector4 co = mScrollView.panel.clipOffset;
                    co.x += localOffset.x;
                    co.y += localOffset.y;
                    mScrollView.panel.clipOffset = co;
                }
                else
                {
                    SpringPanel.Begin(mScrollView.panel.cachedGameObject,
                                      panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
                }
            }
        }
        else
        {
            mCenteredObject = null;
        }

        // Notify the listener
        if (onCenter != null)
        {
            onCenter(mCenteredObject);
        }
    }
    // 현재 스크롤뷰 위치에서 아이템만 갱신.
    public void Refresh()
    {
        foreach (CListViewItem item in m_listItem)
        {
            if (item.m_Index < OnGetItemCount())
            {
                OnUpdateItem(item.m_Index, item.m_GameObject);
                item.m_GameObject.SetActive(true);
            }
            else
            {
                item.m_GameObject.SetActive(false);
            }
        }

        // 아이템이 줄어들어 빈공간이 보이면 뷰를 옮겨준다.
        Vector3 movePos      = new Vector3();
        Vector4 clip         = m_Panel.finalClipRegion;
        float   contentsSize = GetContentsSize();
        // blueasa
        //float contentsSize = GetContentsSizeMinusOne();
        float viewSize;

        if (m_bHorizontal)
        {
            m_InitBound = -(clip.z + m_ItemPadding.x) * 0.5f;
            viewSize    = clip.z;
            float viewPos = clip.x + clip.z * 0.5f;
            //float startPos = (-clip.z) * 0.5f + clip.z * 0.5f;
            //float limitPos = (-clip.z) * 0.5f + contentsSize - clip.z * 0.5f;
            float startPos = m_InitBound + clip.z * 0.5f;
            float limitPos = m_InitBound + contentsSize - clip.z * 0.5f;

            if (contentsSize < viewSize && viewPos > contentsSize - clip.z * 0.5f)
            {
                movePos.x = Mathf.Max(limitPos, startPos) - clip.x;
                SpringPanel.Begin(m_Panel.cachedGameObject, m_Panel.cachedTransform.localPosition - movePos, 8.0f);
            }
        }
        else
        {
            m_InitBound = (clip.w - m_ItemPadding.y) * 0.5f;
            viewSize    = clip.w;
            float viewPos  = clip.y - clip.w * 0.5f;
            float startPos = m_InitBound - clip.w * 0.5f;
            float limitPos = m_InitBound - contentsSize + clip.w * 0.5f;
            // blueasa
            //float limitPos = m_InitBound - GetContentsSizeMinusOne() + clip.w * 0.5f;

            // 위치 조절 안되는 버그 수정[blueasa / 2015-12-17]
            if (contentsSize < viewSize || viewPos < limitPos)
            {
                movePos.y = Mathf.Min(limitPos, startPos) - clip.y;
                SpringPanel.Begin(m_Panel.cachedGameObject, m_Panel.cachedTransform.localPosition - movePos, 8.0f);
            }
        }

        if (contentsSize < viewSize)
        {
            m_ScrollView.enabled = false;
        }
        else
        {
            m_ScrollView.enabled = true;
        }
    }
Beispiel #19
0
    public void AlignItem()
    {
        if (m_draggablePanel == null)
        {
            return;
        }

        UIDraggablePanel draggablePanel = m_draggablePanel.GetComponent <UIDraggablePanel> ();

        draggablePanel.onDragFinished = OnDragFinished;

        if (draggablePanel.horizontalScrollBar != null)
        {
            draggablePanel.horizontalScrollBar.onDragFinished = OnDragFinished;
        }

        if (draggablePanel.verticalScrollBar != null)
        {
            draggablePanel.verticalScrollBar.onDragFinished = OnDragFinished;
        }

        if (draggablePanel.panel == null)
        {
            return;
        }

        // Calculate the panel's center in world coordinates
        Vector4   clip   = draggablePanel.panel.clipRange;
        Transform dt     = draggablePanel.panel.cachedTransform;
        Vector3   center = dt.localPosition;

        center.x += clip.x;
        center.y += clip.y;

        center.x -= m_offsetX;
        center.y -= m_offsetY;
        center    = dt.parent.TransformPoint(center);

        // offset this value by the momentum
        Vector3 offsetCenter = center - draggablePanel.currentMomentum *
                               (draggablePanel.momentumAmount * 0.1f);

        draggablePanel.currentMomentum = Vector3.zero;

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

        // Determain the closest child
        for (int i = 0; i < trans.childCount; i++)
        {
            Transform t = trans.GetChild(i);

            /*
             * Vector3 pos = t.position;
             * pos.x += m_offsetX;
             * pos.y += m_offsetY;
             */

            /*
             * offsetCenter = dt.InverseTransformPoint(offsetCenter);
             * offsetCenter.x += m_offsetX;
             * offsetCenter.y += m_offsetY;
             * offsetCenter = dt.parent.TransformPoint(offsetCenter);
             */

            float sqrDist = Vector3.SqrMagnitude(t.position - offsetCenter);

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

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

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

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

            offset.x += m_offsetX;
            offset.y += m_offsetY;

            // Spring the panel to this calculated position
            SpringPanel.Begin(m_draggablePanel, dt.localPosition - offset, springStrength).onFinished = onFinished;
        }
        else
        {
            _alignItem = null;
        }
    }
Beispiel #20
0
    /// <summary>
    /// Restrict the scroll view's contents to be within the scroll view's bounds.
    /// </summary>

    public bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical)
    {
        if (mPanel == null)
        {
            return(false);
        }

        Bounds  b          = bounds;
        Vector3 constraint = mPanel.CalculateConstrainOffset(b.min, b.max);

        if (!horizontal)
        {
            constraint.x = 0f;
        }
        if (!vertical)
        {
            constraint.y = 0f;
        }
        #region add by oyp 2017.4.13
        if (NeedbackPosition)
        {
            Vector2 pv      = NGUIMath.GetPivotOffset(contentPivot);
            float   x       = pv.x;
            float   y       = 1 - pv.y;
            Vector4 clip    = mPanel.finalClipRegion;
            UIGrid  tUIGrid = gameObject.GetComponentInChildren <UIGrid>();
            float   hx      = clip.z * 0.5f;
            float   hy      = clip.w * 0.5f;

            float left = b.min.x + hx;
            if (tUIGrid != null && this.movement == Movement.Horizontal)
            {
                left = b.min.x + hx - (float)(tUIGrid.cellWidth * 0.5);
            }
            float right  = b.max.x - hx;
            float bottom = b.min.y + hy;
            float top    = b.max.y - hy;
            if (tUIGrid != null && this.movement == Movement.Vertical)
            {
                top = b.max.y - hy + (float)(tUIGrid.cellHeight * 0.5);
            }
            if (mPanel.clipping == UIDrawCall.Clipping.SoftClip)
            {
                left   -= mPanel.clipSoftness.x;
                right  += mPanel.clipSoftness.x;
                bottom -= mPanel.clipSoftness.y;
                top    += mPanel.clipSoftness.y;
            }

            // Calculate the offset based on the scroll value
            float ox = Mathf.Lerp(left, right, x);
            float oy = Mathf.Lerp(top, bottom, y);


            if (tUIGrid != null)
            {
                if (canMoveVertically && !shouldMoveVertically)
                {
                    constraint = new Vector3(pv.x, -oy - mTrans.localPosition.y, 0);
                }
                else if (canMoveHorizontally && !shouldMoveHorizontally)
                {
                    constraint = new Vector3(-ox - mTrans.localPosition.x, pv.y, 0);
                }
            }
        }
        #endregion
        if (constraint.sqrMagnitude > 0.1f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
                Vector3 pos = mTrans.localPosition + constraint;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(mPanel.gameObject, pos, 13f).strength = 8f;
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);

                // Clear the momentum in the constrained direction
                if (Mathf.Abs(constraint.x) > 0.01f)
                {
                    mMomentum.x = 0;
                }
                if (Mathf.Abs(constraint.y) > 0.01f)
                {
                    mMomentum.y = 0;
                }
                if (Mathf.Abs(constraint.z) > 0.01f)
                {
                    mMomentum.z = 0;
                }
                mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }
Beispiel #21
0
    /// <summary>
    /// Recenter the draggable list on the center-most child.
    /// </summary>

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

            if (mDrag == null)
            {
                Debug.LogWarning(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
                enabled = false;
                return;
            }
            else
            {
                mDrag.onDragFinished = OnDragFinished;
            }
        }
        if (mDrag.panel == null)
        {
            return;
        }

        // Calculate the panel's center in world coordinates
        Vector4   clip   = mDrag.panel.clipRange;
        Transform dt     = mDrag.panel.cachedTransform;
        Vector3   center = dt.localPosition;

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

        // Offset this value by the momentum
        Vector3 offsetCenter = center - 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(center);
            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, 8f).onFinished = onFinished;
            //ctrl the light
            //Debug.Log(mCenteredObject.transform.name);
            for (int i = 1; i < 7; i++)
            {
                if (mCenteredObject.transform.name.Substring(4, 1) == Lights.transform.FindChild("Light" + i).name.Substring(5, 1))
                {
                    Lights.transform.FindChild("Light" + i).GetComponent <UISprite>().spriteName = "Button1";
                }
                else
                {
                    Lights.transform.FindChild("Light" + i).GetComponent <UISprite>().spriteName = "Button";
                }
            }
        }
        else
        {
            mCenteredObject = null;
        }
    }
Beispiel #22
0
    /// <summary>
    /// 해당 아이템을 삭제한다.
    /// </summary>
    /// <param name="item"></param>
    public void RemoveItem(UIListItem item)
    {
        if (item.Prev != null)
        {
            item.Prev.Next = item.Next;
        }

        if (item.Next != null)
        {
            item.Next.Prev = item.Prev;
        }

        UIListItem tmp = item.Next as UIListItem;
        int        idx = item.Index;
        int        tempIdx;

        while (tmp != null)
        {
            tempIdx   = tmp.Index;
            tmp.Index = idx;
            mCallback(tmp, tmp.Index);

            idx = tempIdx;
            tmp = tmp.Next as UIListItem;
        }

        UIListItem tail = Tail;

        mList.Remove(item);

        if (ItemCount < mMinShowCount)
        {
            GameObject.DestroyImmediate(item.Target);
        }
        else
        {
            if (item == tail || Tail.Index >= ItemCount - 1)
            {
                // add head
                Head.Prev  = item;
                item.Next  = Head;
                item.Prev  = null;
                item.Index = Head.Index - 1;
                mList.Insert(0, item);
                mCallback(item, item.Index);

                Vector3 constraint = panel.CalculateConstrainOffset(bounds.min, bounds.max);
                SpringPanel.Begin(panel.gameObject, mTrans.localPosition + constraint, 13f).onFinished = UpdateCurrentPosition;
            }
            else
            {
                // add tail
                Tail.Next  = item;
                item.Prev  = Tail;
                item.Next  = null;
                item.Index = Tail.Index + 1;
                mList.Add(item);

                mCallback(item, item.Index);
            }
        }

        UpdatePosition();
    }
    public void setAoYiItem(List <AoYi> aoYiList, bool isDragonType, DragonManager.DragonType successdType = DragonManager.DragonType.None)
    {
        if (aoYiItemPrb == null)
        {
            aoYiItemPrb = PrefabLoader.loadFromPack("WHY/pbUIAoYiItem") as GameObject;
        }

        while (this.aoYiGrid.transform.childCount > 0)
        {
            GameObject g = this.aoYiGrid.transform.GetChild(0).gameObject;
            g.transform.parent = null;
            Destroy(g);
        }


        //------------  把未解锁的奥义放到后面 -------------
        List <AoYi> aoYiListTemp = new List <AoYi>();

        foreach (AoYi aoYi in aoYiList)
        {
            short dragonType = aoYi.AoYiDataConfig.dragonType;

            if (aoYi.AoYiDataConfig.unlockLevel > Core.Data.dragonManager.DragonList[dragonType - 1].RTData.lv)
            {
                aoYiListTemp.Add(aoYi);
            }
        }

        foreach (AoYi aoYi in aoYiListTemp)
        {
            aoYiList.Remove(aoYi);
            int index = aoYiList.Count;
            aoYiList.Insert(index, aoYi);
        }
        //------------ End 把未解锁的奥义放到后面 -------------


        foreach (AoYi aoYi in aoYiList)
        {
            short dragonType = aoYi.AoYiDataConfig.dragonType;

            if (isDragonType && dragonType != ((short)successdType + 1))
            {
                continue;
            }

            GameObject aoYiItemObj = Instantiate(aoYiItemPrb) as GameObject;
            AoYiSlot   aoYiSlot    = aoYiItemObj.GetComponent <AoYiSlot>();
            List_AoYiSlots.Add(aoYiSlot);

            aoYiSlot.transform.parent = aoYiGrid.transform;

            aoYiSlot.transform.localPosition = Vector3.zero;

            aoYiSlot.transform.localScale = Vector3.one;

            aoYiSlot.aoYi = aoYi;

            if (this.currentSelectAoYiAlertType == SelectAoYiAlertType.SelectLearnAoYi)
            {
                aoYiSlot.curAoYiType = AoYiSlot.ParentType.isLearnAoYi;
            }
            else if (this.currentSelectAoYiAlertType == SelectAoYiAlertType.SelectEquipAoYi)
            {
                aoYiSlot.curAoYiType = AoYiSlot.ParentType.isEquipAoYi;
            }

            aoYiSlot.SelectedDelegate = selectedAoYiSlot;

            if (/*aoYi.AoYiDataConfig.unlockLevel <= Core.Data.dragonManager.DragonList[dragonType - 1].RTData.lv &&*/ aoYi.ID != 0) // 已经学习解锁
            {
                aoYiSlot.setUnLock(false);
                if (aoYi.Pos != -1)
                {
                    aoYiSlot.stateRoot.SetActive(true);
                    aoYiSlot.stateIcon.gameObject.SetActive(false);
                    aoYiSlot.stateInfo.text = Core.Data.stringManager.getString(6111);
                }
            }
            else
            {
                aoYiSlot.aoYiIcon.atlas      = aoYiSlot.aoYiAtlas;
                aoYiSlot.aoYiIcon.spriteName = aoYi.AoYiDataConfig.ID.ToString();
                //aoYiSlot.aoYiIcon.MakePixelPerfect();
                aoYiSlot.aoYiIcon.color = Color.gray;

                aoYiSlot.aoYiName.text = aoYi.AoYiDataConfig.name;

                if (/*aoYi.AoYiDataConfig.unlockLevel <= Core.Data.dragonManager.DragonList[dragonType - 1].RTData.lv && */ aoYi.ID == 0) // 没学习   add by wxl
                {
                    aoYiSlot.lockRoot.SetActive(false);
                    aoYiSlot.stateRoot.SetActive(true);
                    aoYiSlot.stateIcon.gameObject.SetActive(false);
                    aoYiSlot.stateInfo.text = Core.Data.stringManager.getString(6112);
                }
//                else if(aoYiSlot.aoYi.AoYiDataConfig.unlockLevel > Core.Data.dragonManager.DragonList[dragonType - 1].RTData.lv && aoYiSlot.aoYi.ID == 0) // 没解锁    解锁功能  取消    by wxl
//				{
//					aoYiSlot.lockRoot.SetActive(true);
//					aoYiSlot.info.text = Core.Data.stringManager.getString(6099).Replace("#", aoYi.AoYiDataConfig.unlockLevel.ToString());
//				}
            }
        }

        aoYiGrid.Reposition();
//		aoYiGrid.GetComponentInParent<UIGrid> ().repositionNow = true;
        SpringPanel.Begin(aoYiGrid.transform.parent.gameObject, new Vector3(-451, -279, 0), 13);
    }
Beispiel #24
0
    //===============================================================================================


    public bool RestrictWithinBounds(Bounds bounds, bool instant, bool horizontal, bool vertical, bool constrainToTop, bool constrainToLeft)
    {
        // [modified] by wsh 2017/02/23
        // almost the same with original function except for adding params:bounds、constrainToTop、constrainToLeft
        if (mPanel == null)
        {
            return(false);
        }

        Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (!horizontal)
        {
            constraint.x = 0f;
        }
        if (!vertical)
        {
            constraint.y = 0f;
        }

        //===============================================================================================
        // [added] by wsh
        // constrainToTop if vertical or constrainToLeft if horizontal
        if (restrictWithinPanel && vertical && constrainToTop && bounds.size.y < mPanel.finalClipRegion.w)
        {
            float offset = 0f;
            if (constraint.y >= 0.01f)
            {
                offset = mPanel.finalClipRegion.w - bounds.size.y;
            }
            else if (Mathf.Abs(constraint.y) < 0.01f)
            {
                offset = (mPanel.finalClipRegion.y + mPanel.finalClipRegion.w * 0.5f) - bounds.max.y;
            }

            if (offset != 0f && mPanel.softBorderPadding && mPanel.clipping == UIDrawCall.Clipping.SoftClip)
            {
                offset -= mPanel.clipSoftness.y;
            }
            constraint.y += offset;
        }

        if (restrictWithinPanel && horizontal && constrainToLeft && bounds.size.x < mPanel.finalClipRegion.z)
        {
            float offset = 0f;
            if (constraint.x <= -0.01f)
            {
                offset = mPanel.finalClipRegion.z - bounds.size.x;
            }
            else if (Mathf.Abs(constraint.x) < 0.01f)
            {
                offset = bounds.min.x - (mPanel.finalClipRegion.x - mPanel.finalClipRegion.z * 0.5f);
            }
            if (offset != 0f && mPanel.softBorderPadding && mPanel.clipping == UIDrawCall.Clipping.SoftClip)
            {
                offset -= mPanel.clipSoftness.x;
            }
            constraint.x -= offset;
        }
        //===============================================================================================

        if (constraint.sqrMagnitude > 0.1f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
                Vector3 pos = mTrans.localPosition + constraint;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(mPanel.gameObject, pos, 8f);
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);

                // Clear the momentum in the constrained direction
                if (Mathf.Abs(constraint.x) > 0.01f)
                {
                    mMomentum.x = 0;
                }
                if (Mathf.Abs(constraint.y) > 0.01f)
                {
                    mMomentum.y = 0;
                }
                if (Mathf.Abs(constraint.z) > 0.01f)
                {
                    mMomentum.z = 0;
                }
                mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }