/// <summary> /// draws the arrows on the spline /// arrow will be pointing to the direction the player will move to /// </summary> /// <param name="point">points to draw arrows at</param> void DrawArrow(int point) { for (int s = 0; s < spline.GetSubwaysLength(point); s++) { float size = HandleUtility.GetHandleSize(spline.GetPosition(point)); Handles.ArrowCap(0, spline.GetPosition(point), Quaternion.LookRotation(spline.GetPointAtTime(0.2f, point, s) - spline.GetPosition(point)), size); } }
/// <summary> /// Comparing two splines /// </summary> /// <param name="o"></param> /// <returns></returns> public override bool Equals(object o) { Spline other = (Spline)o; if (Length != other.Length) { return(false); } for (int i = 0; i < Length; i++) { if (waypoints[i].localPosition != other.waypoints[i].localPosition) { return(false); } if (GetHandlesLength(i) != other.GetHandlesLength(i)) { return(false); } if (waypoints[i].localHandles.Length != other.waypoints[i].localHandles.Length) { return(false); } if (GetSubwaysLength(i) != other.GetSubwaysLength(i)) { return(false); } if (GetReversewaysLength(i) != other.GetReversewaysLength(i)) { return(false); } if (resolution != other.resolution) { return(false); } if (waypoints[i].method != other[i].method) { return(false); } for (int c = 0; c < waypoints[i].localHandles.Length; c++) { if (waypoints[i].localHandles[c] != other.waypoints[i].localHandles[c]) { return(false); } } } return(true); }
/// <summary> /// start moving on the spline at the given point /// note : this method will return false if the inputs you gave are invalid /// </summary> /// <param name="point">point you want to start moving from</param> /// <param name="subway">the subway you want to start from (if the point have multiple ways changing this will change the way it will take) /// otherwise put it 0</param> /// <param name="segment">a float value that detremain where to start exactly if you set it to 0.5 it will start half way throw the given point</param> /// <returns>false if the inputs you gave are invalid</returns> public bool StartMoving(int point, int subway = 0, float segment = 0, bool bReverse = false) { if (spline.Length <= point && spline.GetSubwaysLength(point) <= subway && segment >= 1 && segment < 0) { return(false); } _currPoint = point; _currSubway = subway; currSeg = segment; moving = true; if (currSeg == 0) { if (events.Length > _currPoint) { events[_currPoint].Invoke(); } } rpp = GetRPP(_currPoint, _currSubway); reverse = bReverse; return(true); }