//<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; } }
// 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; } }
//<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"); } } } }
// 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); }
// 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); }
//<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"); } }