Beispiel #1
0
 void CheckForOffturn()
 {
     if (CurrentRoad.HasOffturn && Random.Range(0, 10) >= 7)
     {
         _intersectionStraight = CurrentRoad.OffTurns.First();
         _turnOffOffset        = _intersectionStraight.IntersectionOffset * CurrentRoad.Path.PathLength;
         _shouldTurnOff        = true;
         if (Log)
         {
             Debug.Log($"Car will turn off at {_turnOffOffset}");
         }
     }
 }
Beispiel #2
0
    void FindConnectedIntersections()
    {
        var intersections = RoadCollection.Instance.Intersections;

        if (intersections.Count == 0)
        {
            return;
        }

        intersections.ForEach(intersection => {
            IntersectionStraight straight = intersection.GetComponent <IntersectionStraight>();
            if (straight == null)
            {
                return;
            }
            if (straight.MainRoad != this)
            {
                return;
            }
            HasOffturn = true;
            OffTurns.Add(straight);
        });
    }
 void OnEnable()
 {
     _intersectionStraight = (IntersectionStraight)target;
 }