internal void Reset() { m_morseDisplay.text = ""; m_letterDisplay.text = ""; m_linkedMorseValue = new MorseValue(); m_isSetWithData = false; }
public void SetDisplay(MorseValue value) { m_letterDisplay.text = MorseUtility.GuessValueInClassicMorse(value); m_morseDisplay.text = value.ToString(); m_linkedMorseValue = value; m_isSetWithData = true; }
public MorseValueWithOrigine GetCurrentMorseValueWithOrigine() { MorseValue valueDetected = new MorseValue(m_detectedKeys.ToArray()); string morseName = m_morseSource.GetSourceName(); MorseValueWithOrigine morseLinked = new MorseValueWithOrigine(morseName, valueDetected); return(morseLinked); }
private void DisplayMorseFound(MorseValueWithOrigine morse) { string morseText = TryToGestMorseValue(morse); m_displayCurrentlyTyped.text = morseText; m_displayCurrentlyTypedMorse.text = morse.GetMorseValue().ToString(); m_lastMorseReceived = morse.GetMorseValue(); }
public static string GuessValue(MorseValue morseValue, MorseValueToText[] possibleMatches) { List <MorseValueToText> matchs = possibleMatches.Where(k => k.GetValue().ToString().IndexOf(morseValue.ToString()) == 0).OrderBy(k => k.GetValue().ToString().Length).ToList(); if (matchs.Count > 0) { Debug.Log(matchs[0].GetValue().ToString() + " - " + morseValue.ToString()); return(matchs[0].GetTextAssociated()); } else { return("?"); } }
private MorseValue GetRandomClassicMorse() { MorseValue result = MorseUtility.GetRandomClassicMorseCode(); return(result); }
public MorseValueToText(string text, params MorseKey[] keys) { m_text = text; m_morse = new MorseValue(keys); }
public MorseValueToText(string text, string keys) { m_text = text; m_morse = new MorseValue(keys); }
public static string GuessValueInClassicMorse(MorseValue morseValue) { return(GuessValue(morseValue, ClassicMorseTable)); }
private void SetValue(string description, MorseKey[] keys) { m_morsValue = new MorseValue(keys); m_description = description; }
public void Update() { bool wasDown = m_previousState; bool isDown = m_isDown; bool wasPressing = m_isPressing; // Add time float delta = Time.deltaTime; if (m_isDown) { m_isDownTime += delta; } else { m_isUpTime += delta; } if (m_startDetectiong) { m_firstDetectionTime += delta; } //Check Pressing m_isPressing = m_isDownTime > m_longBecomePressing; //DETECT CHANGE if (wasPressing != m_isPressing && m_isPressing) { onMorsePressingState.Invoke(true); // Debug.Log("Start Pressing: " + m_isDownTime); } if (wasDown != isDown) { onMorseDownState.Invoke(isDown); if (isDown && !m_isPressing) { } else if (!isDown && !m_isPressing) { if (m_isDownTime < m_longDelay) { // Debug.Log("Short"); m_detectedKeys.Add(MorseKey.Short); onMorseKeyDetected.Invoke(MorseKey.Short); } else { m_detectedKeys.Add(MorseKey.Long); onMorseKeyDetected.Invoke(MorseKey.Long); // Debug.Log("Long"); } } else if (!isDown && m_isPressing) { Debug.Log("Stop Pressing: " + m_isDownTime); onMorsePressingState.Invoke(false); ResetMorseDetection(); } if (m_isDown) { m_isUpTime = 0; } else { m_isDownTime = 0; } } if (m_startDetectiong && !m_isPressing && m_isUpTime > m_blankCommitDelay) { //Debug.Log("Notify morse code"); MorseValue val = new MorseValue(m_detectedKeys.ToArray()); onMorseValueDetected.Invoke(val); ResetMorseDetection(); } m_previousState = isDown; }
public MorseValueWithOrigine(string emittorName, MorseValue value) { m_emittorName = emittorName; m_morse = value; }