Exemple #1
0
    private static int SetDelay(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            float       delay       = (float)LuaDLL.luaL_checknumber(L, 2);
            TweenParams o           = tweenParams.SetDelay(delay);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    void PlayAnimation(bool isEnter = true, Action callback = null)
    {
        if (m_CurrentTweener != null && m_CurrentTweener.IsPlaying())
        {
            m_CurrentTweener.Kill();
        }

        float overDisRatio = 1.2f;

        float   aniTime = isEnter ? 1f : 0.5f;
        Vector2 endPos  = m_StartAnchorePos;

        TweenParams aniParams = new TweenParams();

        aniParams.SetEase(isEnter ? Ease.OutBack : Ease.OutCubic);
        aniParams.SetDelay(isEnter ? 0.1f * m_Priority : 0);
        aniParams.OnComplete(() =>
        {
            if (null != callback)
            {
                callback();
            }
        });
        if (!isEnter)
        {
            m_MainObjRectTrans.anchoredPosition = m_StartAnchorePos;
        }

        switch (m_DirType)
        {
        case SideButtonDirType.Left_Top:
        case SideButtonDirType.Left_Bottom:
            Vector2 tempLeftPos = new Vector2(-m_ContentRect.anchoredPosition.x - m_MainObjRectTrans.rect.width, m_StartAnchorePos.y);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempLeftPos;
            }
            else
            {
                endPos = tempLeftPos;
            }
            break;

        case SideButtonDirType.Right:
            Vector2 tempRightPos = new Vector2(m_StartAnchorePos.x + m_ContentRect.rect.width * overDisRatio, m_StartAnchorePos.y);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempRightPos;
            }
            else
            {
                endPos = tempRightPos;
            }
            break;

        case SideButtonDirType.Bottom:

            Vector2 tempBottomPos = new Vector2(m_StartAnchorePos.x, m_StartAnchorePos.y - m_ContentRect.rect.width * overDisRatio);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempBottomPos;
            }
            else
            {
                endPos = tempBottomPos;
            }

            break;
        }

        m_CurrentTweener = m_MainObjRectTrans.DOAnchorPos(endPos, aniTime).SetAs(aniParams);
    }