예제 #1
0
        private static string RelativeValueForInstruction(InstructionSave instruction, CustomVariable customVariable, IElement element)
        {
            if (!string.IsNullOrEmpty(customVariable.SourceObject))
            {
                string relativeMember = InstructionManager.GetRelativeForAbsolute(customVariable.SourceObjectProperty);

                return(relativeMember);
            }
            else
            {
                string relativeMember = null;

                if (element is EntitySave)
                {
                    relativeMember = InstructionManager.GetRelativeForAbsolute(instruction.Member);
                }
                return(relativeMember);
            }
        }
    /// <summary>
    /// Coroutine for the welcome text.
    /// Implement your welcome loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator WelcomeLoop()
    {
        // First flag that we are in the welcome routine
        welcomeDone = false;
        inWelcome   = true;

        //
        HudManager.DisplayText("Look to the top right.");
        InstructionManager.DisplayText("This is the welcome. Here you can write a welcome for your subject! \n Press the trigger button to continue...");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        //
        HudManager.ClearText();
        InstructionManager.DisplayText("It's awesome! \n Press the trigger button to continue...");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        // Now that you are done, set the flag to indicate we are done.
        welcomeDone = true;
    }
        public static void RecordInstructions(InstructionList listToRecordTo, double timeToExecute,
                                              List <string> membersToIgnore, Text textToRecord)
        {
            foreach (string member in EditorData.CurrentTextMembersWatching)
            {
                if (membersToIgnore.Contains(member) == false)
                {
                    Type memberType = InstructionManager.GetTypeForMember(mTextType, member);

                    Type genericType = typeof(Instruction <,>).MakeGenericType(
                        mTextType, memberType);
                    object value = FlatRedBall.Instructions.Reflection.LateBinder <Text> .Instance[textToRecord, member];

                    Instruction instruction = Activator.CreateInstance(genericType,
                                                                       textToRecord, member, value, timeToExecute) as Instruction;

                    listToRecordTo.Add(instruction);
                }
            }
        }
예제 #4
0
        private bool ApplyDesiredDirectionToMovement(Direction desiredDirection, TileShapeCollection collision,
                                                     PositionedObjectList <Character> characters)
        {
            bool movedNewDirection = false;

            if (isMovingToTile == false && desiredDirection != Direction.None)
            {
                float desiredX = this.X;
                float desiredY = this.Y;
                bool  isBlocked;
                MoveInDirection(desiredDirection, ref desiredX, ref desiredY);
                this.ForwardCollision.X = desiredX;
                this.ForwardCollision.Y = desiredY;

                isBlocked = GetIfIsBlocked(collision, characters);

                if (isBlocked)
                {
                    // move the collision back so it occupies the character's tile
                    this.ForwardCollision.Position = this.Position;
                }
                else
                {
                    float timeToTake = tileSize / MovementSpeed;

                    InstructionManager.MoveToAccurate(this, desiredX, desiredY, this.Z, timeToTake);
                    isMovingToTile = true;

                    this.Call(() =>
                    {
                        this.isMovingToTile        = false;
                        BackwardCollision.Position = this.Position;
                        UpdateActionCollision();
                    }).After(timeToTake);

                    movedNewDirection = true;
                }
            }

            return(movedNewDirection);
        }
    /// <summary>
    /// Coroutine for the experiment instructions.
    /// Implement your instructions loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator InstructionsLoop()
    {
        // First flag that we are in the instructions routine
        instructionsDone = false;
        inInstructions   = true;

        //Instructions
        if (sessionNumber == 1) // first session
        {
            InstructionManager.DisplayText("Alright, the sphere targets should have spawned for you." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("In the 1st session, you will need to reach to the spheres using your index finger." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("If you are ready, let's start training!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }
        else if (sessionNumber == 2)                       // second session
        {
            InstructionManager.DisplayText("You've finished the 1st session, well done. Let's start the second session" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("The sphere targets have been replaced by bottle targets and a bottle has been placed in your hand." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("In the 2nd session, you will need to match bothe the target locations and orientations ." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("If you are ready, let's start training!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }



        // Now that you are done, set the flag to indicate we are done.
        instructionsDone = true;
    }
예제 #6
0
 protected virtual void UnpauseThisScreen()
 {
     InstructionManager.UnpauseEngine();
     this.IsPaused = false;
 }
예제 #7
0
        public void StartAsyncLoad(string screenType, Action afterLoaded = null)
        {
            if (AsyncLoadingState == AsyncLoadingState.LoadingScreen)
            {
#if DEBUG
                throw new InvalidOperationException("This Screen is already loading a Screen of type " + asyncScreenTypeToLoad + ".  This is a DEBUG-only exception");
#endif
            }
            else if (AsyncLoadingState == AsyncLoadingState.Done)
            {
#if DEBUG
                throw new InvalidOperationException("This Screen has already loaded a Screen of type " + asyncScreenTypeToLoad + ".  This is a DEBUG-only exception");
#endif
            }
            else
            {
                AsyncLoadingState     = AsyncLoadingState.LoadingScreen;
                asyncScreenTypeToLoad = ScreenManager.MainAssembly.GetType(screenType);

                if (asyncScreenTypeToLoad == null)
                {
                    throw new Exception("Could not find the type " + screenType);
                }

                                #if REQUIRES_PRIMARY_THREAD_LOADING
                // We're going to do the "async" loading on the primary thread
                // since we can't actually do it async.
                PerformAsyncLoad();
                if (afterLoaded != null)
                {
                    afterLoaded();
                }
                                #else
                mNumberOfThreadsBeforeAsync = FlatRedBallServices.GetNumberOfThreadsToUse();

                FlatRedBallServices.SetNumberOfThreadsToUse(1);

                Action action;

                if (afterLoaded == null)
                {
                    action = (Action)PerformAsyncLoad;
                }
                else
                {
                    action = () =>
                    {
                        PerformAsyncLoad();

                        // We're going to add this to the instruction manager so it executes on the main thread:
                        InstructionManager.AddSafe(new DelegateInstruction(afterLoaded));
                    };
                }



#if WINDOWS_8 || UWP
                System.Threading.Tasks.Task.Run(action);
#else
                ThreadStart threadStart = new ThreadStart(action);
                Thread      thread      = new Thread(threadStart);
                thread.Start();
#endif
                                #endif
            }
        }
예제 #8
0
 public virtual void UnpauseThisScreen()
 {
     InstructionManager.UnpauseEngine();
     Math.Collision.CollisionManager.Self.IsPausedByScreen = false;
     this.IsPaused = false;
 }
예제 #9
0
 void Start()
 {
     sMan = GameObject.FindObjectOfType<SignpostManager> ();
     iMan = GameObject.FindObjectOfType<InstructionManager> ();
     spriteRenderer = transform.parent.gameObject.GetComponent<SpriteRenderer> ();
 }
예제 #10
0
    public bool relativeX, relativeY, relativeZ;    // Apply adjustment over these axes


    private void Start()
    {
        this.simManComp   = simManager.GetComponent <SimManager>();
        this.instrManComp = instrManager.GetComponent <InstructionManager>();
    }
예제 #11
0
        private static void GenerateInterpolateForIndividualStateNoSource(ref ICodeBlock codeBlock, IElement element, ref ICodeBlock otherBlock, InstructionSave instruction, CustomVariable customVariable, string valueAsString, string timeCastString)
        {
            string velocityMember =
                FlatRedBall.Instructions.InstructionManager.GetVelocityForState(instruction.Member);

            // If the velocityMember exists, we need to make sure it's actually exposable
            if (!ExposedVariableManager.GetExposableMembersFor(element, false).Any(item => item.Member == velocityMember))
            {
                velocityMember = null;
            }

            if (velocityMember == null && customVariable.HasAccompanyingVelocityProperty)
            {
                velocityMember = customVariable.Name + "Velocity";
            }

            if (!string.IsNullOrEmpty(velocityMember))
            {
                string relativeVelocity = InstructionManager.GetRelativeForAbsolute(velocityMember);

                string leftHandPlusEquals = null;

                if (!string.IsNullOrEmpty(relativeVelocity))
                {
                    codeBlock = codeBlock
                                .If("this.Parent != null");

                    otherBlock = otherBlock
                                 .If("this.Parent != null");

                    string instructionMemberRelative = InstructionManager.GetRelativeForAbsolute(instruction.Member);

                    leftHandPlusEquals = relativeVelocity + " = ";

                    codeBlock.Line(leftHandPlusEquals + "(" + valueAsString + " - " +
                                   instructionMemberRelative + ") / " + timeCastString + "secondsToTake;");

                    otherBlock.Line(leftHandPlusEquals + " 0;");

                    codeBlock = codeBlock
                                .End()
                                .Else();

                    otherBlock = otherBlock
                                 .End()
                                 .Else();
                }
                leftHandPlusEquals = velocityMember + " = ";

                codeBlock.Line(leftHandPlusEquals + "(" + valueAsString + " - " + instruction.Member +
                               ") / " + timeCastString + "secondsToTake;");

                otherBlock.Line(leftHandPlusEquals + " 0;");

                if (!string.IsNullOrEmpty(relativeVelocity))
                {
                    codeBlock  = codeBlock.End();
                    otherBlock = otherBlock.End();
                }
            }
        }
    private void FixedUpdate()
    {
        //
        // Tasks performed determinalistically throughout the experiment
        // E.g. data gathering.
        //
        switch (experimentState)
        {
        case ExperimentState.PerformingTask:
            //
            // Gather data while experiment is in progress
            //
            string displayData = "Training time elapsed: " + taskTime.ToString() + " seconds.";
            // Read from all user sensors
            foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
            {
                if (sensor.GetSensorType().Equals(SensorType.EMGWiFi))
                {
                    displayData += "\n" + sensor.GetSensorType().ToString() + " Command:";
                    float[] sensorData = sensor.GetAllProcessedData();
                    foreach (float element in sensorData)
                    {
                        displayData += "\n" + element.ToString();
                    }
                }
                else if (sensor.GetSensorType().Equals(SensorType.VirtualEncoder))
                {
                    displayData += "\n" + sensor.GetSensorType().ToString() + " Command:";
                    float[] sensorData = sensor.GetAllProcessedData();
                    foreach (float element in sensorData)
                    {
                        displayData += "\n" + element.ToString();
                    }
                }
            }


            InstructionManager.DisplayText(displayData);
            //hudManager.DisplayText(logData);

            //
            // Append data to lists
            //
            taskTime += Time.fixedDeltaTime;

            //
            // Raycast debug
            //
            // Vector3 shoulderToElbow = elbowGO.transform.position - residualLimbGO.transform.position;
            // Vector3 shoulderToHand = handGO.transform.position - (residualLimbGO.transform.position - 0.25f * shoulderToElbow);
            // Debug.DrawRay(residualLimbGO.transform.position - 0.2f * shoulderToElbow, shoulderToHand, Color.magenta);

            //
            // Save log and reset flags when successfully compeleted task
            //
            if (IsTaskDone())
            {
                //
                // Perform data management, such as appending data to lists for analysis
                //

                //
                // Save logger for current experiment and change to data analysis
                //
                //ExperimentSystem.GetActiveLogger(1).CloseLog();

                //
                // Clear data management buffers
                //
                experimentState = ExperimentState.AnalizingResults;
                break;
            }

            // Check if requested to end training
            UpdateEnd();

            break;

        default:
            break;
        }
    }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        switch (experimentState)
        {
        /*
         *************************************************
         *  HelloWorld
         *************************************************
         */
        // Welcome subject to the virtual world.
        case ExperimentState.Welcome:
            if (WaitFlag)
            {
                if (debug)
                {
                    TeleportToStartPosition();
                }
                HudManager.ClearText();
                experimentState = ExperimentState.Initialising;
            }
            else
            {
                HudManager.DisplayText("Welcome!");
                InstructionManager.DisplayText("Hello world!");
            }
            break;

        /*
         *************************************************
         *  InitializingApplication
         *************************************************
         */
        // Perform initialization functions before starting experiment.
        case ExperimentState.Initialising:
            //
            // Perform experiment initialization procedures
            //

            //
            // Initialize data logs
            //

            //
            // Go to training
            //
            experimentState = ExperimentState.Training;
            break;

        /*
         *************************************************
         *  Practice
         *************************************************
         */
        // Perform initialization functions before starting experiment.
        case ExperimentState.Training:
            //
            // Guide subject through training
            //

            //
            // Go to instructions
            //
            experimentState = ExperimentState.Instructions;
            break;

        /*
         *************************************************
         *  GivingInstructions
         *************************************************
         */
        case ExperimentState.Instructions:
            // Skip instructions when repeating sessions
            if (SkipInstructions)
            {
                HudManager.DisplayText("Move to start", 2.0f);
                // Turn targets clear
                experimentState = ExperimentState.WaitingForStart;
                break;
            }

            //
            // Give instructions
            //

            //
            // Go to waiting for start
            //
            HudManager.DisplayText("Move to start", 2.0f);
            // Turn targets clear
            experimentState = ExperimentState.WaitingForStart;

            break;

        /*
         *************************************************
         *  WaitingForStart
         *************************************************
         */
        case ExperimentState.WaitingForStart:
            // Show status to subject
            infoText = GetInfoText();
            InstructionManager.DisplayText(infoText);

            // Check if pause requested
            UpdatePause();
            switch (waitState)
            {
            // Waiting for subject to get to start position.
            case WaitState.Waiting:
                if (IsReadyToStart())
                {
                    startEnable = true;
                    // Select target
                    gridManager.SelectBall(iterationNumber - 1);
                    waitState = WaitState.Countdown;
                }
                break;

            // HUD countdown for reaching action.
            case WaitState.Countdown:
                // If all is good and haven't started counting, start.
                if (startEnable && !counting && !CountdownDone)
                {
                    // Manage countdown
                    HudManager.ClearText();
                    StopHUDCountDown();
                    counting = true;
                    HUDCountDown(3);
                }
                // If all is good and the countdownDone flag is raised, switch to reaching.
                else if (CountdownDone)
                {
                    // Reset flags
                    startEnable   = false;
                    counting      = false;
                    countdownDone = false;
                    // Continue
                    experimentState = ExperimentState.PerformingTask;
                    waitState       = WaitState.Waiting;
                    break;
                }
                // If hand goes out of target reset countdown and wait for position
                else if (!IsReadyToStart() && !CountdownDone)
                {
                    StopHUDCountDown();
                    startEnable   = false;
                    counting      = false;
                    countdownDone = false;
                    // Clear ball
                    gridManager.ResetBallSelection();
                    // Indicate to move back
                    HudManager.DisplayText("Move to start", 2.0f);
                    waitState = WaitState.Waiting;
                    break;
                }
                break;

            default:
                break;
            }
            break;

        /*
         *************************************************
         *  PerformingTask
         *************************************************
         */
        case ExperimentState.PerformingTask:
            // Task performance is handled deterministically in FixedUpdate.
            break;

        /*
         *************************************************
         *  AnalizingResults
         *************************************************
         */
        case ExperimentState.AnalizingResults:
            // Allow 3 seconds after task end to do calculations
            SetWaitFlag(3.0f);

            //
            // Data analysis and calculations
            //

            //
            // System update
            //

            //
            // Data logging
            //

            //
            // Flow managment
            //
            // Rest for some time when required
            if (IsRestTime())
            {
                SetWaitFlag(RestTime);
                experimentState = ExperimentState.Resting;
            }
            // Check whether the new session condition is met
            else if (IsEndOfSession())
            {
                experimentState = ExperimentState.InitializingNext;
            }
            // Check whether the experiment end condition is met
            else if (IsEndOfExperiment())
            {
                experimentState = ExperimentState.End;
            }
            else
            {
                experimentState = ExperimentState.UpdatingApplication;
            }
            break;

        /*
         *************************************************
         *  UpdatingApplication
         *************************************************
         */
        case ExperimentState.UpdatingApplication:
            if (WaitFlag)
            {
                //
                // Update iterations and flow control
                //
                iterationNumber++;
                completedIterations++;

                //
                // Update log requirements
                //

                //
                //
                // Go to start of next iteration
                experimentState = ExperimentState.WaitingForStart;
            }
            break;

        /*
         *************************************************
         *  InitializingNext
         *************************************************
         */
        case ExperimentState.InitializingNext:
            //
            // Perform session closure procedures
            //

            //
            // Initialize new session variables and flow control
            //
            iterationNumber = 1;
            sessionNumber++;
            skipInstructions = true;

            //
            // Initialize data logging
            //
            ExperimentSystem.GetActiveLogger(1).AddNewLogFile(sessionNumber, iterationNumber, "Data format");

            experimentState = ExperimentState.Initialising;     // Initialize next session
            break;

        /*
         *************************************************
         *  Resting
         *************************************************
         */
        case ExperimentState.Resting:
            //
            // Check for session change or end request from experimenter
            //
            if (UpdateNext())
            {
                ConfigureNextSession();
                break;
            }
            else if (UpdateEnd())
            {
                EndExperiment();
                break;
            }
            //
            // Restart after flag is set by wait coroutine
            //
            if (WaitFlag)
            {
                HudManager.DisplayText("Get ready to restart!", 3.0f);
                SetWaitFlag(5.0f);
                experimentState = ExperimentState.UpdatingApplication;
                break;
            }
            break;

        /*
         *************************************************
         *  Paused
         *************************************************
         */
        case ExperimentState.Paused:
            //
            // Check for session change or end request from experimenter
            //
            UpdatePause();
            if (UpdateNext())
            {
                ConfigureNextSession();
                break;
            }
            else if (UpdateEnd())
            {
                EndExperiment();
                break;
            }
            break;

        /*
         *************************************************
         *  End
         *************************************************
         */
        case ExperimentState.End:
        //
        // Update log data and close logs.
        //

        //
        // Return to main menu
        //
        default:
            break;
        }

        //
        // Update information displayed on monitor
        //

        //
        // Update information displayed for debugging purposes
        //
        if (debug)
        {
            debugText.text = experimentState.ToString() + "\n";
            if (experimentState == ExperimentState.WaitingForStart)
            {
                debugText.text += waitState.ToString() + "\n";
            }
            float qShoulder = Mathf.Rad2Deg * (upperArmTracker.GetProcessedData(5) + Mathf.PI);  // Offsetting to horizontal position being 0.
            float qElbow    = Mathf.Rad2Deg * (lowerArmTracker.GetProcessedData(5)) - qShoulder; // Offsetting to horizontal position being 0.
            debugText.text += qShoulder.ToString() + "\n";
            debugText.text += qElbow.ToString() + "\n";
        }
    }
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        switch (experimentState)
        {
        /*
         *************************************************
         *  HelloWorld
         *************************************************
         */
        // Welcome subject to the virtual world.
        case ExperimentState.Welcome:
            if (WaitFlag)
            {
                HudManager.ClearText();
                experimentState = ExperimentState.Initialising;
            }
            else
            {
                HudManager.DisplayText("Welcome!");
            }
            break;

        /*
         *************************************************
         *  InitializingApplication
         *************************************************
         */
        // Perform initialization functions before starting experiment.
        case ExperimentState.Initialising:
            //
            // Perform experiment initialization procedures
            //
            // Enable colliders
            AvatarSystem.EnableAvatarColliders();
            // Initialize arm guide
            guideManager.Initialize(startAngleList[angleNumber - 1], endAngleList[angleNumber - 1], movementTimeList[timeNumber - 1]);
            guideManager.GoToStart();

            //
            // Initialize data logs
            //
            motionLogger.AddNewLogFile(startAngleList[angleNumber - 1] + "_" + endAngleList[angleNumber - 1] + "_" + movementTimeList[timeNumber - 1], iterationNumber, motionDataFormat);

            //
            // Go to training
            //
            experimentState = ExperimentState.Training;
            break;

        /*
         *************************************************
         *  Practice
         *************************************************
         */
        // Perform initialization functions before starting experiment.
        case ExperimentState.Training:
            //
            // Guide subject through training
            //

            //
            // Go to instructions
            //
            experimentState = ExperimentState.Instructions;
            break;

        /*
         *************************************************
         *  GivingInstructions
         *************************************************
         */
        case ExperimentState.Instructions:
            HudManager.DisplayText(movementTimeList[timeNumber - 1] + " sec. movement.", 2.0f);
            // Skip instructions when repeating sessions
            if (SkipInstructions)
            {
                //hudManager.DisplayText("Move to guide", 2.0f);
                experimentState = ExperimentState.WaitingForStart;
                break;
            }

            //
            // Give instructions
            //

            //
            // Go to waiting for start
            //
            experimentState = ExperimentState.WaitingForStart;
            break;

        /*
         *************************************************
         *  WaitingForStart
         *************************************************
         */
        case ExperimentState.WaitingForStart:

            // Check if pause requested
            UpdatePause();
            switch (waitState)
            {
            // Waiting for subject to grab the object.
            case WaitState.Waiting:
                if (guideManager.StartGuiding())
                {
                    //StopAllCoroutines();
                    HudManager.ClearText();
                    taskTime = 0.0f;
                    HUDCountDown(3);
                    experimentState = ExperimentState.PerformingTask;
                }
                break;

            default:
                break;
            }
            break;

        /*
         *************************************************
         *  PerformingTask
         *************************************************
         */
        case ExperimentState.PerformingTask:
            // Task performance is handled deterministically in FixedUpdate.
            break;

        /*
         *************************************************
         *  AnalizingResults
         *************************************************
         */
        case ExperimentState.AnalizingResults:
            HudManager.DisplayText("Rest your arm.", 5.0f);
            // Allow 3 seconds after task end to do calculations
            SetWaitFlag(5.0f);

            //
            // Data analysis and calculations
            //

            //
            // Adaptive system update (when available)
            //

            //
            // Data logging and log management
            //
            motionLogger.CloseLog();

            //
            // Flow managment
            //

            // Rest for some time when required
            if (IsRestTime())
            {
                HudManager.ClearText();
                HudManager.DisplayText("Rest your arm.", 2.0f);
                SetWaitFlag(RestTime);
                experimentState = ExperimentState.Resting;
                break;
            }
            else if (IsEndOfExperiment())
            {
                experimentState = ExperimentState.End;
                break;
            }
            // Check whether the new session condition is met
            else if (IsEndOfSession())
            {
                //
                // Update iterations and flow control
                //
                iterationNumber++;
                timeIterations++;
                totalIterations++;
                // Go to next
                experimentState = ExperimentState.InitializingNext;
                break;
            }
            else
            {
                experimentState = ExperimentState.UpdatingApplication;
            }
            break;

        /*
         *************************************************
         *  UpdatingApplication
         *************************************************
         */
        case ExperimentState.UpdatingApplication:
            if (WaitFlag)
            {
                //
                // Update iterations and flow control
                //
                iterationNumber++;
                timeIterations++;
                totalIterations++;

                //
                // Update experiment object
                //
                guideManager.GoToStart();

                //
                // Update log requirements
                //
                motionLogger.AddNewLogFile(startAngleList[angleNumber - 1] + "_" + endAngleList[angleNumber - 1] + "_" + movementTimeList[timeNumber - 1], iterationNumber, motionDataFormat);

                //
                // Go to start of next iteration
                //
                HudManager.DisplayText("Move to guide", 2.0f);
                experimentState = ExperimentState.WaitingForStart;
            }
            break;

        /*
         *************************************************
         *  InitializingNext
         *************************************************
         */
        case ExperimentState.InitializingNext:
            if (WaitFlag)
            {
                //
                // Perform session closure procedures
                //

                //
                // Initialize new session variables and flow control
                //
                iterationNumber = 1;
                sessionNumber++;
                // Still doing the angle repetitions for the same time
                if (timeIterations < timeIterationLimit)
                {
                    angleNumber++;
                }
                // Done all the angle repetitions for the given time, reset and go to next time
                else
                {
                    angleNumber    = 1;
                    timeIterations = 1;
                    timeNumber++;
                }

                //
                // Update experiment object
                //
                guideManager.GoToStart();
                //
                // Initialize data logging
                //

                experimentState = ExperimentState.Initialising;     // Initialize next session
            }
            break;

        /*
         *************************************************
         *  Resting
         *************************************************
         */
        case ExperimentState.Resting:
            //
            // Check for session change or end request from experimenter
            //
            if (UpdateNext())
            {
                ConfigureNextSession();
                break;
            }
            else if (UpdateEnd())
            {
                EndExperiment();
                break;
            }
            //
            // Restart after flag is set by wait coroutine
            //
            if (WaitFlag)
            {
                if (IsEndOfExperiment())
                {
                    experimentState = ExperimentState.End;
                    break;
                }
                // Check whether the new session condition is met
                else if (IsEndOfSession())
                {
                    //
                    // Update iterations and flow control
                    //
                    iterationNumber++;
                    timeIterations++;
                    totalIterations++;
                    // Go to next
                    experimentState = ExperimentState.InitializingNext;
                    break;
                }
                else
                {
                    HudManager.DisplayText("Get ready!", 3.0f);
                    SetWaitFlag(3.0f);
                    experimentState = ExperimentState.UpdatingApplication;
                }
                break;
            }
            break;

        /*
         *************************************************
         *  Paused
         *************************************************
         */
        case ExperimentState.Paused:
            //
            // Check for session change or end request from experimenter
            //
            UpdatePause();
            if (UpdateNext())
            {
                ConfigureNextSession();
                break;
            }
            else if (UpdateEnd())
            {
                EndExperiment();
                break;
            }
            break;

        /*
         *************************************************
         *  End
         *************************************************
         */
        case ExperimentState.End:
            //
            // Update log data and close logs.
            //

            HudManager.DisplayText("Experiment end, thanks!", 5.0f);
            //
            // Return to main menu
            //
            break;

        default:
            break;
        }

        //
        // Update information displayed on monitor
        //
        string experimentInfoText = "Experiment info: \n";

        experimentInfoText += "Iteration: " + iterationNumber + "/" + iterationsPerAngle + ".\n";
        experimentInfoText += "Session: " + sessionNumber + "/" + startAngleList.Count * movementTimeList.Count + ".\n";
        InstructionManager.DisplayText(experimentInfoText);

        //
        // Update information displayed for debugging purposes
        //
        if (debug)
        {
            string debugText = "Debug info: \n";
            debugText += experimentState.ToString() + ".\n";
            if (experimentState == ExperimentState.WaitingForStart)
            {
                debugText += waitState.ToString() + ".\n";
            }
            debugText += "Angle number:" + angleNumber + ".\n";
            debugText += "Time iterations:" + timeIterations + ".\n";
            InstructionManager.DisplayText(debugText + "\n" + experimentInfoText);
        }
    }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     npcAdapter = GetComponent<NpcAdapter>();
     //npcController = GetComponent<NpcController>();
     npcController = GetComponent<NPC_BoxMovementController>();
     zone = GetComponentInChildren<NpcInteractionZone>();
     dManager = FindObjectOfType<DialogueUIManager>();
     iManager = FindObjectOfType<InstructionManager>();
     player = FindObjectOfType<PlayerAdapter>().gameObject;
 }
 // Use this for initialization
 void Start()
 {
     spriteRenderer = gameObject.GetComponentInParent<SpriteRenderer>();
     iManager = GameObject.FindObjectOfType<InstructionManager>();
 }
예제 #17
0
    /// <summary>
    /// Coroutine for the experiment instructions.
    /// Implement your instructions loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator InstructionsLoop()
    {
        // First flag that we are in the instructions routine
        instructionsDone = false;
        inInstructions   = true;

        //
        InstructionManager.DisplayText("Alright " + SaveSystem.ActiveUser.name + ", let me explain what we are doing today." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Today you are doing the " + AvatarSystem.AvatarType + " version of the experiment, which means..." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        // Type instructions
        if (experimentType == ExperimentType.TypeOne)
        {
            InstructionManager.DisplayText("You'll be reaching for a bunch of floating colorful spheres!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You should see 9 spheres arranged in a 3x3 matrix. They should all be reachable, if not, please let me know." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You are not allowed to step! So if they are too far away, I'll adjust them." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You'll have to touch each sphere a total of " + iterationsPerTarget + " times." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("The order will be random; however, you'll be shown which one to touch before each reach." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You don't need to do anything special, just reach as you normally would, comfortably." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }
        else if (experimentType == ExperimentType.TypeTwo)
        {
            InstructionManager.DisplayText("You'll be reaching for a single floating colorful sphere while using a smart prosthesis!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You'll have to reach for the sphere a total of " + iterationsPerTarget + " times." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("At the beginning it might be a bit difficult to reach and you'll need to compensate with your upper body." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You should not step though!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("However, after each reach, the prosthesis will learn from your movement and adjust itself." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("After a few reachs it should be a piece of cake." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }
        else
        {
            throw new System.Exception("The experiment type is not valid. Place: Instructions");
        }

        InstructionManager.DisplayText("There is no break in this experiment, but if you feel tired or any discomfort let me know immediately and we'll take a break or stop." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Remember you are in VR, so the objects you see are not actually there. So... Don't lean on them!" + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Also, objects you can't see may be around you, so don't go running around. You'll have a chance to explore at the end. :)" + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("If you are ready, let's start training!" + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        // Now that you are done, set the flag to indicate we are done.
        instructionsDone = true;
    }
예제 #18
0
        private static void GenerateInterpolateForIndividualStateWithSource(ref ICodeBlock codeBlock, IElement element, ref ICodeBlock otherBlock, CustomVariable customVariable, string valueAsString, NamedObjectSave sourceNamedObjectSave, string timeCastString)
        {
            if (customVariable.GetIsVariableState())
            {
                GenerateInterpolateForIndividualStateWithSourceStateVariable(codeBlock, customVariable, element, valueAsString.Replace("\"", ""));
            }
            else
            {
                string velocityMember =
                    FlatRedBall.Instructions.InstructionManager.GetVelocityForState(customVariable.SourceObjectProperty);



                bool generatedVelocity = false;

                if (velocityMember == null &&
                    customVariable.HasAccompanyingVelocityProperty)
                {
                    velocityMember    = customVariable.Name + "Velocity";
                    generatedVelocity = true;
                }
                bool velocityComesFromTunnel = false;

                if (velocityMember == null &&
                    // Only want to go 1 deep.  The reason is if the tunneled variable has a
                    // velocity value, we can use that.  However, if it's tunneled multiple times
                    // into a variable that ultimately has a velocity variable we may not be able to
                    // get to it, so we shouldn't just assume we can add "Velocity" to the variable name.
                    customVariable.HasAccompanyingVelocityConsideringTunneling(element, 1))
                {
                    velocityMember          = customVariable.SourceObjectProperty + "Velocity";
                    generatedVelocity       = true;
                    velocityComesFromTunnel = true;
                }

                if (!string.IsNullOrEmpty(velocityMember))
                {
                    string sourceDot = customVariable.SourceObject + ".";

                    IEnumerable <string> exposableVariables =
                        FlatRedBall.Glue.Reflection.ExposedVariableManager.GetExposableMembersFor(sourceNamedObjectSave).Select(item => item.Member);

                    // We will generate this if the variable is contained in exposable variables,
                    // if the user explicitly said to generate a velocity variable, or if
                    // this is a FRB type. The reason we check if it's a FRB Type is because FRB
                    // types have velocity variables which may not be exposable. We don't want Glue
                    // to mess with temporary values like Velocity, so they are removed from the exposab
                    // variable list:
                    bool shouldGenerate = exposableVariables.Contains(velocityMember) ||
                                          generatedVelocity ||
                                          sourceNamedObjectSave.SourceType == SourceType.FlatRedBallType;


                    if (shouldGenerate)
                    {
                        string relativeVelocity = InstructionManager.GetRelativeForAbsolute(velocityMember);

                        string leftHandPlusEquals = null;

                        if (!string.IsNullOrEmpty(relativeVelocity))
                        {
                            codeBlock = codeBlock
                                        .If(customVariable.SourceObject + ".Parent != null");

                            otherBlock = otherBlock
                                         .If(customVariable.SourceObject + ".Parent != null");

                            string sourceObjectPropertyRelative = InstructionManager.GetRelativeForAbsolute(customVariable.SourceObjectProperty);

                            leftHandPlusEquals = sourceDot + relativeVelocity + " = ";

                            codeBlock.Line(leftHandPlusEquals + "(" + valueAsString + " - " + sourceDot +
                                           sourceObjectPropertyRelative + ") / " + timeCastString +
                                           "secondsToTake;");

                            otherBlock.Line(leftHandPlusEquals + " 0;");

                            codeBlock = codeBlock
                                        .End()
                                        .Else();

                            otherBlock = otherBlock
                                         .End()
                                         .Else();
                        }

                        // If we're using a custom velocity value, we don't want to
                        // use the sourceDot.  We just want to use the velocity value
                        if (generatedVelocity && !velocityComesFromTunnel)
                        {
                            leftHandPlusEquals = velocityMember + " = ";
                        }
                        else
                        {
                            leftHandPlusEquals = sourceDot + velocityMember + " = ";
                        }
                        codeBlock.Line(leftHandPlusEquals + "(" + valueAsString + " - " + sourceDot +
                                       customVariable.SourceObjectProperty + ") / " + timeCastString +
                                       "secondsToTake;");

                        otherBlock.Line(leftHandPlusEquals + " 0;");

                        if (!string.IsNullOrEmpty(relativeVelocity))
                        {
                            codeBlock  = codeBlock.End();
                            otherBlock = otherBlock.End();
                        }
                    }
                }
            }
        }
예제 #19
0
    /// <summary>
    /// Coroutine for the experiment training.
    /// Implement your training loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator TrainingLoop()
    {
        // First flag that we are in the training routine
        trainingDone = false;
        inTraining   = true;

        // Only run the training loop when requested, for instance some session may require different session.
        if (trainingPerSession[sessionNumber - 1] == 1)
        {
            // Hud intro
            InstructionManager.DisplayText("Alright " + SaveSystem.ActiveUser.name + ", let's show you the ropes." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Let me introduce you to your assistant, the Heads Up Display (HUD)." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Say hi!");
            HudManager.DisplayText("Hi! I'm HUD!" + "\n (Press trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.DisplayText("I'm here to help!" + "\n (Press trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.DisplayText("Look at the screen.", 3);
            InstructionManager.DisplayText("Let's start training then!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            // Type instructions
            if (experimentType == ExperimentType.TypeOne)
            {
                InstructionManager.DisplayText("First, we'll show you the start position." + "\n\n (Press the trigger)");
                yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
            }
            else if (experimentType == ExperimentType.TypeTwo)
            {
                InstructionManager.DisplayText("First, we'll show how to use the prosthesis." + "\n\n (Press the trigger)");
                yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

                InstructionManager.DisplayText("When the prosthesis is not enabled, the HUD centre will turn yellow." + "\n\n (Press the trigger)");
                HudManager.centreColour = HUDManager.HUDCentreColour.Yellow;
                HudManager.DisplayText("\n <- Like so.");
                yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

                HudManager.ClearText();
                InstructionManager.DisplayText("To activate the prosthesis, press the circle button.");
                yield return(new WaitUntil(() => elbowManager.IsEnabled)); // And wait for the subject to enable it.

                HudManager.DisplayText("\n <- I'll be transparent!");
                InstructionManager.DisplayText("Try moving it around." + "\n\n (Press the trigger)");
                yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

                InstructionManager.DisplayText("Nice! Let's deactivate the prosthesis for now." + "\n\n (Press the trigger)");
                yield return(new WaitUntil(() => !elbowManager.IsEnabled)); // And wait for the subject to disable it.

                InstructionManager.DisplayText("Now, we'll show you the start position." + "\n\n (Press the trigger)");
                yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
            }

            //
            // Start position
            InstructionManager.DisplayText("Your upper arm should be relaxed pointing downards while your elbow should be bent 90 degrees." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Like so:" + "\n Try it.");
            startPosPhoto.SetActive(true);
            yield return(new WaitUntil(() => IsReadyToStart()));

            startPosPhoto.SetActive(false);
            HudManager.ClearText();
            //
            // HUD Colours
            InstructionManager.DisplayText("The colour of the HUD will tell you what you need to do." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Red for adjusting your start position." + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm red!");
            HudManager.colour = HUDManager.HUDColour.Red;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Orange for waiting for the countdown." + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm orange!");
            HudManager.colour = HUDManager.HUDColour.Orange;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Blue for reaching for the sphere!" + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm blue!");
            HudManager.colour = HUDManager.HUDColour.Blue;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Green for returning to the start position." + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm green!");
            HudManager.colour = HUDManager.HUDColour.Green;
            //
            // Practice
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Now, let's practice reaching for a target!" + "\n\n (Press the trigger)");
            HudManager.ClearText();
            HudManager.colour = HUDManager.HUDColour.Red;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("The sphere that you need to reach will turn blue." + "\n\n (Press the trigger)");
            gridManager.SelectBall(0);
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You'll have to wait for a three second countdown. Look at the sphere and get ready!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.colour = HUDManager.HUDColour.Orange;
            HUDCountDown(3);
            yield return(new WaitUntil(() => CountdownDone)); // And wait

            InstructionManager.DisplayText("Reach for it!!");
            HudManager.DisplayText("Reach for it!!");
            HudManager.colour = HUDManager.HUDColour.Blue;
            yield return(new WaitUntil(() => IsTaskDone()));

            // Signal the subject that the task is done
            HudManager.colour = HUDManager.HUDColour.Green;
            // Reset flags
            hasReached   = false;
            taskComplete = false;
            HudManager.DisplayText("You can relax now.", 3);
            //
            // End
            InstructionManager.DisplayText("Make sure you hold your position until the HUD turns green before moving back to the start position." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Otherwise, you look ready to go! Good luck!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }

        // Now that you are done, set the flag to indicate we are done.
        trainingDone = true;
    }
    /// <summary>
    /// Coroutine for the welcome text.
    /// Implement your welcome loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator WelcomeLoop()
    {
        // First flag that we are in the welcome routine
        welcomeDone = false;
        inWelcome   = true;
        HudManager.DisplayText("Look to the top right. Instructions will be displayed there.");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        //HudManager.DisplayText("Look to the top right. Instructions will be displayed there.");
        InstructionManager.DisplayText("Hi " + SaveSystem.ActiveUser.name + "! Welcome to the virtual world. \n\n (Press the trigger button to continue...)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Make sure you are standing on top of the green circle. \n\n (Press the trigger button to continue...)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Test audio. \n\n (If you can hear the audio, press the trigger button to continue...)");
        audio.loop   = true;
        audio.volume = 0.4f;
        audio.Play();

        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        audio.loop = false;
        audio.Stop();
        audio.volume = 1.0f;
        //
        // Hud intro
        InstructionManager.DisplayText("Alright " + SaveSystem.ActiveUser.name + ", let me introduce you to your assistant, the Heads Up Display (HUD)." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Look at the HUD around your left eye. It's saying hi!");
        HudManager.DisplayText("Hi! I'm HUD!" + "\n (Press trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        HudManager.DisplayText("I'm here to help!" + "\n (Press trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        HudManager.DisplayText("Look at the screen.", 3);


        //
        // Experiment overall intro
        InstructionManager.DisplayText("Alright " + SaveSystem.ActiveUser.name + ", let me explain what we are doing today." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Today, the experiment will require you to reach to the targets in front of you." + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("You will do 2 sessions, 1st 90 iterations and 2nd 270 iterations " + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("A 60 sec rest occurs every 35 iterations" + "\n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.



        //
        // Generate the targets

        InstructionManager.DisplayText("First, let's set up the experiment targets for you. \n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("Extend your arms naturally forward and the desired joint positions will be shown on the HUD. \n\n (Press the trigger)");
        yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

        InstructionManager.DisplayText("HUD Format: SH - Shoulder, EB - Elbow and in the bracket (current joint angle / the desired one)");

        for (int i = 0; i < shoulderDesiredPos.Length; i++)
        {
            for (int j = 0; j < elbowDesiredPos.Length; j++)
            {
                //yield return new WaitUntil(() => IsAtRightPosition(shoulderDesiredPos[i], elbowDesiredPos[j], 2.0f));


                if (i % 2 == 0)
                {
                    yield return(new WaitUntil(() => IsAtRightPosition(shoulderDesiredPos[i], elbowDesiredPos[j], 2.0f)));
                }
                else
                {
                    yield return(new WaitUntil(() => IsAtRightPosition(shoulderDesiredPos[i], elbowDesiredPos[elbowDesiredPos.Length - 1 - j], 2.0f)));
                }

                GameObject[] hand = GameObject.FindGameObjectsWithTag("IndexFingerCollider");
                //Debug.Log(indexFinger[0].transform.position.ToString("F3"));
                Vector3 location = Quaternion.Euler(0, this.worldOrientation, 0) * hand[0].transform.position; // Add the index finger location
                gridManager.AddTargetLocation(location);
            }
        }

        gridManager.AddTargetRotation(new Vector3(0.0f, 0.0f, 0.0f));
        gridManager.AddTargetRotation(new Vector3(45.0f, 0.0f, 0.0f));
        gridManager.AddTargetRotation(new Vector3(-45.0f, 0.0f, 0.0f));


        // Now that you are done, set the flag to indicate we are done.

        welcomeDone = true;
    }
예제 #21
0
 public virtual void PauseThisScreen()
 {
     this.IsPaused = true;
     InstructionManager.PauseEngine();
     Math.Collision.CollisionManager.Self.IsPausedByScreen = true;
 }
    /// <summary>
    /// Coroutine for the experiment training.
    /// Implement your training loop here.
    /// </summary>
    /// <returns>Yield instruction</returns>
    public override IEnumerator TrainingLoop()
    {
        // First flag that we are in the training routine
        trainingDone = false;
        inTraining   = true;


        if (sessionNumber == 1)
        {
            InstructionManager.DisplayText("Let's start training then!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.


            //
            // HUD Colours
            InstructionManager.DisplayText("First, let's tell you about the colour of the HUD. It will tell you what you need to do." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("<Red>: for returning back and adjusting your start position." + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm red!");
            HudManager.colour = HUDManager.HUDColour.Red;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("<Orange>: for waiting for the countdown." + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm orange!");
            HudManager.colour = HUDManager.HUDColour.Orange;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("<Blue>: for reaching for the target.!" + "\n\n (Press the trigger)");
            HudManager.DisplayText("I'm blue!");
            HudManager.colour = HUDManager.HUDColour.Blue;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You need to hold on you reaching position for a while until the HUD says 'Well Done', like" + "\n\n (Press the trigger)");
            HudManager.colour = HUDManager.HUDColour.Red;
            HudManager.DisplayText("Well Done");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.ClearText();
            HudManager.colour = HUDManager.HUDColour.Red;

            //
            // Reaching practice
            InstructionManager.DisplayText("Next, the colour of the targets will tell you the status of the target." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("<Blue>: the target is selected as the next target." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("<Green>: you have successfully reached the selected one." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.


            //
            // Explain routine
            InstructionManager.DisplayText("Alright, let's explain the task routine." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("The task routine is: first keep your start position for 3 seconds, and HUD will tell you when to go." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Then reach to the target in <blue> using your index finger." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Finally, when you reach, hold on for a while, until you hear 'Return' and HUD says 'Well done'." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            //
            // Important messages
            InstructionManager.DisplayText("Important!: Keep your final reaching position when you hear 'Hold', like !!! " + "\n\n (Press the trigger to play)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            audio.clip = holdAudioClip;
            audio.Play(0);
            HudManager.DisplayText("Hold on for a while!!");
            InstructionManager.DisplayText("Important!: Keep your final reaching position when you hear 'Hold', like !!! " + "\n\n (Press the trigger to continue)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Important!: Do not return until HUD says 'Well Done' and you hear 'Return', like !!! " + "\n\n (Press the trigger to play)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            audio.clip = returnAudioClip;
            audio.Play(0);
            HudManager.DisplayText("Well done!!");
            InstructionManager.DisplayText("Important!: Do not return until HUD says 'Well Done' and you hear 'Return', like !!! " + "\n\n (Press the trigger to continue)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            //
            // Have a try
            InstructionManager.DisplayText("Ok, let's have a try of a routine." + "\n\n (Press the trigger)");
            HudManager.ClearText();
            HudManager.colour = HUDManager.HUDColour.Red;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.


            //
            // Start position
            InstructionManager.DisplayText("First, let's show you the start position." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            //
            // Start position
            InstructionManager.DisplayText("Your upper arm and elbow should point downards." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Try it. The HUD displays: (current upper and fore arm angle/the desired one)");
            //startPosPhoto.SetActive(true);
            //startPosPhoto.transform.Rotate(new Vector3(0.0f, 90.0f, 0.0f), Space.World);
            yield return(new WaitUntil(() => IsReadyToStart()));

            //startPosPhoto.SetActive(false);
            HudManager.ClearText();

            //Start practice
            gridManager.SelectTarget(0);
            InstructionManager.DisplayText("The sphere that you need to reach will turn blue. Don't reach now." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You'll have to wait for a three second countdown. Look at the sphere and get ready!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.colour = HUDManager.HUDColour.Orange;
            HUDCountDown(1);
            yield return(new WaitUntil(() => CountdownDone)); // And wait

            InstructionManager.DisplayText("Reach for it by index finger!!");
            HudManager.DisplayText("Reach for it by index finger!!");
            HudManager.colour = HUDManager.HUDColour.Blue;
            yield return(new WaitUntil(() => IsTaskDone()));

            // Signal the subject that the task is done
            HudManager.DisplayText("Hold on your current position!");
            yield return(new WaitForSecondsRealtime(1.0f));

            audio.clip = returnAudioClip;
            audio.Play();
            HudManager.colour = HUDManager.HUDColour.Red;
            HudManager.DisplayText("Well done (you can return to start position)!");
            // Reset flags
            hasReached   = false;
            taskComplete = false;
            HudManager.DisplayText("You can relax now. Look to the top right.", 3);

            //
            // End
            InstructionManager.DisplayText("Important: Do not return until you hear 'Return' and HUD says 'Well Done' !!! " + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Otherwise, you look ready to go! Good luck!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }
        if (sessionNumber == 2)
        {
            InstructionManager.DisplayText("Let's start training then!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            //
            // Reaching practice
            InstructionManager.DisplayText("Everthing is the same except you need to match the orientations." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Ok, let's have a try." + "\n\n (Press the trigger)");
            HudManager.ClearText();
            HudManager.colour = HUDManager.HUDColour.Red;
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            //Start practice
            gridManager.SelectTarget(2);
            InstructionManager.DisplayText("The sphere that you need to reach will turn blue. Do not reach now." + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("You'll have to wait for a three second countdown. Look at the sphere and get ready!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            HudManager.colour = HUDManager.HUDColour.Orange;
            HUDCountDown(3);
            yield return(new WaitUntil(() => CountdownDone)); // And wait

            InstructionManager.DisplayText("Reach for it!!");
            HudManager.DisplayText("Reach for it!!");
            HudManager.colour = HUDManager.HUDColour.Blue;
            yield return(new WaitUntil(() => IsTaskDone()));

            // Signal the subject that the task is done
            HudManager.DisplayText("Hold on!");
            yield return(new WaitForSecondsRealtime(1.0f));

            HudManager.colour = HUDManager.HUDColour.Red;
            HudManager.DisplayText("Well done (you can return to start position)!");
            // Reset flags
            hasReached   = false;
            taskComplete = false;
            HudManager.DisplayText("You can relax now. Look to the top right.", 3);

            //
            // End
            InstructionManager.DisplayText("Important: Hold your final reaching position until you hear 'Return' and HUD says 'Well Done' !!! " + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.

            InstructionManager.DisplayText("Otherwise, you look ready to go! Good luck!" + "\n\n (Press the trigger)");
            yield return(WaitForSubjectAcknowledgement()); // And wait for the subject to cycle through them.
        }

        // Now that you are done, set the flag to indicate we are done.
        trainingDone = true;
    }
예제 #23
0
    //Assets\stuff\Assets\anzug_glatze_sprite.png

    #region monobehaviour Stuff

    // Use this for initialization
    void Start()
    {
        currTime = 0;
        #region IntstructionManager
        IManager = new InstructionManager();
        //IManager.SaveInstructions (new InstructionMovement (2f, 0, new Vector2 (4f, 4f), 3));

        //InstructionData[] idat = new InstructionData[1];
        //idat [0] = new InstructionMovement (2f, 4, new Vector2 (3, 21), 5f);
        //IManager.SaveInstructions (idat);
        IManager.LoadInstructions();
        #endregion
        #region user

        List <InputMovement> input = new List <InputMovement> ();
        input.Add(new InputMovement(KeyCode.W, new Vector2(0f, 1f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.S, new Vector2(0f, -1f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.D, new Vector2(1f, 0f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.A, new Vector2(-1f, 0f), PressTypes.KeyDownKey));

        GameObject player = new GameObject("Player", typeof(SpriteRenderer), typeof(CircleCollider2D), typeof(Rigidbody2D));

        player.GetComponent <Rigidbody2D> ().isKinematic  = true;
        player.GetComponent <Rigidbody2D> ().bodyType     = RigidbodyType2D.Dynamic;
        player.GetComponent <Rigidbody2D> ().mass         = 1;
        player.GetComponent <Rigidbody2D> ().drag         = 1000;
        player.GetComponent <Rigidbody2D> ().angularDrag  = 10;
        player.GetComponent <Rigidbody2D> ().gravityScale = 0;

        player.GetComponent <CircleCollider2D> ().radius = 1.5f;
        player.GetComponent <SpriteRenderer> ().sprite   = CharacterSprites [0];

        AddNewPlayer(player, input);
        //Instantiate(player);
        Debug.Log("object created");
        #endregion

        new Spawner(this);

        /*
         #region polize
         *
         *
         * GameObject c = new GameObject ("Polizist",typeof(SpriteRenderer),typeof(CircleCollider2D),typeof(Rigidbody2D));
         *
         * c.transform.position = new Vector2(-4f,-5f);
         * c.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
         * c.GetComponent<Rigidbody2D>().mass = 2;
         * c.GetComponent<Rigidbody2D>().drag = 1000;
         * c.GetComponent<Rigidbody2D>().angularDrag = 10;
         * c.GetComponent<Rigidbody2D>().gravityScale = 0;
         *
         * c.GetComponent<CircleCollider2D>().radius = 1.5f;
         * c.GetComponent<SpriteRenderer> ().sprite = PolizistSprite;
         *
         *
         * AddNewCharacter(c);
         *
         * //Instantiate(player);
         * Debug.Log ("Character created");
         #endregion
         #region general
         *
         * GameObject g = new GameObject ("General", typeof(SpriteRenderer),typeof(CircleCollider2D),typeof(Rigidbody2D));
         * g.transform.position = new Vector2(8,8);
         * g.GetComponent<SpriteRenderer> ().sprite = GeneralSprite;
         *
         * g.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
         * g.GetComponent<Rigidbody2D>().mass = 2;
         * g.GetComponent<Rigidbody2D>().drag = 1000;
         * g.GetComponent<Rigidbody2D>().angularDrag = 10;
         * g.GetComponent<Rigidbody2D>().gravityScale = 0;
         *
         * g.GetComponent<CircleCollider2D>().radius = 1.5f;
         *
         * AddNewCharacter(g);
         *
         * //Instantiate(player);
         * Debug.Log ("Character created");
         #endregion
         */
        //kann benutzt werden um slowmos zu machen und so
        //einfach Zeitlauf verlangsamen
        //Debug.Log (Time.timeScale);
        Camera.main.gameObject.GetComponent <Camera_Behaivour> ().target = entities [0].entity.transform;
    }