public IEnumerator PythonManagerGetScreenshotFilePathTest() { string path = PythonManager.GetInstance().GetScreenshotFilePath("screenshots/", "junction1", 5); Assert.AreEqual("screenshots/junction1_shot5.png", path); yield return(null); }
private void OnPostRender() { if (renderScreenshot) { Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false); texture.Apply(); PythonManager.GetInstance().SetScreenshot(camera, texture); renderScreenshot = false; } }
public IEnumerator PythonManagerRewardCountTest() { int currentCount = PythonManager.GetInstance().GetRewardCount(); currentCount++; PythonManager.GetInstance().IncrementRewardCount(); Assert.AreEqual(PythonManager.GetInstance().GetRewardCount(), currentCount); currentCount = 0; PythonManager.GetInstance().ResetRewardCount(); Assert.AreEqual(PythonManager.GetInstance().GetRewardCount(), currentCount); yield return(null); }
public void DisableLoops() { TrafficLightManager trafficLightManager = (TrafficLightManager)GameObject.FindObjectOfType(typeof(TrafficLightManager)); trafficLightManager.StopAllCoroutines(); PythonManager.GetInstance().StopAllCoroutines(); PedestrianFactory pedestrianFactory = (PedestrianFactory)GameObject.FindObjectOfType(typeof(PedestrianFactory)); if (pedestrianFactory != null) { pedestrianFactory.StopAllCoroutines(); } }
void OnTriggerEnter(Collider other) { VehicleEngine vehicleEngine = other.GetComponentInParent <VehicleEngine>(); if (vehicleEngine != null && !vehicleEngine.densityCountTriggered) { vehicleEngine.densityCountTriggered = true; PythonManager.GetInstance().IncrementDensityCount(); // Calculate Delay if (vehicleEngine.startDelayTime != -1) { float delay = Time.time - vehicleEngine.startDelayTime; Utils.AppendAllTextToResults(Utils.VEHICLE_DELAY_TIMES_FILE_NAME, delay.ToString() + ","); } } }
/// <summary> /// Destroys the vehicle and passes information to the Python Manager. /// </summary> private void Destroy() { if (!densityCountTriggered) { densityCountTriggered = true; PythonManager.GetInstance().IncrementDensityCount(); } Vector3 endPos = transform.position; double distance = Vector3.Distance(startPos, endPos); double time = (Time.time - startTime); double speed = (distance / time); PythonManager.GetInstance().speedList.Add(speed); Destroy(this.gameObject); PythonManager.GetInstance().IncrementRewardCount(); Utils.AppendAllTextToResults(Utils.VEHICLE_TIMES_FILE_NAME, time.ToString() + ","); }
private new void DisableLoops() { // Optimize time by removing unneeded particles foreach (ParticleSystem particleSystem in GameObject.FindObjectsOfType <ParticleSystem>()) { particleSystem.Stop(); } TrafficLightManager trafficLightManager = (TrafficLightManager)GameObject.FindObjectOfType(typeof(TrafficLightManager)); trafficLightManager.enabled = false; trafficLightManager.StopAllCoroutines(); VehicleFactory vehicleFactory = (VehicleFactory)GameObject.FindObjectOfType(typeof(VehicleFactory)); vehicleFactory.StopAllCoroutines(); PythonManager.GetInstance().StopAllCoroutines(); PedestrianFactory pedestrianFactory = (PedestrianFactory)GameObject.FindObjectOfType(typeof(PedestrianFactory)); if (pedestrianFactory != null) { pedestrianFactory.StopAllCoroutines(); } }
public void TearDown() { PythonManager.GetInstance().rewardCount = 0; PythonManager.GetInstance().densityCount = 0; }