Beispiel #1
0
    void CallFuncTest()
    {
        btn_text.text = "点击停止";
        var action = Sequence.Create(
            CallFunc.Create(CallBackO, "延时0.5秒"),
            DelayTime.Create(0.5f),
            CallFunc.Create(CallBackO, "图片移动"),
            MoveTo.Create(1f, 200, 100).InitSubjectTransform(image.transform),
            MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "颜色渐变"),
            ColorTo.Create(0.5f, 1, 0, 0, 1f).InitSubjectComponent(image),
            ColorTo.Create(0.5f, 0, 1, 0, 1f).InitSubjectComponent(image),
            ColorTo.Create(0.5f, 0, 0, 1, 1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "颜色reset"),
            ColorTo.Create(0.5f, 1, 1, 1, 1).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "渐隐"),
            FadeOut.Create(1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "渐出"),
            FadeIn.Create(1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "1秒闪烁5次"),
            Blink.Create(1f, 5),
            CallFunc.Create(CallBackO, "二阶贝塞尔曲线"),
            BezierTo.Create(2.0f, new Vector3(200, 100, 0), new Vector3(-100, 50, 0), new Vector3(100, 80, 0)).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "移动回原点"),
            MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "边移动边放大"),
            Spawn.Create(MoveTo.Create(1.0f, 200, 100f), ScaleTo.Create(1.0f, 3.0f, 3.0f, 3.0f)),
            CallFunc.Create(CallBackO, "缩放位置回原位"),
            Spawn.Create(MoveTo.Create(1.0f, 0, 0), ScaleTo.Create(1.0f, 1f, 1f, 1f)),
            NumberBy.Create(2.0f, "数字跳跃,从100到200:{0:f2}", 100, 100).InitSubjectComponent(text),
            DelayTime.Create(0.5f),
            NumberTo.Create(2.0f, "数字跳跃,从200到0:{0:f2}", 200, 0).InitSubjectComponent(text),
            DelayTime.Create(0.5f),
            CallFunc.Create(CallBackO, "Image Filled"),
            FillAmountTo.Create(1.5f, 0f).InitSubjectComponent(image),
            FillAmountTo.Create(1.5f, 1.0f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "reset"),
            CallFunc.Create(CallBackO, "旋转 放大2倍,复原。重复3次"),
            Repeat.Create(Spawn.Create(
                              RotationBy.Create(1.0f, 0, 0, 360f),
                              Sequence.Create(
                                  ScaleTo.Create(0.5f, 2.0f, 2.0f, 2.0f),
                                  ScaleTo.Create(0.5f, 1.0f, 1.0f, 1.0f))).InitSubjectTransform(image.transform), 3),
            ExtraAction.Create()
            );

        float toX        = 300f;
        var   easeAction = Sequence.Create(
            CallFunc.Create(CallBackO, "变速运动演示,图一正常,图二是变速运动"),
            DelayTime.Create(1f),
            CallFunc.Create(CallBackO, "当前变速是EaseIn"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseIn.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseIn.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),

            CallFunc.Create(CallBackO, "当前变速是EaseOut"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),

            CallFunc.Create(CallBackO, "当前变速是EaseInOut"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseInOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseInOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "变速运动未完待续"),
            DelayTime.Create(1f),
            ExtraAction.Create()
            );

        CCActionManager.Instance.AddAction(Sequence.Create(action, easeAction, CallFunc.Create(CallBackEnd)), transform);
    }
    public override void Execute()
    {
        if (m_DOTweenAction == null)
        {
            Debug.LogError("무브 액션이 설정안된 객체입니다. 설정해주시기 바랍니다. 에러객체 이름 및 좌표 : " + m_MonoBehaviour.gameObject.name + " / " + m_MonoBehaviour.gameObject.transform.position);
            return;
        }

        switch (m_DOTweenActionType)
        {
        case DOTweenActionType.MoveTo:
        {
            MoveTo to = m_DOTweenAction as MoveTo;



            m_MonoBehaviour.gameObject.transform
            .DOMove(to.GetEndPoint(), to.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.MoveBy:
        {
            MoveBy by = m_DOTweenAction as MoveBy;
            m_MonoBehaviour.gameObject.transform
            .DOBlendableMoveBy(by.GetEndPoint(), by.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.MovePaths:
        {
            MovePaths paths = m_DOTweenAction as MovePaths;
            m_MonoBehaviour.gameObject.transform
            .DOPath(paths.GetPaths(), paths.GetDuration(), paths.GetPathType())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.RotateTo:
        {
            RotateTo roateto = m_DOTweenAction as RotateTo;
            m_MonoBehaviour.gameObject.transform
            .DORotate(roateto.GetEndPoint(), roateto.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.RotateBy:
        {
            RotateBy roateby = m_DOTweenAction as RotateBy;
            m_MonoBehaviour.gameObject.transform
            .DOBlendableLocalRotateBy(roateby.GetEndPoint(), roateby.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.ColorTo:
        {
            ColorTo colorto = m_DOTweenAction as ColorTo;
            m_MonoBehaviour.gameObject.GetComponentInChildren <MeshRenderer>().material
            .DOColor(colorto.GetEndPoint(), colorto.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.ColorRewind:
        {
            ColorTo  colorto  = m_DOTweenAction as ColorTo;
            Material material = m_MonoBehaviour.gameObject.GetComponentInChildren <MeshRenderer>().material;
            Color    oriColor = material.color;
            float    duration = colorto.GetDuration() / 2;
            DOTween.Sequence()
            .Append(material.DOColor(oriColor, duration))
            .Append(material.DOColor(colorto.GetEndPoint(), duration))
            .OnComplete(() => m_IsCompleted = true);
        }
        break;

        case DOTweenActionType.ScaleTo:
        {
            ScaleTo scaleTo = m_DOTweenAction as ScaleTo;
            m_MonoBehaviour.gameObject.transform
            .DOScale(scaleTo.GetEndPoint(), scaleTo.GetDuration())
            .OnComplete(() => m_IsCompleted = true);
        }
        break;
        }
    }