//<summary>
        // create all objects necessary for sound game
        // including sound blanks, letters, jars, and word object
        //</summary>
        void LoadSoundGameWord(string word)
        {
            // get properties of current word in game
            WordProperties prop = WordProperties.GetWordProperties(word);

            if (prop != null)
            {
                // phonemes in word
                string[] phonemes = prop.Phonemes();
                // scale of word object
                float objScale = prop.ObjScale();
                // create sound blanks that are scrambled
                BlankCreation.CreateScrambledBlanks(word, phonemes, "Circle", "MovableBlank", "SoundGame");
                // create word object
                WordCreation.CreateWord(word, phonemes, "TargetLetter", "SoundGame");
                CreateWordImage(word, objScale);
                // create jars that "hold" each letter
            }
            else
            {
                Debug.LogWarning("Cannot find word properties");
            }
            CreateJars();
            // make letters black color
            GameObject[] tar = GameObject.FindGameObjectsWithTag(Constants.Tags.TAG_TARGET_LETTER);
            foreach (GameObject go in tar)
            {
                go.GetComponent <SpriteRenderer>().color = Color.black;
            }
        }
Esempio n. 2
0
        // Create word objects. Takes in the current level (category of words) and a list of objects (words).
        public static void CreateWordObjects(string level, string[] objects)
        {
            Vector3[] position = new Vector3[objects.Length];      // stores the desired position for each object
            float[]   scale    = new float[objects.Length];        // stores the appropriate scale for each object

            // Set x-position for each object
            if (objects.Length == 5)
            {
                float x1 = 6;
                float x2 = 3;
                float y1 = 2.5f;

                position = new Vector3[5] {
                    new Vector3(-x1, 0, 0),
                    new Vector3(0, y1, 0),
                    new Vector3(x1, 0, 0),
                    new Vector3(x2, -y1, 0),
                    new Vector3(-x2, -y1, 0)
                };
            }

            for (int i = 0; i < objects.Length; i++)
            {
                // Get appropriate scale for the object (info stored in WordProperties script)
                scale[i] = WordProperties.GetWordProperties(objects[i]).ObjScale();

                // Instantiate word object, according to the given input
                ObjectProperties obj = ObjectProperties.CreateInstance(objects [i], "WordObject", position [i], new Vector3(scale [i], scale [i], 1), level + "/" + objects [i], "Words/" + objects [i]);
                ObjectProperties.InstantiateObject(obj);
            }
        }
Esempio n. 3
0
        // create all objects necessary for sound game
        // including sound blanks, letters, jars, and word object
        void LoadSoundGameWord(string word)
        {
            // get properties of current word in game
            WordProperties prop = WordProperties.GetWordProperties(word);

            string[] phonemes = prop.Phonemes();           // phonemes in word
            float    objScale = prop.ObjScale();           // scale of word object

            // create sound blanks that are scrambled
            BlankCreation.CreateScrambledBlanks(word, phonemes, "Circle", "MovableBlank", "SoundGame");

            // create word object
            WordCreation.CreateWord(word, phonemes, "TargetLetter", "SoundGame");
            CreateWordImage(word, objScale);

            // create jars that "hold" each letter
            CreateJars();

            // make letters black color
            GameObject[] tar = GameObject.FindGameObjectsWithTag("TargetLetter");
            foreach (GameObject go in tar)
            {
                go.GetComponent <SpriteRenderer> ().color = Color.black;
            }
        }
Esempio n. 4
0
        // Create an instance of WordProperties with the desired properties set
        static WordProperties CreateInstance(string[] phonemes, float objScale)
        {
            WordProperties prop = ScriptableObject.CreateInstance <WordProperties> ();

            prop.Init(phonemes, objScale);
            return(prop);
        }
        //<summary>
        // Animation played when user correctly spells word
        // Word object pulses to a cheerful sound
        //</summary>
        public static void CelebratoryAnimation(float delayTime)
        {
            float      time = .3f;        // time to complete one pulse
            GameObject go   = GameObject.FindGameObjectWithTag(Constants.Tags.TAG_WORD_OBJECT);

            // grow and shirnk object a few times
            Debug.Log("Pulsing " + go.name);
            float objScale = WordProperties.GetWordProperties(go.name).ObjScale();

            LeanTween.scale(go, new Vector3(objScale * 1.5f, objScale * 1.5f, 1f), time).setDelay(delayTime);
            LeanTween.scale(go, new Vector3(objScale * .7f, objScale * .7f, 1), time).setDelay(delayTime + time);
            LeanTween.scale(go, new Vector3(objScale * 1.5f, objScale * 1.5f, 1f), time).setDelay(delayTime + 2 * time);
            LeanTween.scale(go, new Vector3(objScale * .7f, objScale * .7f, 1), time).setDelay(delayTime + 3 * time);
            LeanTween.scale(go, new Vector3(objScale * 1f, objScale * 1f, 1), time).setDelay(delayTime + 4 * time);
            // play cheerful sound
            Debug.Log("Playing clip for congrats");
            AudioSource audio = go.AddComponent <AudioSource>();

            audio.clip = Resources.Load("Audio/CongratsSound") as AudioClip;
            if (audio.clip != null)
            {
                audio.PlayDelayed(delayTime);
            }
            else
            {
                Debug.LogWarning("Cannot find audio file");
            }
        }
Esempio n. 6
0
        //<summary>
        // Play sound attached to object
        //</summary>
        public void PlaySound(GameObject go)
        {
            //find word in scene
            GameObject word = GameObject.FindGameObjectWithTag(Constants.Tags.TAG_WORD_OBJECT);
            //get phonemes of the word
            WordProperties prop = WordProperties.GetWordProperties(word.transform.name);

            // phonemes in word
            string[] phonemes = prop.Phonemes();
            //if phoeme contains the current letter
            //play the phoneme for that letter
            foreach (string sound in phonemes)
            {
                if (sound.Contains(go.transform.name))
                {
                    AudioSource audioSource = gameObject.AddComponent <AudioSource>();
                    string      file        = "Audio" + "/Phonemes/" + sound;
                    Debug.Log(file);
                    audioSource.clip = Resources.Load(file) as AudioClip;
                    if (audioSource.clip != null)
                    {
                        //play sound clip
                        audioSource.Play();
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find audio file");
                    }
                }
            }
        }
Esempio n. 7
0
        // create all letters and word object
        void LoadSpellingLesson(string word)
        {
            // get properties of current word being learned
            WordProperties prop = WordProperties.GetWordProperties(word);

            string[] phonemes = prop.Phonemes();           // phonemes in word
            float    objScale = prop.ObjScale();           // scale of object

            // create movable and target letters
            WordCreation.CreateMovableAndTargetWords(word, phonemes);

            // create word object
            CreateWordImage(word, objScale);
        }
Esempio n. 8
0
        // create all objects necessary for spelling game
        // including letters, blanks, and word object
        void LoadSpellingGameWord(string word)
        {
            // get properties of current word in game
            WordProperties prop = WordProperties.GetWordProperties(word);

            string[] phonemes = prop.Phonemes();           // phonemes in word
            float    objScale = prop.ObjScale();           // scale of object

            // create word with scrambled letters
            WordCreation.CreateScrambledWord(word, phonemes);

            // create blanks
            BlankCreation.CreateBlanks(word, phonemes, "Rectangle", "TargetBlank", "SpellingGame");

            // create word object
            CreateWordImage(word, objScale);
        }
Esempio n. 9
0
        //<summary>
        //Play audio clip for while pulsing the letter once
        //float index: order/position of the letter in the word
        //Synchronizes the pulse and sound for each letter
        //</summary>
        void PlaySoundAndPulseLetter(GameObject go, int index)
        {
            //find word, the letters are part of
            GameObject word = GameObject.FindGameObjectWithTag(Constants.Tags.TAG_WORD_OBJECT);

            if (word != null)
            {
                //get the phonemes for the word in the scene
                WordProperties prop = WordProperties.GetWordProperties(word.transform.name);
                if (prop != null)
                {
                    // phonemes in word
                    string[] phonemes = prop.Phonemes();
                    //create an audio source
                    AudioSource audioSource = gameObject.AddComponent <AudioSource>();
                    //load and play audio file attached to the letters
                    string file = "Audio" + "/Phonemes/" + phonemes[index];
                    audioSource.clip = Resources.Load(file) as AudioClip;
                    if (audioSource != null)
                    {
                        audioSource.PlayDelayed(index * clipLength);
                        StartCoroutine(PulseLetter(go, index * clipLength));
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find" + file + " audio component");
                    }
                }
                else
                {
                    Debug.LogError("Cannot find" + prop.name + "properties component");
                }
            }
            else
            {
                Debug.LogError("Cannot find" + word.name + " in scene");
            }
        }