private IEnumerator AttackRoutine() { while (enabled) { m_wizardBehaviour.Scream(); yield return(new WaitForSeconds(DifficultyLevel * 2f)); } }
// Update is called once per frame void Update() { if (Application.isEditor && Input.GetKeyDown(KeyCode.Space)) // for debugging { m_wizardBehaviour.Scream(); //m_wizardDeathBehaviour.enabled = true; } var pressed = m_keyCodes.Where(x => Input.GetKeyDown(x)); if (!pressed.Any()) { return; } //Debug.Log("Pressed: " + string.Join(" ", pressed.Select(x => x.ToString()).ToArray())); var words = GameObject.FindGameObjectsWithTag("Word").Select(x => x.GetComponent <TextHelper>()); foreach (var word in words) { foreach (var a in pressed) { var ch = a.ToString().ToLower().ToCharArray().FirstOrDefault(); if (word.GetNextCharacterToType() == ch) { AudioSource.PlayClipAtPoint(CharacterEnteredSound, Vector3.zero); } else { // TODO fail sound continue; } if (word.AcceptCharacter(ch)) { m_wizardBehaviour.Scream(); AudioSource.PlayClipAtPoint(WordCompleteSound, Vector3.zero); } } } }