Example #1
0
 public void UserWarnCollision_Enter()
 {
     hudController.model.centerText          = "Go straight";
     hudController.model.leftBackingMaterial = Resources.Load(VRAVEStrings.Warning_Img, typeof(Material)) as Material;
     hudController.model.isLeftImageEnabled  = true;
     hudAsyncController.RepeatAudio(5, 1, 3);
 }
Example #2
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;
            }
        }