void fogSet() { FogControl f = mainCamera.GetComponent <FogControl> () as FogControl; //Set whether there is fog and the color and such, can update the color if there is fog f.fog = false; f.fog_color = Color.gray; f.fog_density = 0; }
// Nathan wrote this // class constructor // road is the road object in the development environment public RoadData(Road road) { // store the environment as an EnvironmentData variable Buildings buildingScriptReference = road.getBuildingsReference(); buildingsIndex = buildingScriptReference.getBuildingIndex(); // store the fog variables FogControl fogControlScriptReference = road.getFogControl(); fogDistance = fogControlScriptReference.getFogDistance(); // store the lighting intensities BrightnessControl[] lightScripts = road.getLights(); for (int i = 0; i < lightScripts.Length; i++) { lightIntensities[i] = lightScripts[i].getBrightness(); } // store the lanes as a list of LaneData LinkedList <GameObject> roadLanes = road.getLanes(); // store the lanes foreach (GameObject lane in roadLanes) { BasicLane laneScriptRef = (BasicLane)lane.GetComponent("BasicLane"); LaneData indLaneData = null; // if we have a non-vehicle lane, create the independent lane data with a prop manager if (!laneScriptRef.isVehicleLane()) { PropManager propManagerRef = lane.GetComponent <PropManager>(); indLaneData = new LaneData(laneScriptRef, propManagerRef); } else { indLaneData = new LaneData(laneScriptRef); } laneData.Add(indLaneData); } }
// Nathan wrote this // loads the road from a binary file public void loadRoad(string filename) { UIManager.Instance.closeCurrentUI(); // steps: // 1. clear the contents of the road // 2. obtain the saved road data // 3. insert each saved lane into the road: // a. obtain the saved lane's type // b. find that lane type and insert it // c. obtain a reference to the lane's script // d. adjust the lane's stripes if it's not a vehicle lane // e. load the rest of the attributes // f. load the lanes props (if not a vehicle lane) // 4. load the saved environment // 5. load the saved fog settings // 6. load the saved lighting settings // 1. we have to clear whatever else the user has loaded in since the last save clearRoad(); // 2. obtain the saved data RoadData roadData = RoadVizSaveSystem.loadRoadFromMemory(filename); List <LaneData> savedLanes = roadData.loadLaneData(); // 3. load each of the saved lanes in GameObject currLane = null; foreach (LaneData savedLane in savedLanes) { // 3a: obtain the lane's type string loadedLaneType = savedLane.loadLaneType(); // 3b. find the type and insert it GameObject loadedLane = findLaneType(loadedLaneType); insertLane(currLane, loadedLane, "right"); currLane = roadLanes.Last.Value; // 3c. obtain a script reference BasicLane loadedLaneScriptReference = (BasicLane)currLane.GetComponent("BasicLane"); // 3d. adjust stripes if (!loadedLaneScriptReference.isVehicleLane()) { LinkedListNode <GameObject> loadedLaneNode = roadLanes.Last; handleNonVehicleLaneStripes(loadedLaneScriptReference, loadedLaneNode); } // 3e. load the rest of the lane's variables loadedLaneScriptReference.loadLaneAtts(savedLane); // 3f. load the lanes props (if not a vehicle lane) if (!loadedLaneScriptReference.isVehicleLane()) { PropManager loadedPropManagerRef = currLane.GetComponent <PropManager>(); loadedPropManagerRef.loadProps(savedLane.loadPropManagerData()); } } // 4. load the saved buildings Buildings buildingsScriptReference = (Buildings)buildingsReference.GetComponent("Buildings"); buildingsScriptReference.setBuildingType(roadData.loadBuildingsIndex()); StartCoroutine(FrameDelayBuildingUpdate()); // 5. load the saved fog settings FogControl fogControlScriptReference = (FogControl)fogController.GetComponent("FogControl"); fogControlScriptReference.setFogDistance(roadData.loadFogDistance()); // 6. load the saved lighting settings float[] lightIntensities = roadData.loadLightIntensities(); BrightnessControl[] lightScripts = getLights(); for (int i = 0; i < lightScripts.Length; i++) { lightScripts[i].setBrightness(lightIntensities[i]); } }
public void init(params GameObject[] objRefs) { fogController = GameObject.Find("FogController").GetComponent <FogControl>(); lightController = GameObject.Find("Lights/Solar Light").GetComponent <BrightnessControl>(); updateUIValues(); }