public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            animElement = canvasElement.GetComponent <RectTransform>();


            var pos = (VariablesManager.GetLocal(canvasElement, "originalPosition", true));

            OriginalStartPosition = (Vector3)pos;


            AnimInPosition             = new Vector3(OriginalStartPosition.x, OriginalStartPosition.y, OriginalStartPosition.z);
            AnimOutPositionTop         = new Vector3(animElement.localPosition.x, Screen.height, animElement.localPosition.z);
            AnimOutPositionBottom      = new Vector3(animElement.localPosition.x, -Screen.height, animElement.localPosition.z);
            AnimOutPositionLeft        = new Vector3(-Screen.width, animElement.localPosition.y, animElement.localPosition.z);
            AnimOutPositionRight       = new Vector3(Screen.width, animElement.localPosition.y, animElement.localPosition.z);
            AnimOutPositionTopLeft     = new Vector3(Screen.width, Screen.height, animElement.localPosition.z);
            AnimOutPositionTopRight    = new Vector3(-Screen.width, Screen.height, animElement.localPosition.z);
            AnimOutPositionBottomRight = new Vector3(Screen.width, -Screen.height, animElement.localPosition.z);
            AnimOutPositionBottomLeft  = new Vector3(-Screen.width, -Screen.height, animElement.localPosition.z);

            float vMoveSpeed = AnimateDuration.GetValue(target);

            if (vMoveSpeed < 0.2f)
            {
                vMoveSpeed = 0.2f;
            }

            float initTime = Time.time;


            switch (this.alignment)
            {
            case ALIGN.Top:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);



                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionTop,
                        AnimInPosition,
                        easeValue
                        );

                    yield return(null);
                }

                break;

            case ALIGN.Bottom:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionBottom,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }
                break;

            case ALIGN.Left:

                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionLeft,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }

                break;

            case ALIGN.Right:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionRight,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }


                break;

            case ALIGN.TopLeftCorner:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);



                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionTopLeft,
                        AnimInPosition,
                        easeValue
                        );

                    yield return(null);
                }

                break;

            case ALIGN.TopRightCorner:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionTopRight,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }
                break;

            case ALIGN.BottomLeftCorner:

                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionBottomLeft,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }

                break;

            case ALIGN.BottomRightCorner:
                while (Time.time - initTime < vMoveSpeed)
                {
                    if (animElement == null)
                    {
                        break;
                    }
                    float t         = (Time.time - initTime) / vMoveSpeed;
                    float easeValue = Easing.GetEase(easing, 0.0f, 1.0f, t);

                    animElement.localPosition = Vector3.Lerp(
                        AnimOutPositionBottomRight,
                        AnimInPosition,
                        easeValue
                        );
                    yield return(null);
                }


                break;
            }


            yield return(new WaitForSeconds(0.2f));
        }
Exemplo n.º 2
0
        private static string OnMatch_LocalOtherName(FormulaData data, string clause)
        {
            string name = ClauseParseName(clause, data);

            return(Convert.ToSingle(VariablesManager.GetLocal(data.target.gameObject, name, true)).ToString(CULTURE));
        }