Inheritance: IgnoreTimeScale
Example #1
0
 protected virtual void AdvanceTowardsPosition()
 {
     float deltaTime = RealTime.deltaTime;
     bool flag = false;
     Vector3 localPosition = this.mTrans.localPosition;
     Vector3 vector = NGUIMath.SpringLerp(this.mTrans.localPosition, this.target, this.strength, deltaTime);
     if ((vector - this.target).sqrMagnitude < 0.01f)
     {
         vector = this.target;
         base.enabled = false;
         flag = true;
     }
     this.mTrans.localPosition = vector;
     Vector3 vector2 = vector - localPosition;
     Vector2 clipOffset = this.mPanel.clipOffset;
     clipOffset.x -= vector2.x;
     clipOffset.y -= vector2.y;
     this.mPanel.clipOffset = clipOffset;
     if (this.mDrag != null)
     {
         this.mDrag.UpdateScrollbars(false);
     }
     if (flag && this.onFinished != null)
     {
         SpringPanel.current = this;
         this.onFinished();
         SpringPanel.current = null;
     }
 }
Example #2
0
 public void Refresh()
 {
     if (this.mSpPanel == null)
     {
         this.mSpPanel = this.mClip.GetComponent<SpringPanel>();
     }
     if (this.mSpPanel != null && this.mSpPanel.enabled)
     {
         Vector3 target = this.mSpPanel.target;
         target.y = -32f;
         this.mSpPanel.target = target;
     }
     else
     {
         Vector3 localPosition = this.mClip.transform.localPosition;
         localPosition.y = -34f;
         this.mClip.transform.localPosition = localPosition;
         this.mClip.clipOffset = Vector2.zero;
     }
     GameUIVip.lastLookVIPDesc = this.vipLevel;
     this.vipLevelInfo = Globals.Instance.AttDB.VipLevelDict.GetInfo(this.vipLevel);
     this.groupPageDesc.Refresh(this.vipLevelInfo);
     this.groupGiftPacks.Refresh(this.vipLevelInfo);
     NGUITools.SetActive(this.btnPageLeft.gameObject, this.vipLevel > 1);
     NGUITools.SetActive(this.btnPageRight.gameObject, this.vipLevel < 15);
 }
Example #3
0
    /// <summary>
    /// Start the tweening process.
    /// </summary>

    static public SpringPanel Begin(GameObject go, Vector3 pos, float strength)
    {
        SpringPanel sp = go.GetComponent <SpringPanel>();

        if (sp == null)
        {
            sp = go.AddComponent <SpringPanel>();
        }
        sp.target     = pos;
        sp.strength   = strength;
        sp.onFinished = null;
        sp.mThreshold = 0f;
        sp.enabled    = true;
        return(sp);
    }
Example #4
0
    void SetFocusWithoutScrollBar(int index, SpringPanel.OnFinished onFinished = null)
    {
        if (index >= OnGetItemCount())
        {
            return;
        }

        Vector3 movePos = new Vector3();
        Vector4 clip    = m_Panel.finalClipRegion;

        float contentsSize = GetContentsSize();
        float viewSize     = 0f;

        if (m_bHorizontal)
        {
            viewSize = clip.z;
            int   columnCount = index / m_rowCount;
            float targetPos   = m_InitBound + columnCount * m_TotalItemSize.x;
            float startPos    = m_InitBound + clip.z * 0.5f;
            float limitPos    = m_InitBound + GetContentsSize() - clip.z * 0.5f;
            targetPos = Mathf.Max(targetPos, startPos);
            targetPos = Mathf.Min(targetPos, limitPos);
            movePos.x = targetPos - clip.x;
        }
        else
        {
            viewSize = clip.w;
            int   rowCount  = index / m_columnCount;
            float targetPos = m_InitBound - rowCount * m_TotalItemSize.y;
            float startPos  = m_InitBound - clip.w * 0.5f;
            float limitPos  = m_InitBound - GetContentsSize() + clip.w * 0.5f;
            // Vertical에서 아이템이 아래로 붙던 문제 수정[blueasa / 2015-12-08]
            targetPos = Mathf.Max(targetPos, limitPos);
            targetPos = Mathf.Min(targetPos, startPos);

            movePos.y = targetPos - clip.y;
        }

        // 컨텐츠 사이즈가 패널 사이즈보다 작을 때, 포커싱 이동 안하도록 수정[blueasa / 2015-11-16]
        // if (contentsSize > viewSize)
        {
            SpringPanel springPanel = SpringPanel.Begin(m_Panel.cachedGameObject, m_Panel.cachedTransform.localPosition - movePos, 8.0f);
            if (null != springPanel)
            {
                springPanel.onFinished = onFinished;
            }
        }
    }
Example #5
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 > 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);
    }
    /// <summary>
    /// Restrict the panel's contents to be within the panel's bounds.
    /// </summary>

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

        if (constraint.magnitude > 0.001f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
//				if(mPanel.clipping==UIDrawCall.Clipping.SoftClip)
//				{
//					if((bounds.max.y-bounds.min.y)<mPanel.clipRange.w)
//					{
//						constraint.y =mPanel.clipRange.w/2+ mPanel.clipSoftness.y;
//					}
//				}


                #region God
                if (!GodMove)
                {
                    SpringPanel.Begin(mPanel.gameObject, mTrans.localPosition + constraint, 13f);
                }
                else
                {
                    float leftPos  = -mGrid.cellWidth * (mGrid.transform.childCount - 1);
                    float rightPos = 0.0f;
                    bool  flag     = Mathf.Abs(leftPos - (mTrans.localPosition + constraint).x) >
                                     Mathf.Abs(rightPos - (mTrans.localPosition + constraint).x);

                    Vector3 target = mMoveTarget;
                    target.x = flag ? rightPos : leftPos;
                    target.y = mTrans.localPosition.y + constraint.y;
                    SpringPanel.Begin(mPanel.gameObject, target, 13f);
                }
                #endregion
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);
                mMomentum = Vector3.zero;
                mScroll   = 0f;
            }
            return(true);
        }
        return(false);
    }
Example #7
0
    public void RunToBottom()
    {
        if (!isRunFrist)
        {
            return;
        }
        isRunFrist = false;
        SpringPanel.Begin(_scrollView.gameObject, new Vector3(0, 156, -101), 8).onFinished = () =>
        {
            if (Core.Data.guideManger.isGuiding)
            {
                Core.Data.guideManger.DelayAutoRun(0.2f);
//				Debug.Log(" is finish  ????????????    ");
            }
        };
    }
    public static SpringPanel Begin(GameObject go, Vector3 pos, float strength)
    {
        //IL_001b: Unknown result type (might be due to invalid IL or missing references)
        //IL_001c: Unknown result type (might be due to invalid IL or missing references)
        SpringPanel springPanel = go.GetComponent <SpringPanel>();

        if (springPanel == null)
        {
            springPanel = go.AddComponent <SpringPanel>();
        }
        springPanel.target     = pos;
        springPanel.strength   = strength;
        springPanel.onFinished = null;
        springPanel.set_enabled(true);
        return(springPanel);
    }
Example #9
0
    public void OnPreButtonClicked()
    {
        if (animating)
        {
            return;
        }
        animating = true;

        var panelPosition   = panel.cachedTransform.localPosition;
        var offsizePosition = (panelPosition.x >= 0) ? Vector3.zero : new Vector3(CustomizeWidth, 0);

        SpringPanel.Begin(panel.cachedGameObject, panel.cachedTransform.localPosition + offsizePosition, SpringStrength).onFinished += () =>
        {
            animating = false;
        };
    }
Example #10
0
    private static int set_current(IntPtr L)
    {
        int result;

        try
        {
            SpringPanel current = (SpringPanel)ToLua.CheckUnityObject(L, 2, typeof(SpringPanel));
            SpringPanel.current = current;
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
 private void LateUpdate()
 {
     if (spring == null)
     {
         spring = base.GetComponent <SpringPanel>((Enum)UI.SCR_ABILITY);
     }
     if (spring != null && spring.get_enabled())
     {
         int i = 0;
         for (int num = spr.Length; i < num; i++)
         {
             UISprite component = base.GetComponent <UISprite>((Enum)spr[i]);
             component.UpdateAnchors();
         }
     }
 }
Example #12
0
    public void dragFinished()
    {
        if (mScroll == null)
        {
            Debuger.LogWarning("scroll view 为空");
            return;
        }

        if (!mScroll.shouldMoveHorizontally)
        {
            if (mScroll.dragEffect == UIScrollView.DragEffect.MomentumAndSpring)
            {
                SpringPanel.Begin(mScroll.GetComponent <UIPanel>().gameObject, startPos, 13f).strength = 8f;
            }
        }
    }
Example #13
0
    public void OnClickNinjaLevelC()
    {
        SpringPanel.Begin(ScrollView.gameObject, RawPos + Vector3.left * GridWidth * (CPageNum - 1), 13f);
        if (PageGroup != null)
        {
            PageGroup.CallLuaFunctionForLua("SetCurrentPage", CPageNum);
        }
        if (PageGroupNew != null)
        {
            PageGroupNew.CallLuaFunction("SetCurrentPage", CPageNum);
        }

        ObjNinajaLevelPopWindow.SetActive(false);

        LblNinjaLevel.text = "[ffcc00][u]C级忍者";
    }
Example #14
0
    public bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical)
    {
        if (this.mPanel == null)
        {
            return(false);
        }
        Bounds  bounds = this.bounds;
        Vector3 vector = this.mPanel.CalculateConstrainOffset(bounds.get_min(), bounds.get_max());

        if (!horizontal)
        {
            vector.x = 0f;
        }
        if (!vertical)
        {
            vector.y = 0f;
        }
        if (vector.get_sqrMagnitude() > 0.1f)
        {
            if (!instant && this.dragEffect == UIScrollView.DragEffect.MomentumAndSpring)
            {
                Vector3 pos = this.mTrans.get_localPosition() + vector;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(this.mPanel.get_gameObject(), pos, 13f).strength = 8f;
            }
            else
            {
                this.MoveRelative(vector);
                if (Mathf.Abs(vector.x) > 0.01f)
                {
                    this.mMomentum.x = 0f;
                }
                if (Mathf.Abs(vector.y) > 0.01f)
                {
                    this.mMomentum.y = 0f;
                }
                if (Mathf.Abs(vector.z) > 0.01f)
                {
                    this.mMomentum.z = 0f;
                }
                this.mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }
Example #15
0
    /// <summary>
    /// 실제 아이템 양 끝쪽에 임시 아이템을 생성 후 cllipping 되는 영역의 bound를 구한다.
    /// </summary>
    /// <param name="count"></param>
    private void SetTemplate(int count)
    {
        if (mFirstTemplate == null)
        {
            GameObject firstTemplate = ConstructRootPrefab();
            firstTemplate.SetActive(false);
            mFirstTemplate      = firstTemplate.transform;
            mFirstTemplate.name = "first rect";
        }

        if (mLastTemplate == null)
        {
            GameObject lastTemplate = ConstructRootPrefab();
            lastTemplate.SetActive(false);
            mLastTemplate      = lastTemplate.transform;
            mLastTemplate.name = "last rect";
        }

        float firstX = panel.baseClipRegion.x - ((panel.baseClipRegion.z - CellWidth) * 0.5f);
        float firstY = panel.baseClipRegion.y + ((panel.baseClipRegion.w - (CellHeight + EachItemPaddingForHeight) + panel.clipSoftness.y) * 0.5f);

        if (Arrangement == EArrangement.Vertical)
        {
            mFirstTemplate.localPosition = new Vector3(firstX,
                                                       firstY,
                                                       0);                                                                              //처음위치
            mLastTemplate.localPosition = new Vector3(firstX + (LineCount - 1) * CellWidth,
                                                      firstY - (CellHeight + EachItemPaddingForHeight) * ((count - 1) / LineCount), 0); //끝위치
        }
        else
        {
            mFirstTemplate.localPosition = new Vector3(firstX,
                                                       firstY,
                                                       0); //처음위치
            mLastTemplate.localPosition = new Vector3(firstX + CellWidth * ((count - 1) / LineCount),
                                                      firstY - (LineCount - 1) * (CellHeight + EachItemPaddingForHeight),
                                                      0); //끝위치
        }

        mCalculatedBounds           = true;
        mLastTemplate.localPosition = mLastTemplate.localPosition + MultiListOffSet;
        mBounds = CalculateRelativeWidgetBounds2(mTrans, mFirstTemplate, mLastTemplate);

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

        SpringPanel.Begin(panel.gameObject, mTrans.localPosition + constraint, 13f);
    }
Example #16
0
 //检测显示边界
 private void RestrictWithinBounds()
 {
     if (showItemGoLinkList.Count <= 0)
     {
         return;
     }
     if (mScrollView.isDragging)
     {
         return;
     }
     //处理在mdir=0时又不是首个/末个会回弹
     if (!bRestrictWithinPanel)
     {
         return;
     }
     if (ScrollViewHasSpace())
     {
         //-控制在头 左 / 上
         if (mMovement == UIScrollView.Movement.Vertical)
         {
             var scrollBounds = NGUIMath.CalculateRelativeWidgetBounds(mScrollView.transform);
             var center       = new Vector3(scrollBounds.center.x, scrollBounds.center.y - mScrollView.panel.clipOffset.y);
             scrollBounds.center = center;
             var calOffsetY = mPanelBounds.max.y - scrollBounds.max.y - mPanel.clipSoftness.y;
             //Debug.LogError(calOffsetY);
             var pos = mScrollView.transform.localPosition + new Vector3(0, calOffsetY, 0);
             pos.x = Mathf.Round(pos.x);
             pos.y = Mathf.Round(pos.y);
             SpringPanel.Begin(mPanel.gameObject, pos, 8f);
         }
         else if (mMovement == UIScrollView.Movement.Horizontal)
         {
             var scrollBounds = NGUIMath.CalculateRelativeWidgetBounds(mScrollView.transform);
             var center       = new Vector3(scrollBounds.center.x - mScrollView.panel.clipOffset.x, scrollBounds.center.y);
             scrollBounds.center = center;
             var calOffsetX = mPanelBounds.min.x - scrollBounds.min.x - mPanel.clipSoftness.x;
             var pos        = mScrollView.transform.localPosition + new Vector3(calOffsetX, 0, 0);
             pos.x = Mathf.Round(pos.x);
             pos.y = Mathf.Round(pos.y);
             SpringPanel.Begin(mPanel.gameObject, pos, 8f);
         }
     }
     else
     {
         mScrollView.RestrictWithinBounds(false);
     }
 }
Example #17
0
    public void ClickHeroCard(HeroCard card)
    {
        scrollView_SelectedPos = scrollView.transform.localPosition;

        List <HeroTypeData> typeData = MyCsvLoad.Instance.GetHeroTypeDatas(hero_Element, hero_Kingdom, hero_Class);
        bool existed = FindHeroByID(typeData, selectedCardID);
        bool removed = false;

        selectedCardID = card._id;
        if (!existed)
        {
            removed = RemoveSelectedHero(typeData, selectedCardID);
        }

        if (removed)
        {
            GameObject activeObj = GetLastActiveObject();

            if (activeObj != null)
            {
                activeObj.SetActive(false);
            }

            wrap.maxIndex--;
        }

        label_Hero_Name.text = card.GetHeroName();

        Transform trans = target.transform;

        if (trans.childCount > 0)
        {
            trans.DestroyChildren();
        }

        hero_info.SetActive(true);
        hero_info.transform.position = target.transform.position;

        GameObject go = Main.Instance.MakeObjectToTarget("Unit/tkc-ha_hu_don", target, Vector3.one, Vector3.one * 80);

        Utility.SetSpriteSortingOrderRecursive(go, 1);

        wrap.WrapContent(true);
        Transform wrap_trans = wrap.transform;

        SpringPanel.Begin(scrollView.panel.cachedGameObject, scrollView_SelectedPos, 8);
    }
Example #18
0
    public Boolean RestrictWithinBounds(Boolean instant, Boolean horizontal, Boolean vertical)
    {
        if (this.mPanel == (UnityEngine.Object)null)
        {
            return(false);
        }
        Bounds  bounds = this.bounds;
        Vector3 vector = this.mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (!horizontal)
        {
            vector.x = 0f;
        }
        if (!vertical)
        {
            vector.y = 0f;
        }
        if (vector.sqrMagnitude > 0.1f)
        {
            if (!instant && this.dragEffect == UIScrollView.DragEffect.MomentumAndSpring)
            {
                Vector3 pos = this.mTrans.localPosition + vector;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(this.mPanel.gameObject, pos, 13f).strength = 8f;
            }
            else
            {
                this.MoveRelative(vector);
                if (Mathf.Abs(vector.x) > 0.01f)
                {
                    this.mMomentum.x = 0f;
                }
                if (Mathf.Abs(vector.y) > 0.01f)
                {
                    this.mMomentum.y = 0f;
                }
                if (Mathf.Abs(vector.z) > 0.01f)
                {
                    this.mMomentum.z = 0f;
                }
                this.mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }
    // Token: 0x060002EC RID: 748 RVA: 0x0001CE50 File Offset: 0x0001B050
    public bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical)
    {
        if (this.mPanel == null)
        {
            return(false);
        }
        Bounds  bounds = this.bounds;
        Vector3 vector = this.mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (!horizontal)
        {
            vector.x = 0f;
        }
        if (!vertical)
        {
            vector.y = 0f;
        }
        if (vector.sqrMagnitude > 0.1f)
        {
            if (!instant && this.dragEffect == UIScrollView.DragEffect.MomentumAndSpring)
            {
                Vector3 vector2 = this.mTrans.localPosition + vector;
                vector2.x = Mathf.Round(vector2.x);
                vector2.y = Mathf.Round(vector2.y);
                SpringPanel.Begin(this.mPanel.gameObject, vector2, 8f);
            }
            else
            {
                this.MoveRelative(vector);
                if (Mathf.Abs(vector.x) > 0.01f)
                {
                    this.mMomentum.x = 0f;
                }
                if (Mathf.Abs(vector.y) > 0.01f)
                {
                    this.mMomentum.y = 0f;
                }
                if (Mathf.Abs(vector.z) > 0.01f)
                {
                    this.mMomentum.z = 0f;
                }
                this.mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }
Example #20
0
    public bool RestrictWithinBounds(bool instant, bool horizontal, bool vertical)
    {
        if (mPanel == null)
        {
            return(false);
        }
        Bounds  bounds = this.bounds;
        Vector3 vector = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (!horizontal)
        {
            vector.x = 0f;
        }
        if (!vertical)
        {
            vector.y = 0f;
        }
        if (vector.sqrMagnitude > 0.1f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                Vector3 pos = mTrans.localPosition + vector;
                pos.x = Mathf.Round(pos.x);
                pos.y = Mathf.Round(pos.y);
                SpringPanel.Begin(mPanel.gameObject, pos, 13f).strength = 8f;
            }
            else
            {
                MoveRelative(vector);
                if (Mathf.Abs(vector.x) > 0.01f)
                {
                    mMomentum.x = 0f;
                }
                if (Mathf.Abs(vector.y) > 0.01f)
                {
                    mMomentum.y = 0f;
                }
                if (Mathf.Abs(vector.z) > 0.01f)
                {
                    mMomentum.z = 0f;
                }
                mScroll = 0f;
            }
            return(true);
        }
        return(false);
    }
Example #21
0
    private void Scroll(float delta)
    {
        //IL_0001: Unknown result type (might be due to invalid IL or missing references)
        //IL_0006: Unknown result type (might be due to invalid IL or missing references)
        //IL_000c: Unknown result type (might be due to invalid IL or missing references)
        //IL_0011: Unknown result type (might be due to invalid IL or missing references)
        //IL_0016: Unknown result type (might be due to invalid IL or missing references)
        //IL_0024: Unknown result type (might be due to invalid IL or missing references)
        //IL_0029: Unknown result type (might be due to invalid IL or missing references)
        //IL_002f: Expected O, but got Unknown
        //IL_0036: Unknown result type (might be due to invalid IL or missing references)
        //IL_0037: Unknown result type (might be due to invalid IL or missing references)
        Vector3 pos = preScrollViewPosition + Vector3.get_up() * delta;

        SpringPanel.Begin(GetCtrl(UI.OBJ_SCROLL_VIEW).get_gameObject(), pos, 8f);
        preScrollViewPosition = pos;
    }
Example #22
0
 static int Begin(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         UnityEngine.Vector3    arg1 = ToLua.ToVector3(L, 2);
         float       arg2            = (float)LuaDLL.luaL_checknumber(L, 3);
         SpringPanel o = SpringPanel.Begin(arg0, arg1, arg2);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #23
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);
            }
        }

        for (int i = 0; i < buttons.Length; i++)
        {
            if (gameObj == buttons[i].gameObject)
            {
//				sampleContent.startIndex = i;
//				sampleContent.init();
                sampleContent.jumpTo(i);
                break;
            }
        }

        updateArrow();

        MaskWindow.UnlockUI();
    }
Example #24
0
 /// <summary>
 /// 轮播图滚动
 /// </summary>
 private void SlideMove()
 {
     if (!_moveState)
     {
         var showView = ScrollView.panel.GetViewSize();
         var moveVec  = new Vector3(showView.x * _moveDirection, 0);
         _moveState = true;
         SpringPanel.Begin(ScrollView.panel.cachedGameObject,
                           ScrollView.transform.localPosition - moveVec, _moveSpeed).onFinished += delegate
         {
             if (gameObject.activeInHierarchy)
             {
                 _coroutine = StartCoroutine(SlideWait());
             }
         };
     }
 }
Example #25
0
    public static SpringPanel Begin(GameObject go, Vector3 pos, float strength)
    {
        SpringPanel component = go.GetComponent <SpringPanel>();

        if (component == null)
        {
            component = go.AddComponent <SpringPanel>();
        }
        component.target   = pos;
        component.strength = strength;
        if (!component.enabled)
        {
            component.mThreshold = 0f;
            component.enabled    = true;
        }
        return(component);
    }
Example #26
0
 void OnPressItemPanel(GameObject game, bool state)
 {
     if (scrollView == null)
     {
         return;
     }
     if (state)
     {
         loPosition = UICamera.lastEventPosition;
     }
     else
     {
         if (loPosition != Vector2.zero)
         {
             float x = UICamera.lastEventPosition.x - loPosition.x;
             if (Mathf.Abs(x) > 20f)
             {
                 if (x < 0)
                 {
                     if (page < pageTotal)
                     {
                         page++;
                     }
                     pos = sp.target + new Vector3(-745, 0, 0);
                     if (pos.x > GameCenter.mailBoxMng.TotalPage * -745)
                     {
                         SpringPanel.Begin(scrollView.gameObject, pos, 10f);
                     }
                 }
                 if (x > 0)
                 {
                     if (page > 1)
                     {
                         page--;
                     }
                     pos = sp.target + new Vector3(745, 0, 0);
                     if (pos.x < 745)
                     {
                         SpringPanel.Begin(scrollView.gameObject, pos, 10f);
                     }
                 }
                 listPage[page - 1].SetSelect(true);
             }
         }
     }
 }
Example #27
0
    static int get_target(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel         obj = (SpringPanel)o;
            UnityEngine.Vector3 ret = obj.target;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index target on a nil value"));
        }
    }
Example #28
0
    static int set_strength(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel obj  = (SpringPanel)o;
            float       arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.strength = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index strength on a nil value"));
        }
    }
Example #29
0
    static int get_strength(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel obj = (SpringPanel)o;
            float       ret = obj.strength;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index strength on a nil value"));
        }
    }
Example #30
0
    static int get_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel            obj = (SpringPanel)o;
            SpringPanel.OnFinished ret = obj.onFinished;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onFinished on a nil value"));
        }
    }
Example #31
0
    static int set_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel            obj  = (SpringPanel)o;
            SpringPanel.OnFinished arg0 = (SpringPanel.OnFinished)ToLua.CheckDelegate <SpringPanel.OnFinished>(L, 2);
            obj.onFinished = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onFinished on a nil value"));
        }
    }
Example #32
0
    static int set_target(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SpringPanel         obj  = (SpringPanel)o;
            UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2);
            obj.target = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index target on a nil value"));
        }
    }
Example #33
0
    public override void OnCreate()
    {
        base.OnCreate();

        m_heartUI = UIWindowManager.Singleton.CreateWindow<UIWindow>("UIMapHeart", UIWindowManager.Anchor.TopLeft);

        m_backGroundTrans = mUIObject.transform;
        
        m_stageBtns = new Transform[GlobalVars.TotalStageCount];

        GlobalVars.AvailabeStageCount = PlayerPrefs.GetInt("StageAvailableCount");
        if (GlobalVars.AvailabeStageCount == 0)
        {
            GlobalVars.AvailabeStageCount = 1;
        }
		GlobalVars.StageStarArray = PlayerPrefsExtend.GetIntArray("StageStars", 0, 100);
        GlobalVars.StageScoreArray = PlayerPrefsExtend.GetIntArray("StageScores", 0, 100);
		GlobalVars.StageFailedArray = PlayerPrefsExtend.GetIntArray("StageFailed", 0, 100);
        GlobalVars.LastStage = GlobalVars.AvailabeStageCount;
		
		if(!PlayerPrefs.HasKey("Coins"))
		{
			GlobalVars.Coins = 10;
			PlayerPrefs.SetInt("Coins", 0);
		}
		else
		{
			GlobalVars.Coins = PlayerPrefs.GetInt("Coins");
		}
		
		GlobalVars.PurchasedItemArray = PlayerPrefsExtend.GetIntArray("PurchasedItemArray", 0, 2);
		
		springPanel = mUIObject.AddComponent<SpringPanel>();
        UIPanel panel = mUIObject.GetComponent<UIPanel>();
        panel.baseClipRegion = new Vector4(0, 0, CapsApplication.Singleton.Width, CapsApplication.Singleton.Height);

        m_timeNumber = UIToolkits.FindChild(m_heartUI.mUIObject.transform, "TimeNumber").gameObject;
        m_fullText = UIToolkits.FindChild(m_heartUI.mUIObject.transform, "HeartFull").gameObject;
        m_minNumber = m_heartUI.GetChildComponent<NumberDrawer>("MinNumber");
        m_secNumber = m_heartUI.GetChildComponent<NumberDrawer>("SecNumber");
    }
Example #34
0
 /// <summary>
 /// Disable the spring movement.
 /// </summary>
 public void DisableSpring()
 {
     sp = GetComponent<SpringPanel>();
     if (sp != null) sp.enabled = false;
 }
Example #35
0
    /// <summary>
    /// Advance toward the target position.
	/// </summary>

	protected virtual void AdvanceTowardsPosition ()
	{
		float delta = RealTime.deltaTime;

		bool trigger = false;
		Vector3 before = mTrans.localPosition;
		Vector3 after = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, delta);

		if ((after - target).sqrMagnitude < 0.01f)
		{
			after = target;
			enabled = false;
			trigger = true;
		}
		mTrans.localPosition = after;

		Vector3 offset = after - before;
		Vector2 cr = mPanel.clipOffset;
		cr.x -= offset.x;
		cr.y -= offset.y;
		mPanel.clipOffset = cr;

		if (mDrag != null) mDrag.UpdateScrollbars(false);

		if (trigger && onFinished != null)
		{
			current = this;
			onFinished();
			current = null;
		}
    }
Example #36
0
    private void SpringBegin(int strength = 8)
    {
        sp = gameObject.GetComponent<SpringPanel>();
        if (sp == null) sp = gameObject.AddComponent<SpringPanel>();

        Vector3 vec = Vector3.zero;

        if (dragDirec == MyDragDirection.Horizontal)
        {
            vec = new Vector3(-1 * (maxPageOffsetX + minPageOffsetX) * index + startSvcPos.x, startSvcPos.y, 0);
        }

        if (dragDirec == MyDragDirection.Vertical)
        {
            vec = new Vector3(startSvcPos.x, -1 * (maxPageOffsetY + minPageOffsetY) * index + startSvcPos.y, 0);
        }
        //Debug.Log(index + "---"+vec);
        svcPos = vec;
        sp.target = vec;
        sp.strength = strength;
        sp.enabled = true;

        ////改变标识点
        ChangePoint(index);
        if (ondragFinished != null)
        {
            ondragFinished(index);
        }
    }
Example #37
0
	/// <summary>
	/// Start the tweening process.
	/// </summary>

	static public SpringPanel Begin (GameObject go, Vector3 pos, float strength)
	{
		SpringPanel sp = go.GetComponent<SpringPanel>();
		if (sp == null) sp = go.AddComponent<SpringPanel>();
		sp.target = pos;
		sp.strength = strength;
		sp.onFinished = null;
		sp.enabled = true;
		if (sp.onFinishedEx != null)
		{
			current = sp;
			sp.onFinishedEx(0, pos);
			current = null;
		}
		return sp;
	}
    void SpringBegin(int strength = 8)
    {
        sp = gameObject.GetComponent<SpringPanel>();
        if (sp == null) sp = gameObject.AddComponent<SpringPanel>();

        Vector3 vec = Vector3.zero;

        if (dragDirec == MyDragDirection.Horizontal)
        {
            vec = new Vector3(-1 * (maxPageOffsetX + minPageOffsetX) * index + startSvcPos.x, startSvcPos.y, 0);
        }

        if (dragDirec == MyDragDirection.Vertical)
        {
            vec = new Vector3(startSvcPos.x, -1 * (maxPageOffsetY + minPageOffsetY) * index + startSvcPos.y, 0);
        }
        //Debug.Log(index + "---"+vec);
        svcPos = vec;
        sp.target = vec;
        sp.strength = strength;
        sp.enabled = true;
        sp.finished = AddAndRemoveLinkedList;

        ////改变标识点
        ChangePoint(index);

        if (ondragFinished != null)
        {
            ondragFinished(index);
        }

        int pageCount = CellCount * RowCount;
        int firstID = Convert.ToInt32(items[0].name);
        firstID = firstID / pageCount;  //1
        int itemsIndex = (index - firstID) * pageCount;
        if (itemsIndex >= 0 && itemsIndex < items.Count)
        {
            currentStartItem = items[itemsIndex];
            //Debug.Log("currentStartItem=" + currentStartItem.name);
        }

        itemsIndex = itemsIndex + (pageCount - 1);
        if (itemsIndex >= 0 && itemsIndex < items.Count)
        {
            currentEndItem = items[itemsIndex];
            //Debug.Log("currentEndItem=" + currentEndItem.name);
        }
    }
Example #39
0
	//type: 0 begin
	//		1 move
	//		2 end
	void OnSpringPanelHandle(SpringPanel spring,int type,Vector3 pos)
	{
		GameObject go = spring.gameObject;
		if (CallLuaBegin(go, "onSpringFinish") == true)
		{
			LuaStatic.addGameObject2Lua(wLua.L.L,go, "GameObject");
			LuaDLL.lua_pushnumber(wLua.L.L, type);
			LuaStatic.WriteVector3ToLua(wLua.L.L, pos);
			CallLuaEnd(3);
		}
	}
Example #40
0
    /// <summary>
    /// Restrict the panel's contents to be within the panel's bounds.
    /// </summary>
    public bool RestrictWithinBounds(bool instant)
    {
        Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

        if (constraint.magnitude > 0.001f)
        {
            if (!instant && dragEffect == DragEffect.MomentumAndSpring)
            {
                // Spring back into place
                sp = SpringPanel.Begin(mPanel.gameObject, mTrans.localPosition + constraint, 13f);
            }
            else
            {
                // Jump back into place
                MoveRelative(constraint);
                mMomentum = Vector3.zero;
                mScroll = 0f;
            }
            return true;
        }
        return false;
    }
Example #41
0
    public override void OnCreate()
    {
        base.OnCreate();

        m_newStageNumber = -1;

        m_heartUI = UIWindowManager.Singleton.CreateWindow<UIWindow>("UIMapHeart", UIWindowManager.Anchor.TopLeft);

        m_backGroundTrans = mUIObject.transform;
        
        m_stageBtns = new Transform[GlobalVars.TotalStageCount];
		m_stageNumbers = new Transform[GlobalVars.TotalStageCount];

        GlobalVars.AvailabeStageCount = PlayerPrefs.GetInt("StageAvailableCount");
        GlobalVars.HeadStagePos = PlayerPrefs.GetInt("HeadStagePos");

        if (GlobalVars.AvailabeStageCount == 0)
        {
            GlobalVars.AvailabeStageCount = 1;
        }
        if (GlobalVars.AvailabeStageCount > GlobalVars.TotalStageCount)
        {
            GlobalVars.AvailabeStageCount = GlobalVars.TotalStageCount;
        }
        if (GlobalVars.HeadStagePos > GlobalVars.TotalStageCount)
        {
            GlobalVars.HeadStagePos = GlobalVars.TotalStageCount;
        }
        if (GlobalVars.HeadStagePos == 0)
        {
            GlobalVars.HeadStagePos = 1;
        }
		GlobalVars.StageStarArray = PlayerPrefsExtend.GetIntArray("StageStars", 0, 100);
        GlobalVars.StageScoreArray = PlayerPrefsExtend.GetIntArray("StageScores", 0, 100);
		GlobalVars.StageFailedArray = PlayerPrefsExtend.GetIntArray("StageFailed", 0, 100);
        GlobalVars.LastStage = GlobalVars.AvailabeStageCount;
		
		if(!PlayerPrefs.HasKey("Coins"))
		{
			GlobalVars.Coins = 10;
			PlayerPrefs.SetInt("Coins", 0);
		}
		else
		{
			GlobalVars.Coins = PlayerPrefs.GetInt("Coins");
		}
		
		GlobalVars.PurchasedItemArray = PlayerPrefsExtend.GetIntArray("PurchasedItemArray", 0, 2);

        m_mapObj = mUIObject.transform.FindChild("MapObj").gameObject;
        springPanel = m_mapObj.AddComponent<SpringPanel>();
        springPanel.strength = 1000;
        UIPanel panel = m_mapObj.GetComponent<UIPanel>();
        //panel.baseClipRegion = new Vector4(0, 0, CapsApplication.Singleton.Width, CapsApplication.Singleton.Height);

        //心面板
        m_timeNumber = UIToolkits.FindChild(m_heartUI.mUIObject.transform, "TimeNumber").gameObject;
        m_minNumber = m_heartUI.GetChildComponent<NumberDrawer>("MinNumber");
        m_secNumber = m_heartUI.GetChildComponent<NumberDrawer>("SecNumber");
        UIButton heartBtn = m_heartUI.GetChildComponent<UIButton>("HeartBtn");
        EventDelegate.Set(heartBtn.onClick, delegate()
        {
            if (GlobalVars.HeartCount == 5)
            {
                return;
            }

            if (GlobalVars.UseSFX)
            {
                NGUITools.PlaySound(CapsConfig.CurAudioList.ButtonClip);
            }

            UINoMoreHearts noMoreHeartUI = UIWindowManager.Singleton.GetUIWindow<UINoMoreHearts>();
            UIStageInfo stageInfoUI = UIWindowManager.Singleton.GetUIWindow<UIStageInfo>();

            if (stageInfoUI.Visible)
            {
                stageInfoUI.HideWindow();
            }

            noMoreHeartUI.NeedOpenStageInfoAfterClose = false;
            noMoreHeartUI.ShowWindow();
        });

        //金币面板
        m_coinNumber = m_heartUI.GetChildComponent<NumberDrawer>("MoneyNumber");
        UIButton button = m_heartUI.GetChildComponent<UIButton>("StoreBtn");
        EventDelegate.Set(button.onClick, delegate()
        {
            if (GlobalVars.UseSFX)
            {
                NGUITools.PlaySound(CapsConfig.CurAudioList.ButtonClip);
            }

            UIStore storeUI = UIWindowManager.Singleton.GetUIWindow<UIStore>();
            UIStageInfo stageInfoUI = UIWindowManager.Singleton.GetUIWindow<UIStageInfo>();

            if (stageInfoUI.Visible)
            {
                stageInfoUI.HideWindow();
                GlobalVars.OnCancelFunc = delegate()
                {
                    stageInfoUI.ShowWindow();
                };
                GlobalVars.OnPurchaseFunc = delegate()
                {
                    stageInfoUI.ShowWindow();
                };
            }

            
            storeUI.ShowWindow();
        }
        );

        m_headSprite = GetChildComponent<UISprite>("Head");


        GameObject obj = GameObject.Find("Cloud");
        m_cloudSprite = obj.GetComponent<UISprite>();
        m_cloudSprite.gameObject.SetActive(false);

        obj = GameObject.Find("Cloud2");
        m_cloud2Sprite = obj.GetComponent<UISprite>();
        m_cloud2Sprite.gameObject.SetActive(false);

        m_inputBlocker = mUIObject.transform.Find("Blocker").gameObject;

        m_stageUI = UIWindowManager.Singleton.GetUIWindow<UIStageInfo>();

        for (int i=0; i<3; ++i)
        {
            m_blurSprites[i] = UIToolkits.FindChild( mUIObject.transform, "MapPicBlur" + i).gameObject;
            m_blurSprites[i].SetActive(false);
        }
		
		for (int i = 0; i < GlobalVars.TotalStageCount; ++i)
        {
			Transform transform = UIToolkits.FindChild(mUIObject.transform, "Stage" + (i + 1));      //找到对象

            if (transform == null)
            {
                Debug.LogError("There's no " + "Stage" + (i + 1).ToString() + " Button");
                continue;
            }
			
			m_stageBtns[i] = transform;
			m_stageNumbers[i] = transform.FindChild("StageNumber");
		}
    }
Example #42
0
	protected void MoveToPosition(Vector3 relative, bool useTween)
	{
		if (relative == Vector3.zero)
		{
			if (useTween)
			{
				if (MoveStartEvent != null)
					MoveStartEvent();

				if (MoveEndEvent != null)
					MoveEndEvent();
			}
			return;
		}

		//清除目前的移動量
		scrollView.currentMomentum = Vector3.zero;

		scrollView.DisableSpring();

		if (useTween)
		{
			if (MoveStartEvent != null)
				MoveStartEvent();

			Vector3 panelPos = scrollView.panel.cachedTransform.localPosition + relative; 
			
			tweenSpring = SpringPanel.Begin(scrollView.gameObject, panelPos, MOVE_SPRING_STRENGTH);

			tweenSpring.onFinished += FinishHandler;
		}
		else
		{
			scrollView.MoveRelative(relative);

			this.Update();
		}
	}
    void Start()
    {
        if (!isSetPageTotalCount)
        {
            Debug.LogError("未设置总页面数量!!!");
            return;
        }

        sp = gameObject.GetComponent<SpringPanel>();
        if (sp == null) sp = gameObject.AddComponent<SpringPanel>();
        sp.GenerateMomentumAmount = GenerateMomentumAmount;

        items = new List<GameObject>();

        pageStartCount = CellCount * RowCount * 3;

        pageStartCount = pageStartCount > itemTotalCount ? itemTotalCount : pageStartCount;

        Debug.Log("pageStartCount=" + pageStartCount + "----itemTotalCount=" + itemTotalCount);
        for (int i = 0; i < pageStartCount;)
        {
            GameObject g = Myutils.makeGameObject(ItemPrefab, ItemPos);
            g.name = i.ToString();
            items.Add(g);

            if (AssignEvent != null)
                AssignEvent(g, i++);
        }

        if (items != null && items.Count > 0)
        {
            currentStartItem = items[0];
            currentEndItem = items[items.Count - 1];

            ItemLayout(items);
        }

        #region 协程处理
        //startMakeID = 0;
        //StartCoroutine(TimeOutMakeItems());
        #endregion
    }