public Mover(string source, string destination, MoverCallback mcbk) { this.source = source; this.destination = destination; this.cbk = mcbk; Logger.Log(Logger.LogLevel.DEBUG, String.Format("Mover created {0}", source)); }
//-------------------------------------------------------- public virtual void CreateAnimation(MoverCallback callback = null) { if (spline.advance) { _ComputePath(); _transform.DOLocalPath( spline.OnAdjust(_adjustx, _adjusty), _totalDuration, PathType.CatmullRom, PathMode.Ignore, 5 ).SetEase(CustomEasing).SetAutoKill(false).Pause().OnComplete(() => OnCompleteMover(callback)); } else { _transform.DOLocalPath( spline.OnAdjust(_adjustx, _adjusty), spline.overallDuration, PathType.CatmullRom, PathMode.Ignore, 5 ).SetEase(spline.overallEasing).SetAutoKill(false).Pause().OnComplete(() => OnCompleteMover(callback)); } _animCreated = true; }
//-------------------------------------------------------- public void OnCompleteMover(MoverCallback callback = null) { if (callback != null) { callback(); } }
//-------------------------------------------------------- public void Exec(MoverCallback callback = null) { Assert.IsNotNull(spline, "Waypoints not found"); Assert.IsNotNull(spline.scaledWaypoints, "Waypoints list are empty"); Assert.IsTrue(spline.scaledWaypoints.Length >= 2, "There must be at least 2 waypoints to form a path"); if (!isStatic || !_animCreated) { CreateAnimation(callback); } _PreExec(); _transform.DORestart(); }