示例#1
0
        public void updateCurrentLaneAtEnd()
        {
            Road nextRoad = getNextRoad();

            if (nextRoad == null)
            {
                return;
            }

            //Debug.Log(currentRoad.direction + "\t" + nextRoad.direction);
            // go straight
            if (nextRoad.direction == currentRoad.direction)
            {
                currentTrackIdx++;
                currentRoad = tracks[currentTrackIdx];

                currentLane = currentRoad.lanes[currentLane.index];
            }
            else if (Util.getRltDirection(currentRoad.direction, nextRoad.direction) == RltDirection.Left)
            {
                generateTurnWaypoint(currentLane, tracks[currentTrackIdx + 1].getLeftmostLane());
                currentTrackIdx++;
                currentRoad  = tracks[currentTrackIdx];
                isFarTurning = true;
                currentLane  = currentRoad.getLeftmostLane();
            }
            else if (Util.getRltDirection(currentRoad.direction, nextRoad.direction) == RltDirection.Right)
            {
                generateTurnWaypoint(currentLane, tracks[currentTrackIdx + 1].getRightmostLane());
                currentTrackIdx++;
                currentRoad   = tracks[currentTrackIdx];
                isNearTurning = true;
                currentLane   = currentRoad.getRightmostLane();
            }
        }
示例#2
0
 private void initialize(string _carID)
 {
     isNearTurning    = false;
     isFarTurning     = false;
     currentTrackIdx  = 0;
     currentChangeIdx = 0;
     currentTurnIdx   = 0;
     currentRoad      = tracks[currentTrackIdx];
     setCurrentLane(currentRoad.getRightmostLane());
     waypointChildren = new GameObject();
     waypointChildren.transform.parent = transform;
     turnWaypoints   = new List <Vector3>();
     changeWaypoints = new List <Vector3>();
     carID           = _carID;
 }