public MorseEvent(float maxTime) : base(maxTime) { MorseCodeTranslator morse = GameObject.FindObjectOfType <MorseCodeTranslator>(); _morseObject = morse.gameObject; _morseObject.SetActive(false); }
/// <summary> /// Set default visual states on Start /// </summary> protected virtual void Start() { morseCodeTranslator = GameObject.FindGameObjectWithTag("MorseCode").GetComponent <MorseCodeTranslator>(); if (Keyword != "") { mKeywordArray = new string[1] { Keyword }; if (Keyword.IndexOf(',') > -1) { mKeywordArray = Keyword.Split(','); mKeywordDictionary = new Dictionary <string, int>(); for (int i = 0; i < mKeywordArray.Length; ++i) { mKeywordDictionary.Add(mKeywordArray[i], i); } } #if UNITY_WSA || UNITY_STANDALONE_WIN if (!KeywordRequiresGaze) { mKeywordRecognizer = new KeywordRecognizer(mKeywordArray); mKeywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; mKeywordRecognizer.Start(); } #endif } mCheckEnabled = IsEnabled; mCheckSelected = IsSelected; UpdateEffects(); }
public void RedditMorseToASCII() { const string input = ".... . .-.. .-.. --- / -.. .- .. .-.. -.-- / .--. .-. --- --. .-. .- -- -- . .-. / --. --- --- -.. / .-.. ..- -.-. -.- / --- -. / - .... . / -.-. .... .- .-.. .-.. . -. --. . ... / - --- -.. .- -.--"; string output = MorseCodeTranslator.ToASCII(input); Assert.AreEqual("HELLO DAILY PROGRAMMER GOOD LUCK ON THE CHALLENGES TODAY", output); }
/* Resets the morse translation text so next tests work properly */ public void AfterEachTest() { GameObject morseGraph = GameObject.FindGameObjectWithTag("MorseCode"); MorseCodeTranslator morseTranslator = morseGraph.GetComponent <MorseCodeTranslator>(); morseTranslator.morseTextTranslation = null; morseTranslator.MorseLetter = null; }
public void CanTranslateSimpleInputToMorse() { const string input = "ABC"; string output = MorseCodeTranslator.ToMorse(input); Assert.AreEqual(".- -... -.-.", output); }
public void CanTranslateThreeWordsToMorse() { const string input = "HI THERE HI"; string output = MorseCodeTranslator.ToMorse(input); Assert.AreEqual(".... .. / - .... . .-. . / .... ..", output); }
public void CanTranslateTwoWordsToASCII() { const string input = ".... .. / - .... . .-. ."; string output = MorseCodeTranslator.ToASCII(input); Assert.AreEqual("HI THERE", output); }
public void EndOfAlphabetTestToASCII() { const string input = "-..- -.-- --.."; string output = MorseCodeTranslator.ToASCII(input); Assert.AreEqual("XYZ", output); }
public void CanTranslateMorseToASCII() { const string input = ".- -... -.-."; string output = MorseCodeTranslator.ToASCII(input); Assert.AreEqual("ABC", output); }
static void Main(string[] args) { if (ValidArgs(args)) { string filePath = args[0]; ITranslator translator = new MorseCodeTranslator(); Console.WriteLine("Translating file: " + filePath); Console.WriteLine("Any invalid characters will be denoted by '!'\n"); Console.WriteLine(translator.Translate(filePath)); } }
public void MorseTranslateTestSimplePasses() { // Use the Assert class to test conditions. GameObject morseGraph = GameObject.FindGameObjectWithTag("MorseCode"); MorseCodeTranslator morseTranslator = morseGraph.GetComponent <MorseCodeTranslator>(); morseTranslator.InitializeDictionary(); Assert.AreEqual(morseTranslator.TranslateLetter("-.-"), "k"); Assert.AreEqual(morseTranslator.TranslateLetter("-.-."), "kc"); Assert.AreEqual(morseTranslator.TranslateLetter(".-."), "kcr"); }
public IEnumerator MorseTranslateTestWithEnumeratorPasses() { // Use the Assert class to test conditions. // yield to skip a frame GameObject morseGraph = GameObject.FindGameObjectWithTag("MorseCode"); MorseCodeTranslator morseTranslator = morseGraph.GetComponent <MorseCodeTranslator>(); Assert.AreEqual(morseTranslator.TranslateLetter("-.-"), "k"); Assert.AreEqual(morseTranslator.TranslateLetter("-.-."), "kc"); Assert.AreEqual(morseTranslator.TranslateLetter(".-."), "kcr"); yield return(null); }