private void _SubscribeToGestures() { if (!isSubscribedToGestures) { swipeDownSubscription = swipeController.SubscribeToSwipe(SwipesController.Swipe.Down, _SwipeHandler); swipeLeftSubscription = swipeController.SubscribeToSwipe(SwipesController.Swipe.Left, _SwipeHandler); swipeRightSubscription = swipeController.SubscribeToSwipe(SwipesController.Swipe.Right, _SwipeHandler); swipeUpSubscription = swipeController.SubscribeToSwipe(SwipesController.Swipe.Up, _SwipeHandler); spreadSubscription = pinchController.SubscribeToPinch(PinchController.Pinch.PinchOpen, _PinchHandler); pinchSubscription = pinchController.SubscribeToPinch(PinchController.Pinch.PinchClose, _PinchHandler); isSubscribedToGestures = true; } }
public void StartNextStep() { Action <float> gestureNotificationHandler = (float delta) => { pinchController.UnsubscribeFromPinch(gestureSubscriptionID); gestureSubscriptionID = pinchController.SubscribeToPinch(PinchController.Pinch.Ending, (float delta1) => { pinchController.UnsubscribeFromPinch(gestureSubscriptionID); StartNextStep(); }); }; currentStage++; List <Tuple <TutorialScript.Actions, GameObject> > newPermittedActions = new List <Tuple <TutorialScript.Actions, GameObject> >(); switch (currentStage) { case Stages.WaitingForStart: break; case Stages.ZoomIn: newPermittedActions.Add(new Tuple <TutorialScript.Actions, GameObject>(TutorialScript.Actions.PinchOpen, null)); permitedActionSetter(newPermittedActions); tutorialZoomIn.SetActive(true); gestureSubscriptionID = pinchController.SubscribeToPinch(PinchController.Pinch.PinchOpen, gestureNotificationHandler); break; case Stages.ZoomOut: newPermittedActions.Add(new Tuple <TutorialScript.Actions, GameObject>(TutorialScript.Actions.PinchClose, null)); permitedActionSetter(newPermittedActions); tutorialZoomIn.SetActive(false); tutorialZoomOut.SetActive(true); gestureSubscriptionID = pinchController.SubscribeToPinch(PinchController.Pinch.PinchClose, gestureNotificationHandler); break; case Stages.End: tutorialZoomOut.SetActive(false); permitedActionSetter(newPermittedActions); actionOnComplete(); currentStage = Stages.WaitingForStart; break; } }
public int SubscribeToGesture(Gestures gesture, Action <float> handler) { int subResult = -1; switch (gesture) { case Gestures.PinchClose: subResult = pinchController.SubscribeToPinch(PinchController.Pinch.PinchClose, handler); break; case Gestures.PinchOpen: subResult = pinchController.SubscribeToPinch(PinchController.Pinch.PinchClose, handler); break; case Gestures.Twist: subResult = twistController.SubscribeToTwist(TwistController.Twist.Twist, handler); break; default: break; } return(subResult); }