private void soundResponse() { fishDictionary.word word = soundCommunication.nearestReceived(); if (word != null) { soundCommunication.Clear(); if (word.Name == "music") { curState = 13; } if (word.Name == "followme") { // Debug.Log("follow me"); curState = 14; //follow state followTarget = interactionTarget; isFollowing = true; } if (word.Name == "greeting") { curState = 11; } if (word.Name == "alert") { curState = 15; //flight state } if (word.Name == "smallTalk") { curState = 11; } } }
void Update() { isRecording = leftHand.triggerPressed; //setting the audio recorder if (!microphoneListener.enabled && isRecording && !menuActive) { audioRecorder.StartRecording(); microphoneCommunication.Clear(); barProgress = 0; } if (microphoneListener.enabled && !isRecording) { audioRecording = audioRecorder.StopRecording(); //audioImage = WaveFormImage.RenderWaveForm(audioRecording,Color.red); playbackWord = microphoneCommunication.nearestReceived(); recordingProgress.enabled = false; barProgress = 2 * maxRecordingLength; if (playbackWord != null) { knownWordManager.checkRecording(playbackWord); } else { knownWordManager.textBalloon(speaker, "Nothing recorded"); } } holdingRecording = audioRecorder.recording != null; //updating UI recordingProgress.enabled = isRecording; playProgress.enabled = !isRecording && holdingRecording; playButton.enabled = holdingRecording; barProgress += Time.deltaTime; recordingProgress.fillAmount = barProgress / maxRecordingLength; if (audioRecording) { playProgress.fillAmount = 2 * barProgress / audioRecording.length; } microphoneListener.enabled = isRecording; characterListener.enabled = !isRecording; if (leftHand.menuPressed && barProgress > .3f) { return; barProgress = 0; menuActive = !Menu.activeInHierarchy; Menu.SetActive(menuActive); //PointerScript.Toggle(a); playButton.enabled = menuActive; recordingProgress.enabled = menuActive; } if (leftHand.padPressed && !isRecording && holdingRecording && !menuActive && barProgress / audioRecording.length > .25f) { barProgress = 0; playbackDevice.playbackWord = playbackWord; playbackDevice.PlaySound(audioRecording); if (playbackWord != null) { knownWordManager.wordBalloon(speaker, playbackWord); } knownWordManager.particles(speaker); } }