Example #1
0
        private IEnumerator IntroBriefing()
        {
            //Actually start introduction audio briefing.
            hudController.model.centerText = "Welcome to Bryce's Scenario!";
            yield return(new WaitForSeconds(2f));

            ambientAudioSource.mute = true;
            audioController.playAudio(0);
            yield return(new WaitForSeconds(5f));

            //audioController.playAudio(10);
            hudController.model.centerText = VRAVEStrings.Right_Paddle_To_Continue;
            GameObject rightPaddle = GameObject.FindGameObjectWithTag(VRAVEStrings.Right_Paddle);

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = true;
            yield return(new WaitForSeconds(0.5f));

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = false;
            yield return(new WaitForSeconds(0.5f));

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = true;
            yield return(new WaitForSeconds(0.5f));

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = false;
            yield return(new WaitForSeconds(0.5f));

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = true;

            //Ensure paddle glow is turned off.
            yield return(new WaitForSeconds(3f));

            (rightPaddle.GetComponent("Halo") as Behaviour).enabled = false;
        }
Example #2
0
        private IEnumerator CycleThroughAudio(int idx, int numTimes)
        {
            for (int i = 0; i < numTimes; ++i)
            {
                hudAudioController.playAudio(idx);

                yield return(new WaitForSeconds(hudAudioController.audioModel.durations [idx]));
            }
        }
Example #3
0
        void Awake()
        {
            Initialize <States> ();

            UserCar.GetComponent <CarAIControl> ().enabled   = false;
            UserCar.GetComponent <CarUserControl> ().enabled = true;

            spawnController = GetComponent <SpawnController>();
            hudController   = UserCar.GetComponentInChildren <HUDController>();
            audioController = UserCar.GetComponentInChildren <HUDAudioController> ();


            ambientAudioSource      = GameObject.FindGameObjectWithTag(VRAVEStrings.Ambient_Audio).GetComponent <AudioSource>();
            ambientAudioSource.mute = true;

            hudController.models    = new HUDModel[2];
            hudController.durations = new float[2];

            hudAsyncController = UserCar.GetComponentInChildren <HUDAsyncController> ();
            hudAsyncController.Configure(audioController, hudController);

            mirror = GameObject.FindWithTag(VRAVEStrings.Mirror);
            audioController.audioModel = GameObject.FindObjectOfType <WeatherAudioModel> ();

            spawnModel = new WeatherSpawnModel();
            spawnController.spawnModel = spawnModel;

            //hudController.model = new DefaultHUD ();

            UserCar.GetComponent <CarAIControl> ().enabled   = false;
            UserCar.GetComponent <CarUserControl> ().enabled = false;

            movingAI0.GetComponent <CarAIControl> ().enabled = false;
            movingAI1.GetComponent <CarAIControl> ().enabled = false;
            movingAI2.GetComponent <CarAIControl> ().enabled = false;
            movingAI3.GetComponent <CarAIControl> ().enabled = false;

            movingAIStart0 = new KeyValuePair <Vector3, Quaternion> (movingAI0.transform.position, movingAI0.transform.rotation);
            movingAIStart1 = new KeyValuePair <Vector3, Quaternion> (movingAI1.transform.position, movingAI1.transform.rotation);
            movingAIStart2 = new KeyValuePair <Vector3, Quaternion> (movingAI2.transform.position, movingAI2.transform.rotation);
            movingAIStart3 = new KeyValuePair <Vector3, Quaternion> (movingAI3.transform.position, movingAI3.transform.rotation);

            spawnController.enterScenario();

            /*foreach(GameObject nonMovingAICar in spawnController.initialSpawnedObjects.Values) {
             *      nonMovingAICar.GetComponent<CarAIControl> ().enabled = false;
             *      nonMovingAICar.GetComponent<CarAIControl> ().Circuit = movingAI0.GetComponent<CarAIControl> ().Circuit;
             * }*/

            resetScenario();
            ChangeState(States.ScenarioBriefing);

            cameraFade.StartAlphaFade(Color.black, true, 3f, () => {
                audioController.playAudio(3);
                StartCoroutine(PostIntersectionScenarioBriefingHUDChange());
            });
        }
Example #4
0
        void Awake()
        {
            Initialize <States> ();

            carController          = UserCar.GetComponent <CarController> ();
            carController.MaxSpeed = 15f;
            carAI = UserCar.GetComponent <CarAIControl> ();
            sensitiveSensorResponseHandler = UserCar.GetComponent <SensitiveSensorResponseHandler> ();
            trashCanSensorResponseHandler  = UserCar.GetComponent <TrashcanSensorResponseHandler> ();

            crazyAI            = CrazyIntersectionAI.GetComponent <CarAIControl> ();
            crazyCarController = CrazyIntersectionAI.GetComponent <CarController> ();

            hudController           = UserCar.GetComponentInChildren <HUDController> ();
            audioController         = UserCar.GetComponentInChildren <HUDAudioController> ();
            ambientAudioSource      = GameObject.FindWithTag(VRAVEStrings.Ambient_Audio).GetComponent <AudioSource>();
            ambientAudioSource.mute = true;
            hudAsyncController      = UserCar.GetComponentInChildren <HUDAsyncController> ();

            mirror = GameObject.FindWithTag(VRAVEStrings.Mirror);
            audioController.audioModel = GameObject.FindObjectOfType <ReactionTimeAudioModel> ();

            // configure HUD models
            hudController.models    = new HUDModel[2];
            hudController.durations = new float[2];
            hudController.models[0] = new HUDVRAVE_Default();
            hudController.model     = hudController.models[0];

            // configure ASYNC controller
            hudAsyncController.Configure(audioController, hudController);

            unsuspectingCarAI = UnsuspectingAI.GetComponent <CarAIControl> ();

            foreach (GameObject o2 in triggers)
            {
                o2.SetActive(false);
            }

            resetIntersectionScenario();

            //resetTrashCanScenario();

            //ChangeState (States.TrashcanBriefing);
            ChangeState(States.IntersectionBriefing);
            //ChangeState(States.AIDrivingToTrashcanBriefing);


            cameraFade.StartAlphaFade(Color.black, true, 3f, () => {
                audioController.playAudio(3);
                StartCoroutine(PostIntersectionScenarioBriefingHUDChange());
            });
        }
        // Use this for initialization
        void Start()
        {
            cityAudioModel = new HUDAudioModel();
            cityAudioModel.addClip("Urban-Ambient", 25f);

            cityAudioController = GetComponent <HUDAudioController> ();

            cityAudioController.primaryAudioSource = citySounds;

            cityAudioController.audioModel = cityAudioModel;

            cityAudioController.playAudio(0);
        }
		// Use this for initialization
		void Start ()
		{
			cityAudioModel = new HUDAudioModel ();
			cityAudioModel.addClip ("Urban-Ambient", 25f);

			cityAudioController = GetComponent<HUDAudioController> ();

			cityAudioController.primaryAudioSource = citySounds;

			cityAudioController.audioModel = cityAudioModel;

			cityAudioController.playAudio (0);
		}
Example #7
0
		void Awake()
		{
			Initialize<States> ();

			UserCar.GetComponent<CarAIControl> ().enabled = false;
			UserCar.GetComponent<CarUserControl> ().enabled = true;

			spawnController = GetComponent<SpawnController>();
			hudController = UserCar.GetComponentInChildren<HUDController>();
			audioController = UserCar.GetComponentInChildren<HUDAudioController> ();


			ambientAudioSource = GameObject.FindGameObjectWithTag(VRAVEStrings.Ambient_Audio).GetComponent<AudioSource>();
			ambientAudioSource.mute = true;

			hudController.models = new HUDModel[2];
			hudController.durations = new float[2];

			hudAsyncController = UserCar.GetComponentInChildren<HUDAsyncController> ();
			hudAsyncController.Configure(audioController, hudController);

			mirror = GameObject.FindWithTag (VRAVEStrings.Mirror);
			audioController.audioModel = GameObject.FindObjectOfType<WeatherAudioModel> ();

			spawnModel = new WeatherSpawnModel ();
			spawnController.spawnModel = spawnModel;

			//hudController.model = new DefaultHUD ();

			UserCar.GetComponent<CarAIControl> ().enabled = false;
			UserCar.GetComponent<CarUserControl> ().enabled = false;

			movingAI0.GetComponent<CarAIControl> ().enabled = false;
			movingAI1.GetComponent<CarAIControl> ().enabled = false;
			movingAI2.GetComponent<CarAIControl> ().enabled = false;
			movingAI3.GetComponent<CarAIControl> ().enabled = false;

			movingAIStart0 = new KeyValuePair<Vector3, Quaternion> (movingAI0.transform.position, movingAI0.transform.rotation);
			movingAIStart1 = new KeyValuePair<Vector3, Quaternion> (movingAI1.transform.position, movingAI1.transform.rotation);
			movingAIStart2 = new KeyValuePair<Vector3, Quaternion> (movingAI2.transform.position, movingAI2.transform.rotation);
			movingAIStart3 = new KeyValuePair<Vector3, Quaternion> (movingAI3.transform.position, movingAI3.transform.rotation);

			spawnController.enterScenario ();

			/*foreach(GameObject nonMovingAICar in spawnController.initialSpawnedObjects.Values) {
				nonMovingAICar.GetComponent<CarAIControl> ().enabled = false;
				nonMovingAICar.GetComponent<CarAIControl> ().Circuit = movingAI0.GetComponent<CarAIControl> ().Circuit;
			}*/

			resetScenario ();
			ChangeState(States.ScenarioBriefing);

			cameraFade.StartAlphaFade (Color.black, true, 3f, () => {
				audioController.playAudio (3);
				StartCoroutine (PostIntersectionScenarioBriefingHUDChange ());
			});
		}
Example #8
0
        public override void TriggerCb(uint id)
        {
            switch (id)
            {
            case 0:
                if (GetState().Equals(States.UserDriveRoute))
                {
                    ChangeState(States.UserApproachTraffic);
                }
                else if (GetState().Equals(States.AIDriveRoute))
                {
                    ChangeState(States.AIApproachTraffic);
                }
                break;

            case 1:             //increase fog
                if (GetState().Equals(States.UserApproachTraffic) || GetState().Equals(States.AIApproachTraffic))
                {
                    RenderSettings.fogDensity      = 0.5f;
                    hudController.model.centerText = "Go straight";
                }
                break;

            case 2:
                if (GetState().Equals(States.UserApproachTraffic))
                {
                    ChangeState(States.UserWarnCollision);
                }
                else if (GetState().Equals(States.AIApproachTraffic))
                {
                    ChangeState(States.AIWarnCollision);
                }
                break;

            case 3:
                if (GetState().Equals(States.UserDriveRoute) || GetState().Equals(States.AIDriveRoute))
                {
                    hudController.Clear();
                    hudController.model.centerText = "Turn right";

                    hudController.FlashImage(Resources.Load(VRAVEStrings.Right_Turn, typeof(Material)) as Material,
                                             0.5f, 0.5f, 0.75f, 5, hudAsyncController);
                }
                break;

            case 4:
                //Debug.Log ("CollisionTrigger triggered");
                if (GetState().Equals(States.UserWarnCollision))
                {
                    //Debug.Log ("Switching to UserStopped state");
                    ChangeState(States.UserStopped);
                }
                else if (GetState().Equals(States.AIWarnCollision))
                {
                    ChangeState(States.AIStopped);
                }
                break;

            case 5:
                if (GetState().Equals(States.UserDriveRoute) || GetState().Equals(States.AIDriveRoute))
                {
                    hudController.model.centerText = "Proceed through intersection";
                }
                break;

            case 6:
                if (GetState().Equals(States.UserApproachTraffic) || GetState().Equals(States.AIApproachTraffic))
                {
                    hudController.Clear();
                    hudController.model.centerText = "Turn left";
                    hudController.FlashImage(Resources.Load(VRAVEStrings.Left_Turn, typeof(Material)) as Material,
                                             0.5f, 0.5f, 0.75f, 5, hudAsyncController);
                }
                break;

            case 7:
                if (GetState().Equals(States.UserStopped))
                {
                    //audioController.playAudio (2);
                }
                else if (GetState().Equals(States.AIStopped))
                {
                    audioController.playAudio(4);
                }
                break;

            default:
                break;
            }
        }
		void Awake ()
		{
			Initialize<States> ();
		
			carController = UserCar.GetComponent<CarController> ();
			carController.MaxSpeed = 15f;
			carAI = UserCar.GetComponent<CarAIControl> ();
			sensitiveSensorResponseHandler = UserCar.GetComponent<SensitiveSensorResponseHandler> ();
			trashCanSensorResponseHandler = UserCar.GetComponent<TrashcanSensorResponseHandler> ();

			crazyAI = CrazyIntersectionAI.GetComponent<CarAIControl> ();
			crazyCarController = CrazyIntersectionAI.GetComponent<CarController> ();

			hudController = UserCar.GetComponentInChildren<HUDController> ();
			audioController = UserCar.GetComponentInChildren<HUDAudioController> ();
			ambientAudioSource = GameObject.FindWithTag (VRAVEStrings.Ambient_Audio).GetComponent<AudioSource>();
			ambientAudioSource.mute = true;
			hudAsyncController = UserCar.GetComponentInChildren<HUDAsyncController> ();

			mirror = GameObject.FindWithTag (VRAVEStrings.Mirror);
			audioController.audioModel = GameObject.FindObjectOfType<ReactionTimeAudioModel> ();

			// configure HUD models
			hudController.models = new HUDModel[2];
			hudController.durations = new float[2];
			hudController.models[0] = new HUDVRAVE_Default();
			hudController.model = hudController.models[0];

			// configure ASYNC controller
			hudAsyncController.Configure(audioController, hudController);

			unsuspectingCarAI = UnsuspectingAI.GetComponent<CarAIControl> ();

			foreach (GameObject o2 in triggers) {
				o2.SetActive(false);
			}
				
			resetIntersectionScenario ();

			//resetTrashCanScenario();

			//ChangeState (States.TrashcanBriefing);
			ChangeState (States.IntersectionBriefing);
			//ChangeState(States.AIDrivingToTrashcanBriefing);


			cameraFade.StartAlphaFade (Color.black, true, 3f, () => {
				audioController.playAudio (3);
				StartCoroutine (PostIntersectionScenarioBriefingHUDChange());
			});

		}
Example #10
0
        /********************** TRIGGERS *****************************/

        // Extend abstract method "ChangeState(uint id)
        //
        // This is used for reacting to "OnTriggerEnter" events, called by WaypointTrigger scripts
        public override void TriggerCb(uint id)
        {
            switch (id)
            {
            case 0:             // AI intersection Path 1 waypoint 01
                if (GetState().Equals(States.AIDrivingToIntersection))
                {
                    StartCoroutine(ChangeAIPaths(3f, ai_paths [0], carAI, () => {
                        carController.MaxSpeed = 18f;
                    }));
                }
                break;

            case 1:             // Approaching intersection trigger
                if (GetState().Equals(States.AIDrivingToIntersection) || GetState().Equals(States.HumanDrivingToIntersection))
                {
                    ChangeState(States.AdvancingThroughIntersection);
                }
                else
                {
                    hudController.Clear();
                }
                break;

            // In the "intersection" part of the scenario, engage the unsuspecting AI car
            case 2:
                UnsuspectingAI.SetActive(true);
                if (GetState().Equals(States.HumanDrivingToIntersection))
                {
                    audioController.playAudio(7);
                }
                break;

            case 3:             // post collision state change
                UserCar.GetComponent <CarUserControl> ().enabled = false;
                StartCoroutine(PostCollisionStateChange(5f));
                break;

            case 4:             // trash can trigger
                hudController.Clear();

                if (GetState().Equals(States.HumanDrivingToTrashcan))
                {
                    trashCan.GetComponent <TrashCanAnimator> ().trashCanForce = 800;
                }
                else
                {
                    trashCan.GetComponent <TrashCanAnimator> ().trashCanForce = 400;
                    hudController.FlashImage(Resources.Load(VRAVEStrings.Warning_Img, typeof(Material)) as Material,
                                             0.25f, 0.25f, 0.75f, 5, hudAsyncController);
                    hudAsyncController.RepeatAudio(10, 1, 5);
                }

                trashCan.SetActive(true);
                trashCan.GetComponent <TrashCanAnimator> ().roll();
                trashCanSensorResponseHandler.Enable = true;
                StartCoroutine(PostTrashcanStateChange(6f));
                break;

            case 5:             // trash can change AI path
                StartCoroutine(ChangeAIPaths(4f, ai_paths [2], unsuspectingCarAI, () => {
                    unsuspectingCarAI.ReachTargetThreshold = 2f;
                    UnsuspectingAI.GetComponent <CarController> ().MaxSpeed = 30f;
                }));
                break;

            case 6:             // AI car trashcan path 2 waypoint 4
                unsuspectingCarAI.CautiousSpeedFactor = 0.8f;
                break;

            case 7:             // trash can change User path
                StartCoroutine(ChangeAIPaths(4f, ai_paths [4], carAI, () => {
                    carAI.ReachTargetThreshold = 2f;
                    carController.MaxSpeed     = 32f;
                    hudController.Clear();
                }));
                break;

            case 8:
                carAI.CautiousSpeedFactor = 0.8f;
                break;

            case 9:             // stop sign trigger
                                // display stop sign on HUD,
                hudController.model.centerText = VRAVEStrings.Stop_Sign;
                hudController.FlashImage(Resources.Load(VRAVEStrings.Stop_Img, typeof(Material)) as Material,
                                         0.5f, 0.5f, 0.5f, 5, hudAsyncController);
                break;

            case 10:             // right turn trigger
                // display right turn sign on HUD,
                if (GetState().Equals(States.HumanDrivingToTrashcan) || GetState().Equals(States.AIDrivingToTrashcan))
                {
                    hudController.FlashImage(Resources.Load(VRAVEStrings.Right_Turn, typeof(Material)) as Material,
                                             0.5f, 0.5f, 0.75f, 5, hudAsyncController);
                }
                break;
            }
        }