Ejemplo n.º 1
0
 void HandleNewTouchDetected(ToucheTouch.Type type)
 {
     m_buttonImages [type].color = Color.red;
 }
Ejemplo n.º 2
0
 void HandleTouchOff(ToucheTouch.Type type)
 {
     m_buttonImages [type].color = Color.grey;
 }
Ejemplo n.º 3
0
        void CompareCurrentCurveToSavedCurves()
        {
            if (m_toucheCurves == null || m_currentCurve == null)
            {
                return;
            }

            int storedToucheCurveCount = m_toucheCurves.Count;

            List <ToucheTouch> toucheList = new List <ToucheTouch> ();

            foreach (int key in m_toucheCurves.Keys)
            {
                int       distance       = 0;
                Vector2[] storedVector2s = CurvePositionsToVector2(m_toucheCurves [key].curve);

                int vCount    = storedVector2s.Length;
                int currCount = m_currentCurve.Length;
                if (currCount < vCount)
                {
                    vCount = currCount;
                }

                if (vCount == 0)
                {
                    return;                     //Stop if we have no vectors...
                }
                for (int j = 0; j < m_steps; j++)
                {
                    if (j < vCount)
                    {
                        float temp = Vector2.Distance(storedVector2s [j], m_currentCurve [j]);
                        distance += (int)(temp * temp);                        //square to exxagerate differences
                    }
                }

                m_toucheCurves [key].distance = distance;
                toucheList.Add(m_toucheCurves [key]);
            }

            toucheList.Sort();                        //sorted by distance

            m_currentTouchType = toucheList [0].type; //lowest number wins...

            if (m_lastTouchType != m_currentTouchType)
            {
                for (int i = 0; i < toucheList.Count; i++)
                {
                    if (i == 0)
                    {
                        if (TouchOn != null)
                        {
                            TouchOn(m_currentTouchType);
                        }
                    }
                    else
                    {
                        if (TouchOff != null)
                        {
                            TouchOff(toucheList [i].type);
                        }
                    }
                }
            }

            m_lastTouchType = m_currentTouchType;
        }