public void SwipePointTrigger(SwipePoint swipePoint) { if (swipePoint == _swipePoints[_currentSwipePointIndex]) { _currentSwipePointIndex++; _countdown = _countdownMax; } if (_currentSwipePointIndex >= _swipePoints.Count) { _currentSwipePointIndex = 0; StartCoroutine(FinishTask(true)); } }
// Update is called once per frame void Update() { foreach (Touch touch in Input.touches) { _touches [touch.fingerId] = touch; } _touchDown = getNumberOfTouchesDown () >= NumberOfTouchesRequired; if (!_touchDown && _touchHistory.Count > 0) { _touchHistory.Clear (); } else if (_touchDown) { var newPoint = new SwipePoint () { Position = Input.GetTouch (0).position, DeltaTime = Time.deltaTime, Velocity = 0 }; if (_touchHistory.Count > 0) { var lastPoint = _touchHistory.Last (); newPoint.Velocity = (newPoint.Position - lastPoint.Position).magnitude / newPoint.DeltaTime; } _touchHistory.Add (newPoint); } switch (State) { case GestureState.Inactive: checkForBeginning (); break; case GestureState.Began: checkForCompletion (); break; case GestureState.Complete: reset (); break; case GestureState.Failed: if (!_touchDown) reset (); break; } }