Ejemplo n.º 1
0
    public IEnumerator ValidateWord(string word, int potionCount)
    {
        if (!History[History.Count - 1].IsWordFound(word))   // first check if word has already been created
        {
            bool valid = DictionaryManager.Instance.ValidWord(word);

            if (valid)
            {
                Debug.Log("valid");
                //TODO: animate word moving up into sky
                /* Play the validWord sound effect */
                AudioManager.Instance.PlayEffect(AudioManager.SoundEffects.ValidWord);
                /* Add the found word to the history */
                History[History.Count - 1].AddFoundWord(word);
                StartCoroutine(AddWordToBook(word));
                // add extra time for creating long words and using blends
                if (word.Length >= 4)
                {
                    AddTime(word.Length + word.Length - potionCount);
                }
                cauldron.InstantUpdateSprite();
                yield return(new WaitForSeconds(0.75f));

                cauldron.Clear();
            }
            else
            {
                Debug.Log("not valid");
                //TODO: animate cauldron exploding
                /* Play the invalidWord sound effect */
                AudioManager.Instance.PlayEffect(AudioManager.SoundEffects.InvalidWord);
                yield return(null);

                cauldron.Clear();
            }
        }
        else
        {
            Debug.Log("already made");
            //TODO: animate cauldron exploding
            /* Play the reusedWord sound effect */
            AudioManager.Instance.PlayEffect(AudioManager.SoundEffects.ReusedWord);
            yield return(null);

            cauldron.Clear();
        }
    }