示例#1
0
 IEnumerator RUNLerp(Vector3 start,Vector3 end, bool firstRoad)
 {
     endRoad.SetFilled (speed);
     startTime = Time.time;
     journeyLength = Vector3.Distance(start, end);
     while (Vector3.Distance (gameObject.transform.position, end) >= 0.01f) {
         float distCovered = (Time.time - startTime) * speed;
         float fracJourney = distCovered / journeyLength;
         transform.position = Vector3.Lerp (start, end, fracJourney);
         yield return null;
     }
     if (!firstRoad) {
         previousRoad.SetNotFilled();
     }
     startMarker = endMarker;
     endMarker = endRoad.adjRoads [0, 1].WaypointPos();
     previousRoad = endRoad;
     endRoad = endRoad.adjRoads [0, 1];
     if (endRoad.adjRoads [0, 1] == null) {
         endRoad.SetNotFilled();
         previousRoad.SetNotFilled();
         Destroy (gameObject);
     }
     else if (endRoad.CheckFilled () < 0) {
         speed = 0;
         previousRoad.SetFilled (-1);
         yield return null;
     }
     else if (endRoad.CheckFilled () != 0) {
         speed = endRoad.CheckFilled ();
         yield return StartCoroutine (ChangeLanes ());
     } else {
         StartCoroutine (RUNLerp (startMarker, endMarker, false));
     }
 }