Exemplo n.º 1
0
        /*    void CheckAction<T>(AudioRef audio, Func<T> currentState, T state)
         *   {
         *       bool isPlaying = audio.Value.isPlaying;
         *       while (isPlaying)
         *       {
         *           if (currentState().Equals(state))
         *           {
         *               Debug.Log(currentState());
         *               stepFinished = true;
         *               return;
         *           }
         *           isPlaying = audio.Value.isPlaying;
         *       }
         *   }
         *
         *   IEnumerator CheckAction<T> (Func<T> currentState, T state)
         *   {
         *       if (!stepFinished)
         *       {
         *           Debug.Log(currentState());
         *           yield return new WaitUntil(() => currentState().Equals(state));
         *       }
         *       stepFinished = false;
         *   }
         */

        /// <summary>
        /// Plays the audio of the tutorial step, and shows the tooltip of the corresponding button and additional givin tooltip if there is one.
        /// Waits until does the task mentioned in the tutorial step.
        /// </summary>
        /// <param name="audio">The audio to play for the tutorial step</param>
        /// <param name="button">The button that is required for the tutorial step, of which its tooltip should show</param>
        /// <param name="tooltip">Additional tooltip object that should show if needed for the tutorial step, null if only one tooltip is needed.</param>
        /// <param name="controller">If controller is -1 then left only, 0 then both, 1 then right controller only</param>
        /// <returns></returns>
        IEnumerator TutorialStep(AudioSource audio, VRTK_ControllerTooltips.TooltipButtons button, VRTK_ObjectTooltip tooltip, int controller)
        {
            audio.Play();

            //change tooltip colors to the color during tutorial step
            if (controller <= 0)
            {
                ChangeTooltipColorDuringTutorialStep(leftToggling, leftToggling.ChangeButtonToTooltip(button));
                leftTooltips.ToggleTips(true, button);
            }
            else if (controller >= 0)
            {
                if (tooltip != null)
                {
                    ChangeTooltipColorDuringTutorialStep(rightToggling, tooltip);
                    rightTooltips.ToggleTips(true, rightToggling.ChangeTooltipToButton(tooltip));
                }
                ChangeTooltipColorDuringTutorialStep(rightToggling, rightToggling.ChangeButtonToTooltip(button));
                rightTooltips.ToggleTips(true, button);
            }
            //CheckAction(audio, currentState, state);
            yield return(new WaitForSecondsRealtime(audio.clip.length));

            //yield return StartCoroutine(CheckAction(currentState, state));

            yield return(new WaitUntil(() => stepFinished)); //wait until step is finished before continuing tutorial

            //change tooltip colors once step is finished
            if (controller <= 0)
            {
                ChangeTooltipColorAfterTutorialStep(leftToggling, leftToggling.ChangeButtonToTooltip(button));
                leftTooltips.ToggleTips(false, button);
            }
            else if (controller >= 0)
            {
                if (tooltip != null)
                {
                    ChangeTooltipColorAfterTutorialStep(rightToggling, tooltip);
                    rightTooltips.ToggleTips(false, rightToggling.ChangeTooltipToButton(tooltip));
                }
                ChangeTooltipColorAfterTutorialStep(rightToggling, rightToggling.ChangeButtonToTooltip(button));
                rightTooltips.ToggleTips(false, button);
            }

            //set it back to false for the next step
            stepFinished = false;
        }
        /// <summary>
        /// Initiates each step of the tutorial sequentially, waiting for the previous step to finish before starting the next
        /// </summary>
        /// <returns></returns>
        IEnumerator TutorialCoroutine()
        {
            //dunno why, but this is needed for the tooltips to be pointed to the right places for the right controller
            rightController.transform.GetChild(0).gameObject.SetActive(false);
            yield return(new WaitForSecondsRealtime(1));

            rightController.transform.GetChild(0).gameObject.SetActive(true);

            yield return(new WaitForSecondsRealtime(seconds));

            currentTutorialState = TutorialState.INTRO;
            introAudio.Play();
            instruction.text = "Welcome to the Immersive Semi-Autonomous Aerial Command System, also known as ISAACS. ISAACS is an open-source drone command platform, designed for immersive interfaces such as the Oculus Rift. This tutorial will show you how to start working with the interface and use it as an intuitive and seamless extension of  your drone supervision capabilities.";
            yield return(new WaitForSecondsRealtime(introAudio.clip.length));

            envAudio.Play();
            instruction.text = "On the table in front of you,  you can see a height map and scan of the environment that the drone will be flying in. This environment can be anywhere in the world and enables an operator to have a sense of presence for where the drone is.";
            yield return(new WaitForSecondsRealtime(envAudio.clip.length));

            currentTutorialState = TutorialState.MOVINGMAP;
            instruction.text     = "Use your left joystick to change the location of the map.";
            yield return(StartCoroutine(TutorialStep(mapLocationAudio, VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, null, -1)));

            currentTutorialState = TutorialState.ROTATINGMAP;
            instruction.text     = "Use your right joystick to rotate the map.";
            yield return(StartCoroutine(TutorialStep(mapRotationAudio, VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, null, 1)));

            currentTutorialState = TutorialState.SCALINGMAP;
            instruction.text     = "Grab both of your grip triggers at the same time and pull your hands outward or push them together to change scale of entire map.";
            yield return(StartCoroutine(TutorialStep(MapScaleAudio, VRTK_ControllerTooltips.TooltipButtons.GripTooltip, null, 0)));

            currentTutorialState = TutorialState.PRIMARYPLACEMENT;
            instruction.text     = "“In front of your right controller you should be able to see a white sphere. This is called the placepoint. Press down the index trigger to create a waypoint at the placepoint location. You can drag this waypoint around as long as the index trigger is held. Release the index trigger to finalize the waypoint location.";
            yield return(StartCoroutine(TutorialStep(primaryPlacementAudio, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, null, 1)));

            currentTutorialState = TutorialState.GRABZONE;
            instruction.text     = "At the end of your right controller surrounding your placepoint is a blue sphere called the grab zone. When you move the sphere to collide with a waypoint, the waypoint will highlight to show that it is possible to move it. To move a highlighted waypoint, simply hold down your index trigger and move the controller - the waypoint will follow.";
            yield return(StartCoroutine(TutorialStep(grabZoneAudio, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, null, 1)));

            currentTutorialState = TutorialState.INTERMEDIATEPLACEMENT;
            instruction.text     = "The grab zone can also be used to place intermediate waypoints. If you move your grab zone such that it is colliding with a line segment in the waypoint path, it will indicate that you wish to place an intermediate waypoint. If you attempt to place a waypoint using your index trigger while highlighting a path segment, the new waypoint will be placed between the existing waypoints at either end of that path segment.";
            yield return(StartCoroutine(TutorialStep(intermediatePlacementAudio, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, null, 1)));

            currentTutorialState = TutorialState.SELECTIONPOINTER;
            instruction.text     = "“Holding down grip trigger without a waypoint or line highlighted will cause our selection pointer to appear. This pointer will help you select buttons, locations and objects that are far away from you.";
            yield return(StartCoroutine(TutorialStep(selectionPointerAudio, VRTK_ControllerTooltips.TooltipButtons.GripTooltip, null, 1)));

            currentTutorialState = TutorialState.SECONDARYPLACEMENT;
            instruction.text     = "The selection pointer will enable you to use the secondary waypoint placement method. Hold down your grip trigger and point at the terrain, then press the index trigger to create a ground point. Tilt controller to finalize the waypoint height and click the index trigger again to set the waypoint.";
            yield return(StartCoroutine(TutorialStep(secondaryPlacementAudio, VRTK_ControllerTooltips.TooltipButtons.GripTooltip, rightToggling.ChangeButtonToTooltip(VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip), 1)));

            currentTutorialState = TutorialState.UNDOANDDELETE;
            instruction.text     = "Pressing the B button on your right controller will delete the last waypoint that you placed. To delete particular waypoint, highlight it by putting it in your grab zone and then hit the B button.";
            yield return(StartCoroutine(TutorialStep(undoAndDeleteAudio, VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, null, 1)));

            currentTutorialState = TutorialState.DONE;

            tutorialDoneAudio.Play();
            instruction.text = "Thank you for completing the tutorial.";
            yield return(new WaitForSecondsRealtime(tutorialDoneAudio.clip.length));

            removeOrExploreAudio.Play();
            instruction.text = "You may remove your headset or continue to experiment in the interface.";
        }