/// <summary> /// Returns true if currentBall matches indicator's color and pickedNumber /// </summary> /// <param name="currentBall">Current target being checked</param> /// <param name="pickedNumber">Currently picked number</param> /// <returns></returns> private bool MatchesNumberAndColor(GazumaBall currentBall, int pickedNumber) { return(currentBall.GetColor().Equals(indicatorColor) && currentBall.GetNumber().Equals(pickedNumber)); }
/// <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 }