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>(); }
void Start() { twoLanePathGenerator = FindObjectOfType <TwoLanePathGenerator>(); if (direction == LightDirection.North) { carDirection = new Vector3(0, 0, 0); } if (direction == LightDirection.East) { carDirection = new Vector3(0, 0, 270); } if (direction == LightDirection.South) { carDirection = new Vector3(0, 0, 180); } if (direction == LightDirection.West) { carDirection = new Vector3(0, 0, 90); } //create unique ID for spawn road so weighted rate can get assigned //setup generation for cars //On timer call Spawn() Dictionary <int, float> weightedSpawnRatesDict = SimSettings.getDictionary(); float weight; if (weightedSpawnRatesDict.TryGetValue(id, out weight)) { spawnRate = weight / Application.targetFrameRate; } else { spawnRate = 10.0f / Application.targetFrameRate; } if (PlayerPrefs.GetString("sim_name") == "LargeTwoLaneGrid") { print("large two lane"); spawnRate *= 2; } InvokeRepeating("Spawn", 0.0f, spawnRate); }