static TweenParms SetAttributes(NTweenAttributes attributes) { var tweenParms = new TweenParms (); if (attributes != null) { tweenParms.AutoKill (attributes.GetAutoKill ()); if (attributes.GetDelay () > 0) { tweenParms.Delay (attributes.GetDelay ()); } if (attributes.GetLoops () != 0) { tweenParms.Loops (attributes.GetLoops (), GetLoopType (attributes.GetLoopType ())); } if (attributes.GetEaseType () != NTweenEaseType.Linear) { tweenParms.Ease (GetEaseType (attributes.GetEaseType ())); } if (attributes.GetOnComplete () != null) { tweenParms.OnComplete (attributes.GetOnComplete ().Invoke); } if (attributes.GetOnPlay () != null) { tweenParms.OnStart (attributes.GetOnPlay ().Invoke); } if (attributes.GetOnUpdate () != null) { tweenParms.OnUpdate (attributes.GetOnUpdate ().Invoke); } } return tweenParms; }
//creates a new HOTween tween which moves us to the next waypoint //(defined by passed arguments) internal void CreateTween() { //play walk animation if set PlayWalk(); //prepare HOTween's parameters, you can look them up here //http://www.holoville.com/hotween/documentation.html //////////////////////////////////////////////////////////// //create new HOTween plugin for curved paths //pass in array of Vector3 waypoint positions, relative = true plugPath = new PlugVector3Path(wpPos, true, PathType.Curved); //orients the tween target along the path //constrains this game object on one axis if (orientToPath || lockAxis != Axis.None) plugPath.OrientToPath(lookAhead, lockAxis); //lock position axis if (lockPosition != Axis.None) plugPath.LockPosition(lockPosition); //create a smooth path if closePath was true /* if (closePath && looptype == LoopType.loop && !moveToPath) plugPath.ClosePath(true); */ //create TweenParms for storing HOTween's parameters tParms = new TweenParms(); //sets the path plugin as tween position property tParms.Prop("position", plugPath); //additional tween parameters for partial tweens tParms.AutoKill(false); tParms.Loops(1); //differ between TimeValue like mentioned above at enum TimeValue //use speed with linear easing if (timeValue == TimeValue.speed) { tParms.SpeedBased(); tParms.Ease(EaseType.Linear); } else { //use time in seconds and the chosen easetype if (easetype == Holoville.HOTween.EaseType.AnimationCurve) tParms.Ease(AnimEaseType); else tParms.Ease(easetype); } //if we're on the original tween, //attach methods to the tween if (!moveToPath) { tParms.OnUpdate(CheckPoint); tParms.OnComplete(OnPathComplete); } //create a new tween, move this gameobject with given arguments tween = HOTween.To(transform, originSpeed, tParms); //continue new tween with adjusted speed if it was changed before if (originSpeed != speed) ChangeSpeed(speed); }