// Start is called before the first frame update void Start() { // neutral state, triggering no callbacks currentState = State.INIT; onDoneCallbacks = new Callbacks <State>(); StateManager.Instance.onStateChangeTo[StateManager.States.HUD].Add((s) => StopTraining(), once: true); stateMachine.onEnter[State.START] = (state) => { TutorialSteps.Instance.audioManager.ScheduleAudioClip(pauseMenuAudio.start, queue: true, onEnd: () => TutorialSteps.PublishNotification("Lift one foot off the pedals") ); RudderPedals.PresenceDetector.Instance.canPause = true; RudderPedals.PresenceDetector.Instance.pauseAudio = false; RudderPedals.PresenceDetector.Instance.OnPause((s) => Next(), once: true); PauseMenu.PauseMenu.Instance.switchScene.enabled = false; }; stateMachine.onEnter[State.PAUSE] = (state) => { TutorialSteps.Instance.audioManager.ScheduleAudioClip(pauseMenuAudio.paused); Next(); }; stateMachine.onEnter[State.UNPAUSE] = (state) => { TutorialSteps.Instance.audioManager.ScheduleAudioClip(pauseMenuAudio.unpause, queue: true, onEnd: () => TutorialSteps.PublishNotification("Put both feet back on the pedals") ); RudderPedals.PresenceDetector.Instance.OnUnpause((s) => Next(), once: true); }; stateMachine.onEnter[State.TELEPORT] = (state) => { TutorialSteps.Instance.audioManager.ScheduleAudioClip(pauseMenuAudio.teleport, onEnd: () => TutorialSteps.PublishNotification("Go to the menu and touch the Control button") ); RudderPedals.PresenceDetector.Instance.OnPause((s) => Next(), once: true); }; stateMachine.onEnter[State.DONE] = (state) => { RudderPedals.PresenceDetector.Instance.canPause = true; RudderPedals.PresenceDetector.Instance.pauseAudio = true; PauseMenu.PauseMenu.Instance.switchScene.enabled = true; onDoneCallbacks.Call(State.DONE); }; }
void Start() { //automaton = this; Debug.Log($"Training State visited {StateManager.Instance.TimesStateVisited(StateManager.States.Training)} times"); // get a reference to this singleton, as scripts from other scenes are not able to do this _ = Instance; Instance = this; //currentState = TrainingStep.IDLE; //if (StateManager.Instance.TimesStateVisited(StateManager.States.Training) <= 1) //{ // StartCoroutine(StartTrainingAfter(0)); //} //else //{ // Debug.Log("Training routine skipped."); // startTraining = false; //} //currentStep = TrainingStep.RIGHT_HAND; //NextStep(); //trainingStarted = false; #region StateDefinition stateMachine.onEnter[TrainingStep.HEAD] = (step) => { audioManager.ScheduleAudioClip(miscAudio.head, onStart: () => PublishNotification("Try moving your head around", miscAudio.head.length) ); audioManager.ScheduleAudioClip(miscAudio.nod, queue: true, onStart: () => PublishNotification("Give me a nod to continue", miscAudio.nod.length + 2) ); waitingForNod = true; }; stateMachine.onExit[TrainingStep.HEAD] = (step) => { waitingForNod = false; #if RUDDER if (StateManager.Instance.currentState == StateManager.States.Training) { RudderPedals.PresenceDetector.Instance.canPause = false; } #endif }; stateMachine.onEnter[TrainingStep.LEFT_ARM] = (step) => { #if SENSEGLOVE audioManager.ScheduleAudioClip(senseGloveAudio.leftArm, queue: false); //audioManager.ScheduleAudioClip(senseGloveAudio.leftBall, queue: true); PublishNotification("Move your left arm and try to touch the blue ball", senseGloveAudio.leftArm.length + 2); #else audioManager.ScheduleAudioClip(controllerAudio.leftArm, queue: false); PublishNotification("Press and hold the index trigger and try moving your left arm"); #endif audioManager.ScheduleAudioClip(controllerAudio.leftBall, queue: true, onStart: () => handCollectables.Find("HandCollectableLeft").gameObject.SetActive(true)); }; stateMachine.onExit[TrainingStep.LEFT_ARM] = (step) => { handCollectables.Find("HandCollectableLeft").gameObject.SetActive(false); }; stateMachine.onEnter[TrainingStep.LEFT_HAND] = (step) => { #if SENSEGLOVE audioManager.ScheduleAudioClip(senseGloveAudio.leftHandStart, queue: true, onStart: () => PublishNotification("Move your left hand into the blue box", senseGloveAudio.leftHandStart.length + 2) ); leftCalibrator.OnDone(s => Next(), once: true); #else audioManager.ScheduleAudioClip(controllerAudio.leftHand, queue: true, onStart: () => PublishNotification("Press the grip button on the side to close the hand.") ); #endif }; stateMachine.onExit[TrainingStep.LEFT_HAND] = (step) => { #if SENSEGLOVE // force stop the calibration, if not done so already leftCalibrator.StopCailbration(); #endif }; stateMachine.onEnter[TrainingStep.RIGHT_ARM] = (step) => { #if SENSEGLOVE audioManager.ScheduleAudioClip(senseGloveAudio.rightArm, queue: false); PublishNotification("Move your right arm and try to touch the blue ball"); #else audioManager.ScheduleAudioClip(controllerAudio.rightArm, queue: true); PublishNotification("Press and hold the index trigger and try moving your right arm"); #endif audioManager.ScheduleAudioClip(controllerAudio.rightBall, queue: true, onStart: () => handCollectables.Find("HandCollectableRight").gameObject.SetActive(true)); }; stateMachine.onExit[TrainingStep.RIGHT_ARM] = (step) => { handCollectables.Find("HandCollectableRight").gameObject.SetActive(false); }; stateMachine.onEnter[TrainingStep.RIGHT_HAND] = (step) => { #if SENSEGLOVE audioManager.ScheduleAudioClip(senseGloveAudio.rightHandStart, queue: true, onStart: () => PublishNotification("Move your right hand into the blue box") ); rightCalibrator.OnDone(s => Next(), once: true); #else audioManager.ScheduleAudioClip(controllerAudio.rightHand, queue: true, onStart: () => PublishNotification("Press the grip button to close the hand.") ); #endif }; #if SENSEGLOVE stateMachine.onExit[TrainingStep.RIGHT_HAND] = (step) => { rightCalibrator.StopCailbration(); }; stateMachine.onEnter[TrainingStep.ARM_LENGTH] = (step) => { armLengthCalibration.OnDone(state => Next(), once: true); armLengthCalibration.StartCalibration(); }; stateMachine.onExit[TrainingStep.ARM_LENGTH] = (step) => { armLengthCalibration.StopCalibration(); }; #endif #if WHEELCHAIR stateMachine.onEnter[TrainingStep.WHEELCHAIR] = (step) => { wheelChairTraining.OnDone((s) => Next(), once: true); wheelChairTraining.StartTraining(); }; stateMachine.onExit[TrainingStep.WHEELCHAIR] = (step) => { wheelChairTraining.StopTraining(); }; #endif #if RUDDER stateMachine.onEnter[TrainingStep.PAUSE_MENU] = (step) => { pauseMenuTraining.OnDone((s) => Next(), once: true); pauseMenuTraining.StartTraining(); }; stateMachine.onExit[TrainingStep.PAUSE_MENU] = (step) => { pauseMenuTraining.StopTraining(); }; stateMachine.onEnter[TrainingStep.DONE] = (step) => { //audioManager.ScheduleAudioClip(miscAudio.ready); RudderPedals.PresenceDetector.Instance.canPause = true; }; #else stateMachine.onEnter[TrainingStep.DONE] = (step) => { audioManager.ScheduleAudioClip(miscAudio.enterButton); }; //stateMachine.onEnter[TrainingStep.PAUSE_MENU] = (step) => //{ // PraiseUser(); // audioManager.ScheduleAudioClip(miscAudio.enterButton, queue: true); //}; #endif #endregion }
// Start is called before the first frame update void Start() { initialAriaTarget = ariaNavigation.target; currentState = State.START; ariaTrigger.TriggerEnterCallback((pos) => { var diff = (pos - ariaNavigation.target).magnitude; Debug.Log($"Aria Trigger, posDiff: {diff}, waiting: {waitingForTrigger}"); if (diff < 1f && waitingForTrigger) { Next(); } }); StateManager.Instance.onStateChangeTo[StateManager.States.HUD].Add((s) => StopTraining(), once: true); // states independent of input device stateMachine.onExit[State.FORWARD] = (state) => waitingForTrigger = false; stateMachine.onExit[State.BACKWARD] = (state) => waitingForTrigger = false; stateMachine.onExit[State.TURN_RIGHT] = (state) => waitingForTrigger = false; stateMachine.onExit[State.TURN_LEFT] = (state) => waitingForTrigger = false; stateMachine.onEnter[State.DONE] = (state) => { onDoneCallbacks.Call(State.DONE); }; #if RUDDER stateMachine.onEnter[State.BACKWARD] = (state) => { audioManager.ScheduleAudioClip(rudderWheelchairAudio.start_intro, queue: false); audioManager.ScheduleAudioClip(rudderWheelchairAudio.start, queue: true, onStart: () => { ariaNavigation.target = backwardGoal.position; TutorialSteps.PublishNotification("Press the left pedal to go backward"); waitingForTrigger = true; }, onEnd: () => { } ); }; stateMachine.onEnter[State.FORWARD] = (state) => { audioManager.ScheduleAudioClip(rudderWheelchairAudio.forward, onStart: () => { ariaNavigation.target = forwardGoal.position; waitingForTrigger = true; TutorialSteps.PublishNotification("Press the right pedal to go forward", rudderWheelchairAudio.backwards.length); }, onEnd: () => { } ); }; stateMachine.onEnter[State.TURN_LEFT] = (state) => { audioManager.ScheduleAudioClip(rudderWheelchairAudio.turn_left, onStart: () => { ariaNavigation.target = turnLeftGoal.position; TutorialSteps.PublishNotification("Turn left and follow me", rudderWheelchairAudio.turn_left.length); waitingForTrigger = true; }, onEnd: () => { } ); }; stateMachine.onEnter[State.TURN_RIGHT] = (state) => { audioManager.ScheduleAudioClip(rudderWheelchairAudio.turn_right_intro); audioManager.ScheduleAudioClip(rudderWheelchairAudio.turn_right, queue: true, onStart: () => { ariaNavigation.target = turnRightGoal.position; TutorialSteps.PublishNotification("Turn right and follow me", rudderWheelchairAudio.turn_right_intro.length + 2); waitingForTrigger = true; } ); }; #else stateMachine.onEnter[State.BACKWARD] = (state) => { audioManager.ScheduleAudioClip(rudderWheelchairAudio.start_intro, queue: false); audioManager.ScheduleAudioClip(joystickWheelchairAudio.howto, queue: true); audioManager.ScheduleAudioClip(joystickWheelchairAudio.back, queue: true, onStart: () => { ariaNavigation.target = backwardGoal.position; TutorialSteps.PublishNotification("Use the left joystick to drive back"); waitingForTrigger = true; }, onEnd: () => { } ); }; stateMachine.onEnter[State.FORWARD] = (state) => { audioManager.ScheduleAudioClip(joystickWheelchairAudio.front, queue: false, onStart: () => { ariaNavigation.target = forwardGoal.position; TutorialSteps.PublishNotification("Drive forwards"); waitingForTrigger = true; }, onEnd: () => { } ); }; stateMachine.onEnter[State.TURN_RIGHT] = (state) => { audioManager.ScheduleAudioClip(joystickWheelchairAudio.right, queue: false, onStart: () => { ariaNavigation.target = turnRightGoal.position; TutorialSteps.PublishNotification("Turn right", joystickWheelchairAudio.right.length + 2); waitingForTrigger = true; }, onEnd: () => { } ); }; stateMachine.onEnter[State.TURN_LEFT] = (state) => { audioManager.ScheduleAudioClip(joystickWheelchairAudio.left, onStart: () => { ariaNavigation.target = turnLeftGoal.position; TutorialSteps.PublishNotification("Turn left", joystickWheelchairAudio.left.length + 2); waitingForTrigger = true; }, onEnd: () => { } ); }; #endif }