IEnumerator PlaySounds() { if (!soundMaker) { soundMaker = GameObject.FindObjectOfType <SoundMaker>(); } soundMaker.MakeSound(progressionSounds[0]); yield return(new WaitForSeconds(progressionSounds[0].length)); soundMaker.MakeSound(progressionSounds[1]); }
public void PlaySound(AudioClip clip) { if (!maker) { maker = GameObject.FindObjectOfType <SoundMaker>(); maker.MakeSound(clip); } else { maker.MakeSound(clip); } }
public static void TakeMessage(string msg, SoundMaker talker, Transform subject = null) { //deal with simon if (talker.simonSayer) { if (Time.time > talker.timeWhenSimonDies) { talker.simonSayer = false; talker.simonSayee.simon = false; talker.simonSayee = null; } else { talker.timeWhenSimonDies = Time.time + talker.simonTimeCheck; } } //end Command cmd = new Command(talker); string[] message = msg.Split(' '); bool hasVerb = false; bool hasNoun = false; foreach (string word in message) { //this ain't a verb or a noun... if (word.Length == 3 || word.Length == 5 || talker.simonSayer) { cmd.custom = word; continue; } if (hasVerb && hasNoun) { break; } if (verbs.ContainsKey(word))//its a verb!! { hasVerb = true; cmd.verb = verbs[word]; continue; } if (nouns.ContainsKey(word))//its a noun!! { hasNoun = true; cmd.noun = nouns[word]; continue; } } if (subject) { cmd.subject = subject; Debug.Log("su"); } cmd.plain = msg; if (hasVerb && hasNoun)//congrats you have a whole command! { talker.MakeSound(cmd); } else//uh oh not a whole command { /*if (hasVerb) * { * talker.MakeSound(cmd); * }else if (talker.simonSayer)//you're playing simon says * { * talker.MakeSound(cmd); * }*/ talker.MakeSound(cmd); } }