private bool AddPointInMatchQueue(CocoVCSAnchor point)
        {
            int index = (_matchQueueStartIndex + _matchedCount) % _detectTotalCount;

            _matchQueue [index] = point;

            if (point != _detectSequence [_matchedCount])
            {
                return(false);
            }

            _matchedCount++;
            _lastMatchTime = Time.time;
            return(true);
        }
        private CocoVCSAnchor GetTouchPoint(Vector2 pos)
        {
            // x
            CocoVCSAlignX alignX = CocoVCSAlignX.None;

            pos.x /= Screen.width;
            if (pos.x <= _detectBounds.x)
            {
                alignX = CocoVCSAlignX.Left;
            }
            else if (pos.x >= 1 - _detectBounds.x)
            {
                alignX = CocoVCSAlignX.Right;
            }
            else if (Mathf.Abs(pos.x - 0.5f) <= _detectBounds.x / 2)
            {
                alignX = CocoVCSAlignX.Center;
            }

            // y
            CocoVCSAlignY alignY = CocoVCSAlignY.None;

            pos.y /= Screen.height;
            if (pos.y >= 1 - _detectBounds.y)
            {
                alignY = CocoVCSAlignY.Upper;
            }
            else if (pos.y <= _detectBounds.y)
            {
                alignY = CocoVCSAlignY.Lower;
            }
            else if (Mathf.Abs(pos.y - 0.5f) < _detectBounds.y / 2)
            {
                alignY = CocoVCSAlignY.Middle;
            }

            CocoVCSAnchor anchor = GetAnchor(alignX, alignY);

            //Debug.Log ("GetTouchPoint: " + pos + " -> " + anchor);
            return(anchor);
        }
        private void TouchPosition(Vector2 pos)
        {
            // timeout checking
            if (_matchedCount > 0)
            {
                if (Time.time - _lastMatchTime > _detectTimeout)
                {
                    ResetMatchQueue();
                }
            }

            CocoVCSAnchor point = GetTouchPoint(pos);

            if (point == CocoVCSAnchor.None)
            {
                ResetMatchQueue();
            }

            if (AddPointInMatchQueue(point))
            {
                //Debug.LogWarning (_matchQueueStartIndex + " - " + _matchedCount);
                // match finish
                if (_matchedCount >= _detectTotalCount)
                {
                    ResetMatchQueue();
                    DisplayVCSInfo(!_shouldDisplay);
                }
                return;
            }

            // refresh queue from next start index
            int startIndex = (_matchQueueStartIndex + 1) % _detectTotalCount;
            int endIndex   = (startIndex + _matchedCount) % _detectTotalCount;

            RefreshMatchQueue(startIndex, endIndex);
        }
 private CocoVCSAlignY GetAlignY(CocoVCSAnchor anchor)
 {
     return((CocoVCSAlignY)((int)anchor & 0xF0));
 }
 private CocoVCSAlignX GetAlignX(CocoVCSAnchor anchor)
 {
     return((CocoVCSAlignX)((int)anchor & 0x0F));
 }