public void Start()
 {
     intersection = this.transform.parent.GetComponent <IntersectionTwoLane>();
     visibleLight = this.GetComponent <SpriteRenderer>();
     red          = new Color32(204, 6, 5, 255);
     yellow       = new Color32(250, 210, 1, 255);
     green        = new Color32(51, 165, 50, 255);
 }
 public void Start()
 {
     intersection         = transform.GetComponent <IntersectionTwoLane>();
     twoLanePathGenerator = FindObjectOfType <TwoLanePathGenerator>();
     spawnRoads           = new List <SpawnRoad>(FindObjectsOfType <SpawnRoad>());
     exitRoads            = new List <ExitRoad>(FindObjectsOfType <ExitRoad>());
     spawnDiff            = maxSpawnRate - minSpawnRate;
     exitDiff             = maxExitRate - minExitRate;
     agent = FindObjectOfType <OneIntersectionController>();
 }
Example #3
0
    //Helper function for FloydBigBrain
    private bool IsNeighbor(Road r, IntersectionTwoLane i, LightDirection incomingDirection)
    {
        bool TurnIntersection = false;

        if (i.lightController is Turn)
        {
            TurnIntersection = true;
        }
        if (r == i.outboundNorthRoad?.straightRoadScript)
        {
            if (TurnIntersection && incomingDirection == LightDirection.South)
            {
                return(false);
            }
            return(true);
        }
        if (r == i.outboundEastRoad?.straightRoadScript)
        {
            if (TurnIntersection && incomingDirection == LightDirection.West)
            {
                return(false);
            }
            return(true);
        }
        if (r == i.outboundSouthRoad?.straightRoadScript)
        {
            if (TurnIntersection && incomingDirection == LightDirection.North)
            {
                return(false);
            }
            return(true);
        }
        if (r == i.outboundWestRoad?.straightRoadScript)
        {
            if (TurnIntersection && incomingDirection == LightDirection.East)
            {
                return(false);
            }
            return(true);
        }
        return(false);
    }
 public void Start()
 {
     intersection = this.transform.GetComponent <IntersectionTwoLane>();
 }
 public void Awake()
 {
     intersection = this.transform.GetComponent <IntersectionTwoLane>();//Make intersection accessible from light controller
 }