void GetTelegraphInput() { if (Input.GetKeyDown("space") && !telegraphDown) { telegraphDownTime = Time.time; telegraphDown = true; PoorAnimation(); } if (Input.GetKeyUp("space") && telegraphDown) { if (Time.time < telegraphDownTime + dotInputPause) { SoundDot.Play(); InputCodeString += "."; } else { SoundDash.Play(); InputCodeString += "-"; } OutgoingTransmissionText.text = InputCodeString; telegraphDown = false; PoorAnimation(); } // if(telegraphDown && Time.time > telegraphDownTime + dashInputPause){ // timesUp = true; // } // if(Time.time > telegraphDownTime + dashInputPause){ // timesUp = true; // } }
IEnumerator PlayCode(string codeToPlay) { IncomingTransmissionText.text = ""; List <char> codeList = new List <char>(codeToPlay.ToCharArray()); foreach (char character in codeList) { if (character == '.') { SoundDot.Play(); IncomingTransmissionText.text += '.'; yield return(StartCoroutine(waitForSound(SoundDot))); } else if (character == '-') { SoundDash.Play(); IncomingTransmissionText.text += '-'; yield return(StartCoroutine(waitForSound(SoundDash))); } yield return(new WaitForSeconds(CodeSoundPause)); } }