/// <summary> /// Parses voice recognizer results after a small delay /// </summary> /// <param name="results">Results to be parsed</param> /// <returns></returns> private IEnumerator StartRecognizingAfterDelay(string results) { yield return(new WaitForSeconds(0.1f)); string lowercase = results.ToLower(); switch (lowercase) { case string a when a.Contains("wyjście") || a.Contains("wyjdź") || a.Contains("koniec"): // end the application LoadingScreen.enabled = true; Application.Quit(); break; case string b when b.Contains("raz") || b.Contains("jeden") || b.Contains("1"): // picking a minigame LoadingScreen.enabled = true; SceneManager.LoadScene("SayTarget", LoadSceneMode.Single); break; case string c when c.Contains("dwa") || c.Contains("2"): LoadingScreen.enabled = true; SceneManager.LoadScene("FollowThePath", LoadSceneMode.Single); break; case string d when d.Contains("trzy") || d.Contains("3") || d.Contains("czy"): LoadingScreen.enabled = true; SceneManager.LoadScene("Gazuma", LoadSceneMode.Single); break; case string e when e.Contains("pomoc") || e.Contains("opis"): // switch between two texts if (showingHelp) { showingHelp = false; StartCoroutine(FadeToAlpha(TEXT_FADE_TIME, HelpText)); StartCoroutine(UnfadeFromAlpha(TEXT_FADE_TIME, DescText)); voiceControllerInterface.StartListening(); } else { showingHelp = true; StartCoroutine(FadeToAlpha(TEXT_FADE_TIME, DescText)); StartCoroutine(UnfadeFromAlpha(TEXT_FADE_TIME, HelpText)); voiceControllerInterface.StartListening(); } break; default: voiceControllerInterface.StartListening(); break; } }
/// <summary> /// Parses the voice recognizer's results. /// </summary> /// <param name="results">Voice recognizer results string</param> public void OnVoiceRecognizerResults(string results) { string lowercase = results.ToLower(); if (lowercase.Contains("wyjdź") || lowercase.Contains("wyjście") || lowercase.Contains("koniec")) // exiting the app { SceneManager.LoadScene("MainMenu"); LoadingScreen.enabled = true; } if (AreValidResults(lowercase)) // scoring the target { Destroy(spawnedTarget); SpawnRandomTarget(); } voiceControllerInterface.StartListening(); }
private void Update() { if (hasPermissions) { hasPermissions = false; StartCoroutine(FadeToAlpha(TEXT_FADE_TIME, PermissionsWaitText)); StartCoroutine(FadeToAlpha(TEXT_FADE_TIME, PermissionsDeniedText)); StartCoroutine(UnfadeFromAlpha(TEXT_FADE_TIME, IntroductionText)); voiceControllerInterface = GetComponentInChildren <VoiceControllerInterface>(); // initializing voice recognizer voiceControllerInterface.StartListening(); } }
private void Update() { newLabelTimer += Time.deltaTime; if (waitingToShowNewLabel && newLabelTimer > NEW_LABEL_DELAY) // is it time to pick a new target label? { currentTargetLabelVariants = targetLabelsVariants[UnityEngine.Random.Range(0, targetLabelsVariants.Count - 1)]; target.SetDisplayedText(currentTargetLabelVariants[0]); waitingToShowNewLabel = false; voiceControllerInterface.StartListening(); } if (points >= MAX_POINTS) // is it time to change the path? { points = 0; currentPath++; if (currentPath > paths.Count - 1) { currentPath = 0; } target.SetPathCreator(paths[currentPath]); } }
private void Start() { LoadingScreen.enabled = false; // no loading at the beginning TextAsset targetLabelsResource = Resources.Load <TextAsset>("TargetLabels"); // loading target labels targetLabels = new List <string>(targetLabelsResource.text.ToLower().Split(new[] { "\r\n", "\r" }, System.StringSplitOptions.None)); TARGET_SPAWN_CIRCLE_RADIUS = CalculateTargetSpawnCircleRadius(); // calculating spawn circle radius based on the display dimensions SpawnRandomTarget(); voiceControllerInterface = GetComponentInChildren <VoiceControllerInterface>(); // initializing voice recognizer voiceControllerInterface.StartListening(); }
private void Start() { LoadingScreen.enabled = false; // no loading visible at the start voiceControllerInterface = GetComponentInChildren <VoiceControllerInterface>(); // initialize voice recognizer interface spawner.transform.localPosition = new Vector3( // move the spawner to the proper position TARGETS_PATH_RADIUS, 0.0f, 1.0f ); SetIndicatorColor(colors[Random.Range(0, colors.Length)]); // give it first color voiceControllerInterface.StartListening(); // start listening for commands }
/// <summary> /// Parses voice recognizer results after a small delay. /// </summary> /// <param name="results">Voice recognizer result string.</param> /// <returns></returns> private IEnumerator StartRecognizingAfterDelay(string results) { yield return(new WaitForSeconds(0.1f)); string lowercase = results.ToLower(); switch (lowercase) { case string a when a.Contains("wyjście") || a.Contains("wyjdź") || a.Contains("koniec"): // exiting the app LoadingScreen.enabled = true; Application.Quit(); break; case string b when b.Contains("dalej") || b.Contains("okej") || b.Contains("tak"): // proceed with the manager's state switch (splashScreenState) { case SplashScreenState.PermissionsDenied: LoadingScreen.enabled = true; Application.Quit(); break; case SplashScreenState.DisplayIntroduction: LoadingScreen.enabled = true; SceneManager.LoadScene("MainMenu", LoadSceneMode.Single); break; default: break; } break; default: voiceControllerInterface.StartListening(); // try again to recognize the speech after failuree break; } }
private void Start() { LoadingScreen.enabled = false; // no loading at the beginning voiceControllerInterface = GetComponentInChildren <VoiceControllerInterface>(); // initializing voice recognizer voiceControllerInterface.StartListening(); }
/// <summary> /// Parse voice recognizer results /// </summary> /// <param name="results"> Results string </param> public void OnVoiceRecognizerResults(string results) { string lowercase = results.ToLower(); int pickedNumber = 0; switch (lowercase) { case string a when a.Contains("wyjście") || a.Contains("wyjdź") || a.Contains("koniec"): // closing the minigame LoadingScreen.enabled = true; SceneManager.LoadScene("MainMenu"); break; case string b when b.Contains("raz") || b.Contains("jeden") || b.Contains("1"): // picking the target pickedNumber = 1; break; case string c when c.Contains("dwa") || c.Contains("2"): pickedNumber = 2; break; case string d when d.Contains("trzy") || d.Contains("3") || d.Contains("czy"): pickedNumber = 3; break; case string e when e.Contains("cztery") || e.Contains("4"): pickedNumber = 4; break; case string f when f.Contains("pięć") || f.Contains("5"): pickedNumber = 5; break; case string g when g.Contains("sześć") || g.Contains("6"): pickedNumber = 6; break; case string h when h.Contains("siedem") || h.Contains("7"): pickedNumber = 7; break; case string i when i.Contains("skip") || i.Contains("dalej") || i.Contains("kolor"): // changing the indicator's color Color newColor; do { newColor = colors[Random.Range(0, colors.Length)]; } while (newColor.Equals(indicatorColor)); indicatorColor = newColor; SetIndicatorColor(indicatorColor); break; default: break; } if (pickedNumber != 0) // removing the scored target(s) { LinkedListNode <GameObject> ptr = spawnedTargets.First; while (ptr != null) { GazumaBall currentBall = ptr.Value.GetComponent <GazumaBall>(); if (MatchesNumberAndColor(currentBall, pickedNumber)) { if (ExistsAndMatchesColor(ptr.Next)) // destroy matching neighbours { movementTimer -= SPAWN_DELAY; Destroy(ptr.Next.Value); spawnedTargets.Remove(ptr.Next); } if (ExistsAndMatchesColor(ptr.Previous)) { movementTimer -= SPAWN_DELAY; Destroy(ptr.Previous.Value); spawnedTargets.Remove(ptr.Previous); } movementTimer -= SPAWN_DELAY; // destroy scored target Destroy(ptr.Value); spawnedTargets.Remove(ptr); break; } ptr = ptr.Next; } } voiceControllerInterface.StartListening(); // listen for next voice commands }