Beispiel #1
0
 public void PollLock()
 {
     if (m_combination.Count > 0 && m_locked)
     {
         DialDir desiredDir = GetDesiredDir(m_comboIndex);
         if (!IsCorrectDialDirection(m_dialDirection, desiredDir) && m_dialMoved)
         {
             if (m_resetOnWrongNumber)
             {
                 m_comboIndex = 0;
             }
         }
         else
         {
             if (m_currentNumber == m_combination[m_comboIndex])
             {
                 m_comboHoldTimeCurrent += Time.deltaTime;
                 if (m_comboHoldTimeCurrent >= m_comboHoldTime)
                 {
                     m_comboIndex++;
                     if (m_comboIndex >= m_combination.Count)
                     {
                         m_comboIndex = m_combination.Count - 1;
                         Unlock();
                     }
                     NumberTicked();
                 }
             }
             else
             {
                 m_comboHoldTimeCurrent = 0;
             }
         }
     }
 }
Beispiel #2
0
 public bool IsCorrectDialDirection(DialDir dir, DialDir desiredDir)
 {
     if (!m_needDirection || dir == desiredDir || dir == DialDir.DD_Default)
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        int newNumber = GetNumberAtAngle(GetDialAngle());

        if (newNumber != m_currentNumber)
        {
            m_lastNumber    = m_currentNumber;
            m_currentNumber = newNumber;
            m_dialDirection = CalculateDialDirection(m_lastNumber, m_currentNumber);
            m_dialMoved     = true;
            if (m_useHapticFeedback && m_grabbedHand != null)
            {
                if (newNumber == m_combination[m_comboIndex])
                {
                    m_grabbedHand.controller.TriggerHapticPulse(m_hapticFeedbackCorrectDurationMicroseconds);
                }
                else
                {
                    m_grabbedHand.controller.TriggerHapticPulse(m_hapticFeedbackDurationMicroseconds);
                }
            }
        }

        PollLock();

        // debug
        if (m_numberDisplayText != null)
        {
            if (m_verboseDisplayText)
            {
                m_numberDisplayText.text = BetterReplaceKeywords(m_displayTextStringVerbose);
                //m_numberDisplayText.text =
                //	"Locked: " + m_locked +
                //	"\nNumber: " + m_currentNumber +
                //	"\nAngle: " + GetDialAngle() +
                //	"\nDir: " + getDialDirection() +
                //	"\nDDir: " + GetDesiredDir(m_comboIndex) +
                //	"\nIndex: " + m_comboIndex +
                //	"\nCurrent number: " + m_combination[m_comboIndex]
                //	;
            }
            else
            {
                m_numberDisplayText.text = BetterReplaceKeywords(m_displayTextString);
                //m_numberDisplayText.text =
                //	"Locked: " + m_locked +
                //	"\nNumber: " + m_currentNumber +
                //	"\nCurrent number: " + m_combination[m_comboIndex] +
                //	"\nNeeded Direction: " + (GetDesiredDir(m_comboIndex) == DialDir.DD_AntiClockwise ? "<-" : "->")
                //	;
            }
        }
    }
Beispiel #4
0
    public string DialDirEnumToString(DialDir dde)
    {
        switch (dde)
        {
        case DialDir.DD_AntiClockwise:
            return(m_antiClockwiseSymbol);

        case DialDir.DD_Clockwise:
            return(m_clockwiseSymbol);

        case DialDir.DD_Default:
            return("");
        }
        return("");
    }