public void Init(LogicalRoadnet network) { // add cars cars.Add(new Car(network, true)); int number_of_cars = 99; for (int i = 0; i < number_of_cars; i++) { cars.Add(new Car(network, false)); } // traffic is ready ready = true; // init stalkercam StalkerCam stalker = GameObject.Find("stalker").AddComponent(typeof(StalkerCam)) as StalkerCam; stalker.go = cars[0].model; stalker.ready = true; // init helicam HeliCam heli = GameObject.Find("heli").AddComponent(typeof(HeliCam)) as HeliCam; heli.go = cars[0].model; heli.ready = true; cars[0].debugging = true; // set up the marker over car #0 marker = GameObject.CreatePrimitive(PrimitiveType.Sphere); marker.GetComponent <Renderer>().material.color = Color.magenta; marker.transform.localScale = new Vector3(GraphicalRoadnet.roadWidth / 6, GraphicalRoadnet.roadWidth / 6, GraphicalRoadnet.roadWidth / 6); marker_large = GameObject.CreatePrimitive(PrimitiveType.Sphere); marker_large.GetComponent <Renderer>().material.color = Color.magenta; marker_large.transform.localScale = new Vector3(GraphicalRoadnet.roadWidth * 2, GraphicalRoadnet.roadWidth * 2, GraphicalRoadnet.roadWidth * 2); }
public Car(LogicalRoadnet network, bool debugging) { this.network = network; this.debugging = debugging; // pick a starting intersection source = network.intersections[Deterministic.random.Next(network.intersections.Count)]; destination = InitialDestination(source); // pick a car model int model_index = Deterministic.random.Next(car_models.Length); model = LoadPrefab(car_models[model_index]); // move car to starting position position = position + source.coordinates; // set position model.transform.position = position; model.transform.localScale = scale; UpdateDirection(); }