コード例 #1
0
ファイル: GestureManagerIF.cs プロジェクト: manakamic/Gesture
        public bool RemoveSwipe(GestureSwipe swipe)
        {
            if (swipe == null || _listSwipe == null)
            {
                return(false);
            }

            return(_listSwipe.Remove(swipe));
        }
コード例 #2
0
ファイル: GestureManagerIF.cs プロジェクト: manakamic/Gesture
        public bool AddSwipe(GestureSwipe swipe)
        {
            if (swipe == null)
            {
                return(false);
            }

            if (_listSwipe == null)
            {
                _listSwipe = new List <GestureSwipe>();
            }

            _listSwipe.Add(swipe);

            return(true);
        }
        private void CheckSwipe(bool end)
        {
            if (_listSwipe == null)
            {
                return;
            }

            Vector3 pos        = Input.mousePosition;
            Vector2 touchPos   = new Vector2(pos.x, pos.y);
            Vector2 deltaPos   = new Vector2(pos.x - _lastPos.x, pos.y - _lastPos.y);
            Vector2 diffPos    = new Vector2(pos.x - _startPos.x, pos.y - _startPos.y);
            bool    stationary = (deltaPos.x < 1.0f && deltaPos.y < 1.0f) ? true : false;

            for (int i = 0, len = _listSwipe.Count; i < len; ++i)
            {
                GestureSwipe swipe = _listSwipe[i];

                if (swipe.enabled)
                {
                    if (!swipe.stationary && stationary)
                    {
                        continue;
                    }

                    if (swipe.Check(diffPos))
                    {
                        swipe.startPos = _startPos;
                        swipe.position = touchPos;
                        swipe.deltaPos = deltaPos;
                        swipe.end      = end;

                        swipe.callback();
                    }
                }
            }
        }