Пример #1
0
        public void Abort(AbortMethod abortMethod)
        {
            if (Tween == null || !Tween.IsPlaying())
            {
                return;
            }

            if (abortMethod == AbortMethod.JustKill)
            {
                Tween.Kill();
            }
            else if (abortMethod == AbortMethod.ForceCompleteWithKillCallback)
            {
                Tween.OnComplete(null);
                Tween.Complete();
            }
            else if (abortMethod == AbortMethod.ForceCompleteWithOnCompleteCallback)
            {
                Tween.OnKill(null);
                Tween.Complete();
            }
            else if (abortMethod == AbortMethod.ForceCompleteWithOnCompleteAndOnKill)
            {
                Tween.Kill(true);
            }

            Tween = null;
        }
Пример #2
0
        public void Play()
        {
            if (IsPlaying())
            {
                return;
            }

            if (_tween == null)
            {
                _tween = Prepare();
            }

            _tween.OnComplete(() => _tween = null).Play();
        }
Пример #3
0
 public void Shoot(Vector2 dir)
 {
     this.transform.parent = null;
     this.dir = dir.normalized;
     shooting = true;
     Invoke("Kill", 0.3f);
     trailSystem.Play();
     if (fader != null)
     {
         fader.Kill();
         fader.OnComplete(() => sprite.color = Color.white);
     }
     sprite.sprite = shootingSprite;
     chargingSystem.Stop();
 }
 static int OnComplete(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DG.Tweening.Tween         obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
         DG.Tweening.TweenCallback arg0 = (DG.Tweening.TweenCallback)ToLua.CheckDelegate <DG.Tweening.TweenCallback>(L, 2);
         DG.Tweening.Tween         o    = obj.OnComplete(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #5
0
    static int OnComplete(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        DG.Tweening.Tween         obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
        DG.Tweening.TweenCallback arg0 = null;
        LuaTypes funcType2             = LuaDLL.lua_type(L, 2);

        if (funcType2 != LuaTypes.LUA_TFUNCTION)
        {
            arg0 = (DG.Tweening.TweenCallback)LuaScriptMgr.GetNetObject(L, 2, typeof(DG.Tweening.TweenCallback));
        }
        else
        {
            LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 2);
            arg0 = () =>
            {
                func.Call();
            };
        }

        DG.Tweening.Tween o = obj.OnComplete(arg0);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Пример #6
0
    protected override void OnInit()
    {
        target = host.fireBoll.ro;
        //Debug.Log(target.transform.position);
        limit = host.fireBoll.limit;
        if (!target)
        {
            return;
        }

        Vector3 pos = parent.position;

        pos.y += parent.BoxCollider.y / 2;
        if (host.config.IsActOnTarget)
        {
            pos = target.transform.position;
        }
        if (host.config.IsRatioOffset)
        {
            Offset = new Vector3(parent.BoxCollider.x * Offset.x, parent.BoxCollider.y * Offset.y, parent.BoxCollider.z * Offset.z);
        }
        this.gameObject.transform.position = pos + this.Offset + this.gameObject.transform.forward * host.config.Distance;
        MaxDistance = Vector3.Distance(target.position, this.gameObject.transform.position) - target.BoxCollider.z / 2;
        //Vector3 forward = (target.position - this.gameObject.transform.position).normalized;
        //forward.y = 0;

        //this.targetPos = this.gameObject.transform.position + (Quaternion.Euler(this.Angle) * forward) * MaxDistance;
        //this.targetPos.y = target.position.y + target.BoxCollider.y / 2;
        this.targetPos = target.transform.position;
        this.gameObject.transform.LookAt(this.targetPos);//向目标飞行

        float speed = host.config.Speed;

        if (speed <= 0)
        {
            speed = 1;
        }

        //路径点
        Vector3[]            paths    = new Vector3[] { this.targetPos / 2, this.targetPos };
        DG.Tweening.PathType pathtype = DG.Tweening.PathType.Linear;
        if (host.PathType != Model.PathType.Linear)
        {
            pathtype = DG.Tweening.PathType.CatmullRom;
            switch (host.PathType)
            {
            case Model.PathType.CatmullRom:
                paths[0].y = this.gameObject.transform.position.y + host.OffsetMaxY;
                break;

            case Model.PathType.LeftCatmullRom:
                paths[0].x -= host.OffsetMaxY;
                break;

            case Model.PathType.RightCatmullRom:
                paths[0].x += host.OffsetMaxY;
                break;
            }
        }
        Debug.Log(paths);
        Debug.Log(MaxDistance + "/" + host.config.Speed + "=" + MaxDistance / host.config.Speed);
        DG.Tweening.Tween tween = null;
        if (pathtype == DG.Tweening.PathType.Linear)
        {
            tween = this.gameObject.transform.DOPath(new Vector3[] { targetPos }, MaxDistance / host.config.Speed, pathtype).SetLookAt(0.001f);
        }
        else
        {
            tween = this.gameObject.transform.DOPath(paths, MaxDistance / host.config.Speed, pathtype).SetLookAt(0.001f);
        }
        tween.OnComplete(() => target.mActionPerformer.StartAction(host.farther.config, EventPart.FIREBALLHIT, host.farther.High));

        ColliderEventComponent colliderEvent = this.gameObject.AddComponent <ColliderEventComponent>();

        colliderEvent.isTrigger       = true;
        colliderEvent.onTriggerEnter += OnTriggerEnter;
    }
Пример #7
0
        int _playCount = -1; // Used when calling DOPlayNext

        #region Unity Methods

        void Awake()
        {
            if (!isValid)
            {
                return;
            }

            Component c;

            switch (animationType)
            {
            case DOTweenAnimationType.None:
                break;

            case DOTweenAnimationType.Move:
                c = this.GetComponent <Rigidbody2D>();
                if (c != null)
                {
                    _tween = ((Rigidbody2D)c).DOMove(endValueV3, duration, optionalBool0);
                    goto SetupTween;
                }
                c = this.GetComponent <Rigidbody>();
                if (c != null)
                {
                    _tween = ((Rigidbody)c).DOMove(endValueV3, duration, optionalBool0);
                    goto SetupTween;
                }
                _tween = transform.DOMove(endValueV3, duration, optionalBool0);
                break;

            case DOTweenAnimationType.LocalMove:
                _tween = transform.DOLocalMove(endValueV3, duration, optionalBool0);
                break;

            case DOTweenAnimationType.Rotate:
                c = this.GetComponent <Rigidbody2D>();
                if (c != null)
                {
                    _tween = ((Rigidbody2D)c).DORotate(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Rigidbody>();
                if (c != null)
                {
                    _tween = ((Rigidbody)c).DORotate(endValueV3, duration, optionalRotationMode);
                    goto SetupTween;
                }
                _tween = transform.DORotate(endValueV3, duration, optionalRotationMode);
                break;

            case DOTweenAnimationType.LocalRotate:
                _tween = transform.DOLocalRotate(endValueV3, duration, optionalRotationMode);
                break;

            case DOTweenAnimationType.Scale:
                _tween = transform.DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration);
                break;

            case DOTweenAnimationType.Color:
                isRelative = false;
#if TK2D
                c = this.GetComponent <tk2dBaseSprite>();
                if (c != null)
                {
                    _tween = ((tk2dBaseSprite)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
#endif
                c = this.GetComponent <SpriteRenderer>();
                if (c != null)
                {
                    _tween = ((SpriteRenderer)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Renderer>();
                if (c != null)
                {
                    _tween = ((Renderer)c).material.DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Image>();
                if (c != null)
                {
                    _tween = ((Image)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                break;

            case DOTweenAnimationType.Fade:
                isRelative = false;
#if TK2D
                c = this.GetComponent <tk2dBaseSprite>();
                if (c != null)
                {
                    _tween = ((tk2dBaseSprite)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
#endif
                c = this.GetComponent <SpriteRenderer>();
                if (c != null)
                {
                    _tween = ((SpriteRenderer)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Renderer>();
                if (c != null)
                {
                    _tween = ((Renderer)c).material.DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Image>();
                if (c != null)
                {
                    _tween = ((Image)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                break;

            case DOTweenAnimationType.Text:
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#if TK2D
                c = this.GetComponent <tk2dTextMesh>();
                if (c != null)
                {
                    _tween = ((tk2dTextMesh)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#endif
                break;

            case DOTweenAnimationType.PunchPosition:
                _tween = transform.DOPunchPosition(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0);
                break;

            case DOTweenAnimationType.PunchScale:
                _tween = transform.DOPunchScale(endValueV3, duration, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.PunchRotation:
                _tween = transform.DOPunchRotation(endValueV3, duration, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.ShakePosition:
                _tween = transform.DOShakePosition(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0);
                break;

            case DOTweenAnimationType.ShakeScale:
                _tween = transform.DOShakeScale(duration, endValueV3, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.ShakeRotation:
                _tween = transform.DOShakeRotation(duration, endValueV3, optionalInt0, optionalFloat0);
                break;
            }

SetupTween:
            if (_tween == null)
            {
                return;
            }

            if (isFrom)
            {
                ((Tweener)_tween).From(isRelative);
            }
            else
            {
                _tween.SetRelative(isRelative);
            }
            _tween.SetTarget(this.gameObject).SetDelay(delay).SetLoops(loops, loopType).SetAutoKill(autoKill)
            .OnKill(() => _tween = null);
            if (easeType == Ease.INTERNAL_Custom)
            {
                _tween.SetEase(easeCurve);
            }
            else
            {
                _tween.SetEase(easeType);
            }
            if (!string.IsNullOrEmpty(id))
            {
                _tween.SetId(id);
            }

            if (hasOnStart)
            {
                if (onStart != null)
                {
                    _tween.OnStart(onStart.Invoke);
                }
            }
            else
            {
                onStart = null;
            }
            if (hasOnStepComplete)
            {
                if (onStepComplete != null)
                {
                    _tween.OnStepComplete(onStepComplete.Invoke);
                }
            }
            else
            {
                onStepComplete = null;
            }
            if (hasOnComplete)
            {
                if (onComplete != null)
                {
                    _tween.OnComplete(onComplete.Invoke);
                }
            }
            else
            {
                onComplete = null;
            }

            if (autoPlay)
            {
                _tween.Play();
            }
            else
            {
                _tween.Pause();
            }
        }