示例#1
0
        /// <summary>
        /// Completely resets this Tweener, except its target
        /// </summary>
        override protected void Reset()
        {
            base.Reset();

            if (HOTween.overwriteManager != null) HOTween.overwriteManager.RemoveTween(this);
            isFrom = false;
            plugins = null;
            isPartialled = false;
            pv3Path = null;
            _delay = _elapsedDelay = delayCount = 0;
            _pixelPerfect = false;
            _speedBased = false;
            _easeType = HOTween.defEaseType;
            _easeOvershootOrAmplitude = HOTween.defEaseOvershootOrAmplitude;
            _easePeriod = HOTween.defEasePeriod;
            _originalEaseType = HOTween.defEaseType;
            onPluginOverwritten = null;
            onStepCompleteWParms = null;
            onPluginOverwrittenParms = null;
        }
示例#2
0
        /// <summary>
        /// If this Tweener contains a <see cref="PlugVector3Path"/> tween,
        /// defines a portion of that path to use and re-adapt to,
        /// and rewinds/restarts the tween in its partial form (depending if it was paused or not).
        /// </summary>
        /// <param name="p_waypointId0">
        /// Id of the new starting waypoint on the current path.
        /// If you want to be sure you're targeting the first point in the path, pass -1
        /// (this is because the first waypoint of the path might be different from the first waypoint you passed,
        /// in case the target Transform was not already on the starting position, and thus needed to reach it).
        /// </param>
        /// <param name="p_waypointId1">
        /// Id of the new ending waypoint on the current path 
        /// (-1 in case you want to target the ending waypoint of a closed path)
        /// </param>
        /// <param name="p_newDuration">
        /// Tween duration of the partial path (if -1 auto-calculates the correct partial based on the original duration)
        /// </param>
        /// <param name="p_newEaseType">New EaseType to apply</param>
        public Tweener UsePartialPath(int p_waypointId0, int p_waypointId1, float p_newDuration, EaseType p_newEaseType)
        {
            if (plugins.Count > 1) {
                TweenWarning.Log("Applying a partial path on a Tweener (" + _target + ") with more than one plugin/property being tweened is not allowed");
                return this;
            }

            if (pv3Path == null) {
                // Get eventual plugVector3Path plugin
                pv3Path = GetPlugVector3PathPlugin();
                if (pv3Path == null) {
                    TweenWarning.Log("Tweener for " + _target + " contains no PlugVector3Path plugin");
                    return this;
                }
            }

            // Startup the tween (if not already started) to store the path data.
            Startup();
            // Store original duration and easeType (if not already stored).
            if (!isPartialled) {
                isPartialled = true;
                _originalDuration = _duration;
                _originalEaseType = _easeType;
            }
            // Convert waypoints ids to path ids
            int pathWaypointId0 = ConvertWaypointIdToPathId(pv3Path, p_waypointId0, true);
            int pathWaypointId1 = ConvertWaypointIdToPathId(pv3Path, p_waypointId1, false);
            // Get waypoints length percentage (needed for auto-duration and calculation of lookAhed)
            float partialPerc = pv3Path.GetWaypointsLengthPercentage(pathWaypointId0, pathWaypointId1);
            float partialStartPerc = pathWaypointId0 == 0 ? 0 : pv3Path.GetWaypointsLengthPercentage(0, pathWaypointId0);
            // Assign new duration and ease
            _duration = p_newDuration >= 0 ? p_newDuration : _originalDuration * partialPerc;
            _easeType = p_newEaseType;

            // Convert path to partial
            pv3Path.SwitchToPartialPath(_duration, p_newEaseType, partialStartPerc, partialPerc);

            // Re-Startup and restart
            Startup(true);
            if (!_isPaused)
                Restart(true);
            else {
                Rewind(true, true);
            }

            return this; // Returns this so it can be directly used with WaitForCompletion coroutines
        }
示例#3
0
 /// <summary>
 /// Returns the correct id of the given waypoint, converted to path id.
 /// </summary>
 /// <param name="p_plugVector3Path">Vector3 path plugin to use</param>
 /// <param name="p_waypointId">Waypoint to convert</param>
 /// <param name="p_isStartingWp">If TRUE indicates that the given waypoint is the starting one,
 /// otherwise it's the ending one</param>
 /// <returns></returns>
 static int ConvertWaypointIdToPathId(PlugVector3Path p_plugVector3Path, int p_waypointId, bool p_isStartingWp)
 {
     if (p_waypointId == -1) return p_isStartingWp ? 1 : p_plugVector3Path.path.path.Length - 2;
     if (p_plugVector3Path.hasAdditionalStartingP) return p_waypointId + 2;
     return p_waypointId + 1;
 }
示例#4
0
 //disables any running movement methods
 public void Stop()
 {
     //exit waypoint coroutine
     StopAllCoroutines();
     //destroy current HOTween movement component
     HOTween.Kill(transform);
     plugPath = null;
     tween = null;
     //play idle animation if set
     PlayIdle();
 }
示例#5
0
    //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);

        //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)
            plugPath.ClosePath(true);

        //create TweenParms for storing HOTween's parameters
        tParms = new TweenParms();
        //sets the path plugin as tween position property
        if (local)
            tParms.Prop("localPosition", plugPath);
        else
            tParms.Prop("position", plugPath);
        //additional tween parameters for partial tweens
        tParms.AutoKill(false);
        tParms.Pause(true);
        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
            tParms.Ease(easetype);

        //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);
    }
示例#6
0
    //creates a new HOTween tween which moves us to the next waypoint
    //(defined by passed arguments)
    internal void CreateTween()
    {
        //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);

        //orients the tween target along the path
        //constrains this game object on one axis
        if (orientToPath)
            plugPath.OrientToPath();

        //create TweenParms for storing HOTween's parameters
        tParms = new TweenParms();
        //sets the path plugin as tween position property
        tParms.Prop("position", plugPath);
        tParms.AutoKill(true);

        //differ between TimeValue like mentioned above at enum TimeValue
        //use speed with linear easing
        if (timeValue == TimeValue.speed)
            tParms.SpeedBased();
        //else, use time value with linear easing
        tParms.Ease(EaseType.Linear);
        tParms.OnComplete(OnPathComplete);

        //create a new tween, move this gameobject with given arguments
        tween = HOTween.To(transform, maxSpeed, tParms);
    }
示例#7
0
	void Start()
	{
		HOTween.showPathGizmos = true;

		Vector3[] path = new[] {
			Vector3.zero,
			new Vector3(0,1,0),
			new Vector3(1,2,0),
			new Vector3(2,1,0),
			new Vector3(2,0,0)
		};

		Axis lockRotation = lockRotation0 | lockRotation1;

		PlugVector3Path plugPath = new PlugVector3Path(path, true).ClosePath().OrientToPath(0.1f, lockRotation).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[0], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();
		plugPath = new PlugVector3Path(path).ClosePath().LookAt(targets[2]).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[1], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();

		// Linear VS curved
		plugPath = new PlugVector3Path(path, true, PathType.Curved).ClosePath().LookAt(Vector3.zero).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[2], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();
		plugPath = new PlugVector3Path(path, true, PathType.Linear).ClosePath().OrientToPath(0.1f, lockRotation).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[3], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();

		// Linear VS curved top-down
		path = new[] {
			Vector3.zero,
			new Vector3(0,0,1),
			new Vector3(1,0,2),
			new Vector3(2,0,1),
			new Vector3(2,0,0)
		};
		plugPath = new PlugVector3Path(path, true, PathType.Curved).ClosePath().OrientToPath(0.1f, lockRotation).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[4], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();
		plugPath = new PlugVector3Path(path, true, PathType.Linear).ClosePath().OrientToPath(0.1f, lockRotation).LockPosition(lockPosition);
		if (is2DPath) plugPath.Is2D(is2DSideScroller);
		HOTween.To(targets[5], 3, new TweenParms()
			.Prop("position", plugPath)
			.Ease(EaseType.Linear)
			.Loops(-1)
		).Pause();
	}