Beispiel #1
0
 public void OnClickRight(TurnCallBack action)
 {
     if (!bIsRolling)
     {
         OnClickRight();
         onClick = action;
     }
 }
Beispiel #2
0
    //自动翻动指定的矢量值的页数
    //在自动翻到指定的页数后,调用该Item按钮的时间
    public void AutoToPageTurn(int _turnDirection, TurnCallBack action = null)
    {
        if (!b_Active)
        {
            return;
        }

        iOffDir = _turnDirection;
        onClick = action;
    }
Beispiel #3
0
    void UpdatePosition()
    {
        if (!bIsRolling && iOffDir != 0)
        {
            if (iOffDir > 0)
            {
                for (int i = 0; i < Mathf.Abs(iOffDir); i++)
                {
                    NextRightItem();
                }
            }
            else
            {
                for (int i = 0; i < Mathf.Abs(iOffDir); i++)
                {
                    NextLeftItem();
                }
            }
            iOffDir = 0;
            //if (iOffDir > 0)
            //{
            //	--iOffDir;
            //	NextRightItem();
            //}
            //else
            //{
            //	++iOffDir;
            //	NextLeftItem();
            //}
        }

        if (f_process != f_targetProcess)
        {
            float speedT = Time.deltaTime * f_Rollspeed;

            if (f_process > f_targetProcess)
            {
                if ((f_process - speedT) > f_targetProcess)
                {
                    f_process -= speedT;
                }
                else
                {
                    f_process = f_targetProcess;
                }
            }
            else
            {
                if ((f_process + speedT) < f_targetProcess)
                {
                    f_process += speedT;
                }
                else
                {
                    f_process = f_targetProcess;
                }
            }

            if (f_process > f_proMax)
            {
                f_process       = f_proMin;
                f_targetProcess = f_targetProcess - f_proMax + f_proMin;
            }
            if (f_process < f_proMin)
            {
                f_process       = f_proMax - (f_proMin - f_process);
                f_targetProcess = f_proMax - (f_proMin - f_targetProcess);
            }
        }
        else
        {
            bIsRolling = false;
            if (iOffDir == 0)
            {
                if (onClick != null)
                {
                    TurnCallBack t = onClick;
                    onClick = null;
                    t();
                }
            }
        }

        if (f_process != lastProcess)
        {
            bIsRolling = true;

            //_value = Mathf.RoundToInt((1 - (f_process - f_proMin) / 2f) * i_ItemCount) % i_ItemCount;
            _value = Mathf.RoundToInt((f_process - f_proMin) / 2f / f_proMin);
            SetPositions(a_itemDrag);

            if (change != null)
            {
                change.Invoke();
            }
        }

        lastProcess = f_process;
    }