using System.Collections; using System.Collections.Generic; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Core.PathCore; using DG.Tweening.Plugins.Options; using UnityEngine; using UnityEngine.Events; public class DoTweenPathHelper : MonoBehaviour { public void DoPath(DOTweenPath sourcePath) { if (sourcePath == null) { return; } TweenerCore t = sourcePath.isLocal ? sourcePath.transform.DOLocalPath(sourcePath.wps.ToArray(), sourcePath.duration, sourcePath.pathType,sourcePath.pathMode).SetOptions(sourcePath.isClosedPath, AxisConstraint.None, sourcePath.lockRotation) : sourcePath.transform.DOPath(sourcePath.wps.ToArray(), sourcePath.duration, sourcePath.pathType, sourcePath.pathMode).SetOptions(sourcePath.isClosedPath, AxisConstraint.None, sourcePath.lockRotation); switch (sourcePath.orientType) { case OrientType.ToPath: if (sourcePath.assignForwardAndUp) { t.SetLookAt(sourcePath.lookAhead, new Vector3?(sourcePath.forwardDirection), new Vector3?(sourcePath.upDirection)); break; } t.SetLookAt(sourcePath.lookAhead, new Vector3?(), new Vector3?()); break; case OrientType.LookAtTransform: if ((Object)sourcePath.lookAtTransform != (Object)null) { if (sourcePath.assignForwardAndUp) { t.SetLookAt(sourcePath.lookAtTransform, new Vector3?(sourcePath.forwardDirection), new Vector3?(sourcePath.upDirection)); break; } t.SetLookAt(sourcePath.lookAtTransform, new Vector3?(), new Vector3?()); break; } break; case OrientType.LookAtPosition: if (sourcePath.assignForwardAndUp) { t.SetLookAt(sourcePath.lookAtPosition, new Vector3?(sourcePath.forwardDirection), new Vector3?(sourcePath.upDirection)); break; } t.SetLookAt(sourcePath.lookAtPosition, new Vector3?(), new Vector3?()); break; } t.SetDelay>(sourcePath.delay).SetLoops>(sourcePath.loops, sourcePath.loopType).SetAutoKill>(sourcePath.autoKill).SetUpdate>(sourcePath.updateType).OnKill>((TweenCallback)(() => sourcePath.tween = (Tween)null)); if (sourcePath.isSpeedBased) t.SetSpeedBased>(); if (sourcePath.easeType == Ease.INTERNAL_Custom) t.SetEase>(sourcePath.easeCurve); else t.SetEase>(sourcePath.easeType); if (!string.IsNullOrEmpty(sourcePath.id)) t.SetId>((object)sourcePath.id); if (sourcePath.hasOnStart) { if (sourcePath.onStart != null) t.OnStart>(new TweenCallback(sourcePath.onStart.Invoke)); } else sourcePath.onStart = (UnityEvent)null; if (sourcePath.hasOnPlay) { if (sourcePath.onPlay != null) t.OnPlay>(new TweenCallback(sourcePath.onPlay.Invoke)); } else sourcePath.onPlay = (UnityEvent)null; if (sourcePath.hasOnUpdate) { if (sourcePath.onUpdate != null) t.OnUpdate>(new TweenCallback(sourcePath.onUpdate.Invoke)); } else sourcePath.onUpdate = (UnityEvent)null; if (sourcePath.hasOnStepComplete) { if (sourcePath.onStepComplete != null) t.OnStepComplete>(new TweenCallback(sourcePath.onStepComplete.Invoke)); } else sourcePath.onStepComplete = (UnityEvent)null; if (sourcePath.hasOnComplete) { if (sourcePath.onComplete != null) t.OnComplete>(new TweenCallback(sourcePath.onComplete.Invoke)); } else sourcePath.onComplete = (UnityEvent)null; t.Play>(); sourcePath.tween = (Tween)t; if (!sourcePath.hasOnTweenCreated || sourcePath.onTweenCreated == null) return; sourcePath.onTweenCreated.Invoke(); } }