예제 #1
0
        public void Move(Vector2 toPos, float time, CTween.EaseType method, CTween.EndHandler endEvent, bool xEnable, bool yEnable)
        {
            if (!trans)
            {
                trans = GetComponent <RectTransform>();
            }
            if (time <= 0f)
            {
                if (!xEnable)
                {
                    toPos.x = trans.anchoredPosition.x;
                }
                if (!yEnable)
                {
                    toPos.y = trans.anchoredPosition.y;
                }
                trans.anchoredPosition = toPos;
                return;
            }
            t = 0f;
            d = time;
            Vector2 transPos = trans.anchoredPosition;

            xAxis.canGo = xEnable?(toPos.x != transPos.x):xEnable;
            yAxis.canGo = yEnable?(toPos.y != transPos.y):yEnable;
            if (xAxis.canGo)
            {
                xAxis.b = transPos.x;
                xAxis.c = toPos.x - transPos.x;
            }
            if (yAxis.canGo)
            {
                yAxis.b = transPos.y;
                yAxis.c = toPos.y - transPos.y;
            }
            this.toPos = toPos;
            switch (method)
            {
            case CTween.EaseType.Linear:
                cTween = new LinearEase();
                break;

            case CTween.EaseType.ExpoEaseIn:
                cTween = new ExpoEaseIn();
                break;

            case CTween.EaseType.ExpoEaseOut:
                cTween = new ExpoEaseOut();
                break;

            case CTween.EaseType.ExpoEaseInOut:
                cTween = new ExpoEaseInOut();
                break;

            case CTween.EaseType.SineEaseIn:
                cTween = new SineEaseIn();
                break;

            case CTween.EaseType.SineEaseOut:
                cTween = new SineEaseOut();
                break;

            case CTween.EaseType.SineEaseInOut:
                cTween = new SineEaseInOut();
                break;

            case CTween.EaseType.ElasticEaseIn:
                cTween = new ElasticEaseIn();
                break;

            case CTween.EaseType.ElasticEaseOut:
                cTween = new ElasticEaseOut();
                break;

            case CTween.EaseType.ElasticEaseInOut:
                cTween = new ElasticEaseInOut();
                break;

            case CTween.EaseType.BackEaseIn:
                cTween = new BackEaseIn();
                break;

            case CTween.EaseType.BackEaseOut:
                cTween = new BackEaseOut();
                break;

            case CTween.EaseType.BackEaseInOut:
                cTween = new BackEaseInOut();
                break;

            case CTween.EaseType.BounceEaseIn:
                cTween = new BounceEaseIn();
                break;

            case CTween.EaseType.BounceEaseOut:
                cTween = new BounceEaseOut();
                break;

            case CTween.EaseType.BounceEaseInOut:
                cTween = new BounceEaseInOut();
                break;

            default:
                cTween = new SineEaseOut();
                break;
            }
            this.enabled  = true;
            this.EndEvent = endEvent;
        }
예제 #2
0
        public void Rotate(Vector3 toAngle, float time, bool useWorldPos, CTween.EaseType method, CTween.EndHandler endEvent, bool xEnable, bool yEnable, bool zEnable)
        {
            this.useWorldPos = useWorldPos;
            if (time <= 0f)
            {
                if (useWorldPos)
                {
                    transform.eulerAngles = toAngle;
                }
                else
                {
                    if (!xEnable)
                    {
                        toAngle.x = transform.localEulerAngles.x;
                    }
                    if (!yEnable)
                    {
                        toAngle.y = transform.localEulerAngles.y;
                    }
                    if (!zEnable)
                    {
                        toAngle.z = transform.localEulerAngles.z;
                    }
                    transform.localEulerAngles = toAngle;
                }
                return;
            }
            t = 0f;
            d = time;
            Vector3 transPos = useWorldPos?transform.eulerAngles:transform.localEulerAngles;

            xAxis.canGo = xEnable?(toAngle.x != transPos.x):xEnable;
            yAxis.canGo = yEnable?(toAngle.y != transPos.y):yEnable;
            zAxis.canGo = zEnable?(toAngle.z != transPos.z):zEnable;
            if (xAxis.canGo)
            {
                xAxis.b = transPos.x;
                xAxis.c = toAngle.x - transPos.x;
            }
            if (yAxis.canGo)
            {
                yAxis.b = transPos.y;
                yAxis.c = toAngle.y - transPos.y;
            }
            if (zAxis.canGo)
            {
                zAxis.b = transPos.z;
                zAxis.c = toAngle.z - transPos.z;
            }
            this.toAngle = toAngle;
            switch (method)
            {
            case CTween.EaseType.Linear:
                cTween = new LinearEase();
                break;

            case CTween.EaseType.ExpoEaseIn:
                cTween = new ExpoEaseIn();
                break;

            case CTween.EaseType.ExpoEaseOut:
                cTween = new ExpoEaseOut();
                break;

            case CTween.EaseType.ExpoEaseInOut:
                cTween = new ExpoEaseInOut();
                break;

            case CTween.EaseType.SineEaseIn:
                cTween = new SineEaseIn();
                break;

            case CTween.EaseType.SineEaseOut:
                cTween = new SineEaseOut();
                break;

            case CTween.EaseType.SineEaseInOut:
                cTween = new SineEaseInOut();
                break;

            case CTween.EaseType.ElasticEaseIn:
                cTween = new ElasticEaseIn();
                break;

            case CTween.EaseType.ElasticEaseOut:
                cTween = new ElasticEaseOut();
                break;

            case CTween.EaseType.ElasticEaseInOut:
                cTween = new ElasticEaseInOut();
                break;

            case CTween.EaseType.BackEaseIn:
                cTween = new BackEaseIn();
                break;

            case CTween.EaseType.BackEaseOut:
                cTween = new BackEaseOut();
                break;

            case CTween.EaseType.BackEaseInOut:
                cTween = new BackEaseInOut();
                break;

            case CTween.EaseType.BounceEaseIn:
                cTween = new BounceEaseIn();
                break;

            case CTween.EaseType.BounceEaseOut:
                cTween = new BounceEaseOut();
                break;

            case CTween.EaseType.BounceEaseInOut:
                cTween = new BounceEaseInOut();
                break;

            default:
                cTween = new SineEaseOut();
                break;
            }
            this.enabled  = true;
            this.EndEvent = endEvent;
        }
예제 #3
0
 public void StopMove()
 {
     cTween       = null;
     this.enabled = false;
 }