public IEnumerator PedestrianCrossingEnterAndExitTest() { DisableLoops(); DisableVehicles(); PedestrianCrossing pedestrianCrossing = GameObject.FindObjectOfType <PedestrianCrossing>(); Vector3 centerPosition = pedestrianCrossing.GetComponent <BoxCollider>().bounds.center; GameObject pedestrian = SpawnPedestrian(true); yield return(new WaitForSeconds(1)); pedestrian.transform.position = centerPosition; yield return(new WaitForSeconds(1)); Assert.IsTrue(pedestrianCrossing.pedestriansCurrentlyInCrossingArea.Contains(pedestrian.GetComponent <Pedestrian>())); pedestrian.transform.position = Vector3.forward * 1000; yield return(new WaitForSeconds(1)); Assert.IsFalse(pedestrianCrossing.pedestriansCurrentlyInCrossingArea.Contains(pedestrian.GetComponent <Pedestrian>())); }
public IEnumerator PedestrianCrossingAllowCrossingTest() { DisableLoops(); DisableVehicles(); PedestrianCrossing pedestrianCrossing = GameObject.FindObjectOfType <PedestrianCrossing>(); pedestrianCrossing.SetAllowCrossing(false); Vector3 centerPosition = pedestrianCrossing.GetComponent <BoxCollider>().bounds.center; GameObject pedestrian = SpawnPedestrian(true); yield return(new WaitForSeconds(1)); pedestrian.transform.position = centerPosition; yield return(new WaitForSeconds(1)); Assert.IsFalse(pedestrian.GetComponent <Pedestrian>().GetAllowCrossing()); yield return(new WaitForSeconds(1)); pedestrianCrossing.SetAllowCrossing(true); Assert.IsTrue(pedestrian.GetComponent <Pedestrian>().GetAllowCrossing()); }