void Start() { badWordSound = GetComponent <AudioSource>(); _clientManager = FindObjectOfType <ClientManager>(); if (_clientManager == null) { Debug.LogError("There should be a client manager in the scene!"); } goodWordSound = GameObject.Find("GoodWordSound").GetComponent <AudioSource>(); // Creating the dictionary only needs to happen at the start LetterIndices = new Dictionary <char, int>(OuijaLetters.Length); for (var i = 0; i < OuijaLetters.Length; ++i) { LetterIndices.Add(OuijaLetters[i].Letter, i); } GetNewWord(); letter = GetLetter(); }
void Update() { if (letter == null) { // If the word is completed spelling, wait a while on the last letter, then continue with a new word bool pauseCompleted = planchette.Pause(timeBetweenWords); if (pauseCompleted) { GetNewWord(); letter = GetLetter(); } } else { planchette.Move(letter.transform, timeBetweenLetters); timer += Time.deltaTime; if (timer >= timeStranglingPlanchetteRequired) { GetNewWord(); letter = GetLetter(); timer = 0; } // Do this when the planchette is near the letter it moves to if ((letter.transform.position - planchette.transform.position).magnitude <= threshold) { bool effectCompleted = planchette.Effect(); if (effectCompleted) { UpdateSpellingBoard(); letter = GetLetter(); } } } }