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<Vector3, Path, PathOptions> 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<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.delay).SetLoops<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.loops, sourcePath.loopType).SetAutoKill<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.autoKill).SetUpdate<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.updateType).OnKill<TweenerCore<Vector3, Path, PathOptions>>((TweenCallback)(() => sourcePath.tween = (Tween)null)); if (sourcePath.isSpeedBased) t.SetSpeedBased<TweenerCore<Vector3, Path, PathOptions>>(); if (sourcePath.easeType == Ease.INTERNAL_Custom) t.SetEase<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.easeCurve); else t.SetEase<TweenerCore<Vector3, Path, PathOptions>>(sourcePath.easeType); if (!string.IsNullOrEmpty(sourcePath.id)) t.SetId<TweenerCore<Vector3, Path, PathOptions>>((object)sourcePath.id); if (sourcePath.hasOnStart) { if (sourcePath.onStart != null) t.OnStart<TweenerCore<Vector3, Path, PathOptions>>(new TweenCallback(sourcePath.onStart.Invoke)); } else sourcePath.onStart = (UnityEvent)null; if (sourcePath.hasOnPlay) { if (sourcePath.onPlay != null) t.OnPlay<TweenerCore<Vector3, Path, PathOptions>>(new TweenCallback(sourcePath.onPlay.Invoke)); } else sourcePath.onPlay = (UnityEvent)null; if (sourcePath.hasOnUpdate) { if (sourcePath.onUpdate != null) t.OnUpdate<TweenerCore<Vector3, Path, PathOptions>>(new TweenCallback(sourcePath.onUpdate.Invoke)); } else sourcePath.onUpdate = (UnityEvent)null; if (sourcePath.hasOnStepComplete) { if (sourcePath.onStepComplete != null) t.OnStepComplete<TweenerCore<Vector3, Path, PathOptions>>(new TweenCallback(sourcePath.onStepComplete.Invoke)); } else sourcePath.onStepComplete = (UnityEvent)null; if (sourcePath.hasOnComplete) { if (sourcePath.onComplete != null) t.OnComplete<TweenerCore<Vector3, Path, PathOptions>>(new TweenCallback(sourcePath.onComplete.Invoke)); } else sourcePath.onComplete = (UnityEvent)null; t.Play<TweenerCore<Vector3, Path, PathOptions>>(); sourcePath.tween = (Tween)t; if (!sourcePath.hasOnTweenCreated || sourcePath.onTweenCreated == null) return; sourcePath.onTweenCreated.Invoke(); } }