/// <summary> /// Shifts the Min and Max Indices to the next set for route movement /// </summary> /// <param name="valueWaypoint">Value Waypoint interface to modify</param> /// <param name="scaleDirection">Direction of shift -1, 0, 1</param> public static void Shift(IValueWaypoint valueWaypoint, float scaleDirection) { if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_FORWARD)) { ValueSmoothWaypointUtils.ShiftMinMaxIndex(valueWaypoint, valueWaypoint.nodes.Length - 1, 0, ValueSmoothWaypointUtils._CanIncrement, _Add, 0.0f); } else if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_REVERSE)) { ValueSmoothWaypointUtils.ShiftMinMaxIndex(valueWaypoint, 0, valueWaypoint.nodes.Length - 1, ValueSmoothWaypointUtils._CanDecrement, _Sub, 1.0f); } else // ValueSmoothWaypointUtils.DIRECTION_NONE { } }
/// <summary> /// Responds to OnClamped event from Value Waypoint /// </summary> /// <param name="valueWaypoint">Value Waypoint sending the event</param> public static void OnValueWaypointClamp(IValueWaypoint valueWaypoint) { float scaleDirection = Mathf.Sign(valueWaypoint.scale); switch (valueWaypoint.actionType) { case ActionType.PingPong: if (!valueWaypoint.loop) { if (!ValueSmoothWaypointUtils.IsRouteCycleCompleted(valueWaypoint)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, scaleDirection); } } else { if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_REVERSE) && valueWaypoint.direction.Equals(ValueSmoothWaypointUtils.DIRECTION_REVERSE)) { if (!ValueSmoothWaypointUtils._FlipDirection.Invoke(valueWaypoint, valueWaypoint.currentIndex, ValueSmoothWaypointUtils._GreaterOrEqual)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, -scaleDirection); } } else if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_REVERSE) && valueWaypoint.direction.Equals(ValueSmoothWaypointUtils.DIRECTION_FORWARD)) { if (!ValueSmoothWaypointUtils._FlipDirection.Invoke(valueWaypoint, valueWaypoint.currentIndex, ValueSmoothWaypointUtils._LessOrEqual)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, scaleDirection); } } else if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_FORWARD) && valueWaypoint.direction.Equals(ValueSmoothWaypointUtils.DIRECTION_FORWARD)) { if (!ValueSmoothWaypointUtils._FlipDirection.Invoke(valueWaypoint, valueWaypoint.currentIndex, ValueSmoothWaypointUtils._GreaterOrEqual)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, scaleDirection); } } else if (scaleDirection.Equals(ValueSmoothWaypointUtils.DIRECTION_FORWARD) && valueWaypoint.direction.Equals(ValueSmoothWaypointUtils.DIRECTION_REVERSE)) { if (!ValueSmoothWaypointUtils._FlipDirection.Invoke(valueWaypoint, valueWaypoint.currentIndex, ValueSmoothWaypointUtils._LessOrEqual)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, -scaleDirection); } } } break; case ActionType.Wrap: if (!valueWaypoint.loop) { if (!ValueSmoothWaypointUtils.IsRouteCycleCompleted(valueWaypoint)) { ValueSmoothWaypointUtils.Shift(valueWaypoint, scaleDirection); } } else { ValueSmoothWaypointUtils.Shift(valueWaypoint, scaleDirection); } break; case ActionType.None: case ActionType.Random: default: break; } valueWaypoint.Prepare(); ValueWaypointUtils.SetVecsToNode(valueWaypoint); }