예제 #1
0
파일: Player.cs 프로젝트: AustereHippy/2.5D
 void OnGesture(GestureState eventData)
 {
     if (GameManager.mode == GameMode.Game && GameManager.orthoToggle)
     {
         if (eventData == GestureState.SwipeLeft)
         {
             if (RayHit(GestureManager.orgLoc))
                 Move(Vector3.left);
         }
         else if (eventData == GestureState.SwipeRight)
         {
             if (RayHit(GestureManager.orgLoc))
                 Move(Vector3.right);
         }
         else if (eventData == GestureState.SwipeUp)
         {
             if (RayHit(GestureManager.orgLoc))
                 Move(Vector3.up);
         }
         else if (eventData == GestureState.SwipeDown)
         {
             if (RayHit(GestureManager.orgLoc))
                 Move(Vector3.down);
         }
     }
 }
예제 #2
0
    public void Rest()
    {
        switch (TrainGestureState)
        {
        case GestureState.NoMovement:
            return;

        case GestureState.Close:
            Controller.StopBendFingers();
            TrainGestureState = GestureState.NoMovement;
            break;

        case GestureState.Open:
            Controller.StopBendFingers();
            TrainGestureState = GestureState.NoMovement;
            break;

        case GestureState.Supination:
            StartCoroutine(Supination(false));
            break;

        case GestureState.Pronation:
            StartCoroutine(Pronation(false));
            break;

        case GestureState.Flexion:
            StartCoroutine(Flexion(false));
            break;

        case GestureState.Extension:
            StartCoroutine(Extension(false));
            break;
        }
    }
예제 #3
0
    public IEnumerator ResetHand()
    {
        for (var i = 0; i < Mathf.Abs(FelxionCount); i++)
        {
            yield return(new WaitForSeconds(0.01f));

            Controller.RotateWrist(FelxionCount >= 0 ? 0.1f : -0.1f);
        }
        for (var i = 0; i < Mathf.Abs(SupnationCount); i++)
        {
            yield return(new WaitForSeconds(0.01f));

            Controller.RotateForearm(SupnationCount >= 0 ? 0.1f : -0.1f);
        }
        for (var i = 0; i < Mathf.Abs(CloseCount); i++)
        {
            yield return(new WaitForSeconds(0.01f));

            if (CloseCount >= 0)
            {
                Controller.StopBendFingersAmount();
            }
            else
            {
                Controller.StartBendFingersAmount();
            }
        }
        Controller.StartBendFingers();
        Controller.StopBendFingers();
        TrainGestureState = GestureState.NoMovement;
        TestGestureState  = GestureState.NoMovement;
        SupnationCount    = 0;
        FelxionCount      = 0;
        CloseCount        = 0;
    }
예제 #4
0
 //return true if not matched, else return false
 private bool MatchingAnalysis(GestureState gesture)
 {
     if (gesture.ToMatchFrameIndex + 1 == gesture.ToMatch.Count)
     {
         var result = GestureMatchingEngine.LastFrameAnalyze(gesture);
         if (result == LastFrameResult.Matched)
         {
             gesture.Matched = true;
             return(false);
         }
         else if (result == LastFrameResult.Failed)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         if (GestureMatchingEngine.FrameAnalyze(gesture))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
예제 #5
0
        private void SetupTransitions()
        {
            current = GestureState.NO_TOUCH;

            transitions = new List <Transition>()
            {
                new Transition(GestureState.NO_TOUCH, GestureEvent.DOWN, GestureState.TOUCH_DOWN, HandleTouchDown),
                new Transition(GestureState.NO_TOUCH, GestureEvent.PINCH, GestureState.TOUCH_PINCH, HandlePinchStart),
                new Transition(GestureState.TOUCH_PINCH, GestureEvent.PINCH, GestureState.TOUCH_PINCH, HandlePinch),
                new Transition(GestureState.TOUCH_DOWN, GestureEvent.HOLD, GestureState.TOUCH_HOLD, HandleTouchHoldStart),
                new Transition(GestureState.TOUCH_DOWN, GestureEvent.PINCH, GestureState.TOUCH_PINCH, HandlePinchStart),
                new Transition(GestureState.TOUCH_DOWN, GestureEvent.DRAG, GestureState.TOUCH_DRAG, HandleDragStart),
                new Transition(GestureState.TOUCH_HOLD, GestureEvent.HOLD, GestureState.TOUCH_HOLD, HandleTouchHold),
                new Transition(GestureState.TOUCH_HOLD, GestureEvent.DRAG, GestureState.TOUCH_DRAG, () => { HandleTouchHoldEnd(); HandleDragStart(); }),
                new Transition(GestureState.TOUCH_HOLD, GestureEvent.PINCH, GestureState.TOUCH_PINCH, () => { HandleTouchHoldEnd(); HandlePinchStart(); }),
                new Transition(GestureState.TOUCH_DRAG, GestureEvent.DRAG, GestureState.TOUCH_DRAG, HandleDrag),
                new Transition(GestureState.TOUCH_DOWN, GestureEvent.DOUBLE, GestureState.NO_TOUCH, HandleDoubleTouch),
                new Transition(GestureState.TOUCH_DOWN, GestureEvent.UP, GestureState.NO_TOUCH, HandleTouchUp),
                new Transition(GestureState.TOUCH_HOLD, GestureEvent.UP, GestureState.NO_TOUCH, HandleTouchHoldEnd),
                new Transition(GestureState.TOUCH_PINCH, GestureEvent.UP, GestureState.NO_TOUCH, HandlePinchEnd),
                new Transition(GestureState.TOUCH_DRAG, GestureEvent.UP, GestureState.NO_TOUCH, HandleDragEnd),
                new Transition(GestureState.TOUCH_PINCH, GestureEvent.DRAG, GestureState.TOUCH_DRAG, () => { HandlePinchEnd(); HandleDragStart(); }),
                new Transition(GestureState.TOUCH_DRAG, GestureEvent.PINCH, GestureState.TOUCH_PINCH, () => { HandleDragCancel(); HandlePinchStart(); }),
                new Transition(GestureState.TOUCH_DRAG, GestureEvent.DOUBLE, GestureState.NO_TOUCH, HandleDragEnd)
            };
        }
예제 #6
0
 void TouchGesture(GestureState eventData)
 {
     if (mode == GameMode.Game && eventData == GestureState.DoubleTap)
     {
         ToggleOrthoMode();
     }
 }
예제 #7
0
 void OnGesture(GestureState eventData)
 {
     if (GameManager.mode == GameMode.Game && !GameManager.orthoToggle)
     {
         if (eventData == GestureState.SwipeLeft)
         {
             startAngle = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, Vector3.up) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeRight)
         {
             startAngle = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, -Vector3.up) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeUp)
         {
             startAngle = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, Vector3.right) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeDown)
         {
             startAngle = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, -Vector3.right) * transform.rotation;
             StartCoroutine(Swipe());
         }
     }
 }
예제 #8
0
        private void HandleGamepadAPressed()
        {
            // TODO: Should this handle Submit from Edit > ProjectSettings > Input ?
            if (Input.GetButtonDown(GamePadButtonA))
            {
                inputManager.RaiseSourceDown(this, GamePadId, InteractionSourcePressInfo.Select);
                isAPressed          = true;
                navigationCompleted = false;
                currentGestureState = GestureState.APressed;
            }

            if (isAPressed)
            {
                HandleNavigation();

                if (!holdStarted && !raiseOnce && !navigationStarted)
                {
                    // Raise hold started when user has held A down for certain interval.
                    Invoke("HandleHoldStarted", HoldStartedInterval);
                }

                // Check if we get a subsequent release on A.
                HandleGamepadAReleased();
            }
        }
예제 #9
0
        void DragFingerToMoveCamera(object beginDraw, object p)
        {
            //drawingRectOnScreen = (bool)beginDraw;
            GestureState state       = (GestureState)beginDraw;
            Vector2      hitPosition = (Vector2)p;

            switch (state)
            {
            case GestureState.Started:
            {
                OnMoveCameraStarted(hitPosition);
                break;
            }

            case GestureState.Updated:
            {
                OnMovingCamera(hitPosition);
                break;
            }

            case GestureState.Ended:
            {
                OnMoveCameraEnded(hitPosition);
                break;
            }
            }
        }
예제 #10
0
    /*
     * Checks for position of tool relative to interacting object.
     */
    protected void CheckProximityStatus()
    {
        switch (m_toolHandState)
        {
        case HandState.SEARCHING:
            CheckForObjectCollision();
            break;

        case HandState.HOLDING:
            //Closest proximity triggers
            //--------------------------
            GameObject activeInterior  = HydraController.Instance.HandTarget(m_hand, ProximityType.INSTRUMENT_INTERIOR, m_mode);
            GameObject activeProximity = HydraController.Instance.HandTarget(m_hand, ProximityType.INSTRUMENT_PROXIMITY, m_mode);

            //Set proximity state based on last state and current position
            //--------------------------
            if (activeProximity == m_heldObject)
            {
                if (activeInterior == m_heldObject)
                {
                    //Inside interior
                    if (m_gestureState == GestureState.PROXIMITY)
                    {
                        m_gestureState = GestureState.PROXIMITY_TO_INTERIOR;
                    }
                    else if (m_gestureState == GestureState.EXTERIOR)
                    {
                        m_gestureState = GestureState.EXTERIOR_TO_INTERIOR;
                    }
                }
                else
                {
                    //Inside proximity
                    if (m_gestureState == GestureState.INTERIOR)
                    {
                        m_gestureState = GestureState.INTERIOR_TO_PROXIMITY;
                    }
                    else if (m_gestureState == GestureState.EXTERIOR)
                    {
                        m_gestureState = GestureState.EXTERIOR_TO_PROXIMITY;
                    }
                }
            }
            else
            {
                //Outside exterior
                if (m_gestureState == GestureState.PROXIMITY)
                {
                    m_gestureState = GestureState.PROXIMITY_TO_EXTERIOR;
                }
                else if (m_gestureState == GestureState.INTERIOR)
                {
                    m_gestureState = GestureState.INTERIOR_TO_EXTERIOR;
                }
            }

            ProcessGestures();
            break;
        }
    }
예제 #11
0
 /*
  * Tool enter state
  */
 public override void TransitionIn()
 {
     m_toolHandState    = BaseTool.HandState.SEARCHING;
     m_gestureState     = GestureState.EXTERIOR;
     m_lastGestureState = GestureState.EXTERIOR;
     m_gestureTimer     = m_betweenGestureDelay;
 }
        private static void OnGestureComplete(Point gestureOrigin, Point releasePoint)
        {
            _state         = GestureState.None;
            _previousDelta = null;

            RaiseGestureEvent((handler) => handler.GestureCompleted, () => new Microsoft.Phone.Controls.GestureEventArgs(gestureOrigin, releasePoint), false);
        }
 /// <summary>
 /// Constructs a new <see cref="ActivateGestureEvent"/>.
 /// </summary>
 /// <param name="id">The <see cref="GestureId"/> associated with the gesture.</param>
 /// <param name="state">The <see cref="GestureId"/> associated with the gesture.</param>
 /// <param name="rayOrigin">The <see cref="Vector3"/> ray origin associated with the gesture.</param>
 /// <param name="rayDirection">The <see cref="Vector3"/> ray direction associated with the gesture.</param>
 public ActivateGestureEvent(GestureId id, GestureState state, Vector3 rayOrigin, Vector3 rayDirection)
 {
     m_Id           = id;
     m_State        = state;
     m_RayOrigin    = rayOrigin;
     m_RayDirection = rayDirection;
 }
예제 #14
0
 public CustomGesture(CustomGestureType type, Leap.Frame frame)
 {
     _type                 = type;
     _handsForGesture      = frame.Hands;
     _pointablesForGesture = frame.Pointables;
     _state                = GestureState.NA;
 }
    public void Start()
    {
        currentAction = GestureAction.Idle;
        if (Camera.main == null)
        {
            throw new Exception("no camera in scene, cannot gesture");
        }

        state = new GestureState()
        {
            zoomState  = new GestureZoomState(),
            dragState  = new GestureDragState(),
            twistState = new GestureTwistState(),
            tapState   = new GestureTapState(),
        };

        if (MousePlatforms.Contains(Application.platform))
        {
            platform           = new GesturePlatformMouse(gestures.config.mouse, keys, state, Camera.main, eventSystem);
            state.platformName = "Mouse";
            return;
        }

        platform           = new GesturePlatformTouch(state, Camera.main, gestures.config.touch);
        state.platformName = "Touch";
    }
        public virtual void OnXboxInputUpdate(XboxControllerEventData eventData)
        {
            if (string.IsNullOrEmpty(GamePadName))
            {
                GamePadName = eventData.GamePadName;
            }

            if (XboxControllerMapping.GetButton_Down(SelectButton, eventData))
            {
                CurrentGestureState = GestureState.SelectButtonPressed;

                InputManager.Instance.RaiseSourceDown(eventData.InputSource, eventData.SourceId, InteractionSourcePressInfo.Select);

                HoldStartedRoutine = StartCoroutine(HandleHoldStarted(eventData));
            }

            if (XboxControllerMapping.GetButton_Pressed(SelectButton, eventData))
            {
                HandleNavigation(eventData);
            }

            if (XboxControllerMapping.GetButton_Up(SelectButton, eventData))
            {
                HandleSelectButtonReleased(eventData);
            }

            // Consume this event
            eventData.Use();
        }
        protected virtual void HandleNavigation(XboxControllerEventData eventData)
        {
            float displacementAlongX = XboxControllerMapping.GetAxis(HorizontalNavigationAxis, eventData);
            float displacementAlongY = XboxControllerMapping.GetAxis(VerticalNavigationAxis, eventData);

            if (displacementAlongX == 0.0f && displacementAlongY == 0.0f && CurrentGestureState != GestureState.NavigationStarted)
            {
                return;
            }

            NormalizedOffset.x = displacementAlongX;
            NormalizedOffset.y = displacementAlongY;
            NormalizedOffset.z = 0f;

            if (CurrentGestureState != GestureState.NavigationStarted)
            {
                if (CurrentGestureState == GestureState.HoldStarted)
                {
                    InputManager.Instance.RaiseHoldCanceled(eventData.InputSource, eventData.SourceId);
                }

                CurrentGestureState = GestureState.NavigationStarted;

                // Raise navigation started event.
                InputManager.Instance.RaiseNavigationStarted(eventData.InputSource, eventData.SourceId);
            }
            else
            {
                // Raise navigation updated event.
                InputManager.Instance.RaiseNavigationUpdated(eventData.InputSource, eventData.SourceId, NormalizedOffset);
            }
        }
        protected virtual void HandleSelectButtonReleased(XboxControllerEventData eventData)
        {
            InputManager.Instance.RaiseSourceUp(eventData.InputSource, eventData.SourceId, InteractionSourcePressInfo.Select);

            if (HoldStartedRoutine != null)
            {
                StopCoroutine(HoldStartedRoutine);
            }

            switch (CurrentGestureState)
            {
            case GestureState.NavigationStarted:
                InputManager.Instance.RaiseNavigationCompleted(eventData.InputSource, eventData.SourceId, Vector3.zero);
                break;

            case GestureState.HoldStarted:
                InputManager.Instance.RaiseHoldCompleted(eventData.InputSource, eventData.SourceId);
                break;

            default:
                InputManager.Instance.RaiseInputClicked(eventData.InputSource, eventData.SourceId, InteractionSourcePressInfo.Select, 1);
                break;
            }

            CurrentGestureState = GestureState.SelectButtonUnpressed;
        }
예제 #19
0
 void OnGesture(GestureState eventData)
 {
     if (GameManager.mode == GameMode.Game && GameManager.orthoToggle)
     {
         if (eventData == GestureState.SwipeLeft)
         {
             if (RayHit(GestureManager.orgLoc))
             {
                 Move(Vector3.left);
             }
         }
         else if (eventData == GestureState.SwipeRight)
         {
             if (RayHit(GestureManager.orgLoc))
             {
                 Move(Vector3.right);
             }
         }
         else if (eventData == GestureState.SwipeUp)
         {
             if (RayHit(GestureManager.orgLoc))
             {
                 Move(Vector3.up);
             }
         }
         else if (eventData == GestureState.SwipeDown)
         {
             if (RayHit(GestureManager.orgLoc))
             {
                 Move(Vector3.down);
             }
         }
     }
 }
예제 #20
0
        /// <summary>
        /// Tries to change gesture state.
        /// </summary>
        /// <param name="value">New state.</param>
        /// <returns><c>true</c> if state was changed; otherwise, <c>false</c>.</returns>
        protected bool setState(GestureState value)
        {
            if (gestureManagerInstance == null)
            {
                return(false);
            }
            if (requireGestureToFail != null)
            {
                switch (value)
                {
                case GestureState.Recognized:
                case GestureState.Began:
                    if (!requiredGestureFailed)
                    {
                        delayedStateChange = value;
                        return(false);
                    }
                    break;

                case GestureState.Possible:
                case GestureState.Failed:
                case GestureState.Cancelled:
                    delayedStateChange = GestureState.Possible;
                    break;
                }
            }

            var newState = gestureManagerInstance.GestureChangeState(this, value);

            State = newState;

            return(value == newState);
        }
예제 #21
0
 public TwoFingerTouch(int id, CGPoint coord1, CGPoint coord2, GestureState state)
 {
     Id     = id;
     Coord1 = coord1;
     Coord2 = coord2;
     State  = state;
 }
예제 #22
0
파일: BaseCube.cs 프로젝트: ShamezW/2.5D
 void OnGesture(GestureState eventData)
 {
     if (GameManager.mode == GameMode.Game && !GameManager.orthoToggle)
     {
         if (eventData == GestureState.SwipeLeft)
         {
             startAngle  = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, Vector3.up) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeRight)
         {
             startAngle  = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, -Vector3.up) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeUp)
         {
             startAngle  = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, Vector3.right) * transform.rotation;
             StartCoroutine(Swipe());
         }
         else if (eventData == GestureState.SwipeDown)
         {
             startAngle  = transform.rotation;
             targetAngle = Quaternion.AngleAxis(90f, -Vector3.right) * transform.rotation;
             StartCoroutine(Swipe());
         }
     }
 }
예제 #23
0
        private IEnumerator ResetWhenTouchesEnd()
        {
            // Wait for lack of input
            bool bHasTouches    = Input.touchCount > 0;
            bool bHasMouseInput = Input.GetMouseButton(0);

            while (bHasTouches || bHasMouseInput)
            {
                yield return(null);

                bHasTouches    = Input.touchCount > 0;
                bHasMouseInput = !Input.GetMouseButton(0);
            }

            // Reset Gesture
            bool bHasBuffer = m_pxBuffer != null;

            if (bHasBuffer)
            {
                State = GestureState.GestureStateWaiting;
            }
            else
            {
                State = GestureState.GestureStatePossible;
            }
        }
예제 #24
0
        public void Pinch(GestureState state, float scale, SKPoint origin)
        {
            switch (state)
            {
            case GestureState.Started:
                startPinchMatrix = Matrix;
                startPinchOrigin = origin;
                totalPinchScale  = 1f;
                break;

            case GestureState.Running:
                totalPinchScale *= scale;
                var pinchTranslation  = origin - startPinchOrigin;
                var canvasTranslation = SKMatrix.MakeTranslation(pinchTranslation.X, pinchTranslation.Y);
                var canvasScaling     = SKMatrix.MakeScale(totalPinchScale, totalPinchScale, origin.X, origin.Y);
                var canvasCombined    = SKMatrix.MakeIdentity();
                SKMatrix.Concat(ref canvasCombined, ref canvasScaling, ref canvasTranslation);
                SKMatrix.Concat(ref Matrix, ref canvasCombined, ref startPinchMatrix);
                break;

            default:
                startPinchMatrix = SKMatrix.MakeIdentity();
                startPinchOrigin = SKPoint.Empty;
                totalPinchScale  = 1f;
                break;
            }
        }
예제 #25
0
 internal void Reset()
 {
     activeTouches.Clear();
     delayedStateChange    = GestureState.Possible;
     requiredGestureFailed = false;
     reset();
 }
예제 #26
0
 public void OnTouch(GestureState state)
 {
     if (state.phase == GesturePhase.End)
     {
         target.SendMessage(methodName);
     }
 }
 /// <summary>
 /// Constructs a new <see cref="MagicLeapKeyPoseGestureEvent"/>.
 /// </summary>
 /// <param name="id">The <see cref="GestureId"/> associated with the gesture.</param>
 /// <param name="state">The <see cref="GestureId"/> associated with the gesture.</param>
 /// <param name="keyPose">The <see cref="MagicLeapKeyPose"/> associated with the gesture.</param>
 /// <param name="hand">The <see cref="MagicLeapHand"/> associated with the gesture.</param>
 public MagicLeapKeyPoseGestureEvent(GestureId id, GestureState state, MagicLeapKeyPose keyPose, MagicLeapHand hand)
 {
     m_Id      = id;
     m_State   = state;
     m_KeyPose = keyPose;
     m_Hand    = hand;
 }
예제 #28
0
        private void HandleGamepadAPressed()
        {
            if (Input.GetButtonDown(GamePadButtonA))
            {
                //Debug.Log("Gamepad: A pressed");
                isAPressed          = true;
                navigationCompleted = false;
                currentGestureState = GestureState.APressed;
                InputRouter.Instance.PressedSources.Add(InteractionSourceKind.Controller);
            }

            if (isAPressed)
            {
                HandleNavigation();

                if (!holdStarted && !raiseOnce && !navigationStarted)
                {
                    // Raise hold started when user has held A down for certain interval.
                    Invoke("HandleHoldStarted", HoldStartedInterval);
                }

                // Check if we get a subsequent release on A.
                HandleGamepadAReleased();
            }
        }
예제 #29
0
 public void Reset()
 {
     IterationCount  = 0;
     State           = GestureState.None;
     Timestamp       = 0;
     StartPosition   = LPosition.None;
     CurrentPosition = LPosition.None;
 }
예제 #30
0
 private void transition(GestureState newState)
 {
     if (newState != state)
     {
         //Console.Out.WriteLine("Transition {0} => {1}", state, newState);
         state = newState;
     }
 }
예제 #31
0
 public void Reset()
 {
     gesturestate    = GestureState.NONE;
     initialdistance = 0.0;
     predistance     = 0.0;
     trackid         = 0;
     scaleindex      = 0;
 }
예제 #32
0
        public void PinchInProgress_is_false_when_pinch_state_changed(GestureState state)
        {
            var recognizer = new PlatformPinchRecognizerStub(new object());

            recognizer.OnPinchingBegan(0, 0);
            recognizer.OnPinchingStateChanged(state);
            recognizer.PinchInProgress.Should().BeFalse("since the pinch state changed");
        }
예제 #33
0
        protected override void AddGestureEventToCurrentList(GestureState state)
        {
            var deltaTrans = currPosition - lastPosition;
            CurrentGestureEvents.Add(new GestureEventDrag(state, ConfigDrag.RequiredNumberOfFingers, ElapsedSinceLast, ElapsedSinceBeginning, ConfigDrag.DragShape,
                                                          NormalizeVector(startPosition), NormalizeVector(currPosition), NormalizeVector(deltaTrans)));

            lastPosition = currPosition;

            base.AddGestureEventToCurrentList(state);
        }
        protected override void AddGestureEventToCurrentList(GestureState state)
        {
            var deltaRotation = currentRotation - lastRotation;
            var deltaScale = currentScale - lastScale;
            CurrentGestureEvents.Add(new GestureEventComposite(state, ElapsedSinceLast, ElapsedSinceBeginning, deltaRotation, currentRotation, deltaScale, currentScale,
                                                               NormalizeVector(beginCenter), NormalizeVector(lastCenter), NormalizeVector(currentCenter)));

            lastRotation = currentRotation;
            lastScale = currentScale;
            lastCenter = currentCenter;

            base.AddGestureEventToCurrentList(state);
        }
예제 #35
0
 /// <summary>Begins the recognition of the current gesture.</summary>
 void BeginRecognition()
 {
     if (SingleTouch()) {
         if (Input.touches[0].phase == TouchPhase.Began) {
             currentGesture = new Tap(Input.touches[0].position, Time.time);
             if (gestureState == GestureState.NEUTRAL) { NotifyGestureRecognitionStart(); }
             gestureState = GestureState.TAP;
         }
     } else if (MultiTouch()) {
         currentGesture = new Sprinch(Input.touches[0].position, Input.touches[1].position);
         gestureState = GestureState.SPRINCH;
     }
 }
예제 #36
0
 internal GestureEventTranslation(GestureType type, GestureState state, int numberOfFingers, TimeSpan deltaTime, TimeSpan totalTime, 
                                   GestureShape shape, Vector2 startPos, Vector2 currPos, Vector2 deltaTrans)
 {
     Type = type;
     State = state;
     NumberOfFinger = numberOfFingers;
     DeltaTime = deltaTime;
     TotalTime = totalTime;
     Shape = shape;
     StartPosition = startPos;
     CurrentPosition = currPos;
     DeltaTranslation = deltaTrans;
     TotalTranslation = currPos - startPos;
     AverageSpeed = TotalTranslation / (float)(TotalTime.TotalSeconds + 0.0001f); // avoid division by zero
 }
예제 #37
0
 internal GestureEventComposite(GestureState state, TimeSpan deltaTime, TimeSpan totalTime, float deltaAngle, float totalAngle, 
     float deltaScale, float totalScale, Vector2 firstCenter, Vector2 lastCenter, Vector2 currentCenter)
 {
     Type = GestureType.Composite;
     State = state;
     DeltaTime = deltaTime;
     TotalTime = totalTime;
     DeltaRotation = deltaAngle;
     TotalRotation = totalAngle;
     DeltaScale = deltaScale;
     TotalScale = totalScale;
     DeltaTranslation = currentCenter-lastCenter;
     TotalTranslation = currentCenter-firstCenter;
     CenterBeginningPosition = firstCenter;
     CenterCurrentPosition = currentCenter;
 }
예제 #38
0
 public void UpdatePosition(long timeStamp)
 {
     if (State != GestureState.InProcess)
     {
         State = GestureState.InProcess;
         TimeStamp = timeStamp;
     }
 }
예제 #39
0
        protected virtual void AddGestureEventToCurrentList(GestureState state)
        {
            ElapsedSinceLast = TimeSpan.Zero;

            if (state == GestureState.Ended)
                GestureBeganEventSent = false;
        }
예제 #40
0
 /// <summary>
 /// Limpia los datos de este gesto
 /// para comenzar un reconocimiento nuevo
 /// </summary>
 public void Clear()
 {
     FirstPosition = Vector2.one * -1;
     LastPosition = FirstPosition;
     StartTime = -1;
     State = GestureState.Possible;
 }
예제 #41
0
 internal void Reset()
 {
     activeTouches.Clear();
     delayedStateChange = GestureState.Possible;
     requiredGestureFailed = false;
     reset();
 }
예제 #42
0
 public void UpdateState(GestureState state, long timeStamp)
 {
     State = state;
     TimeStamp = timeStamp;
 }
예제 #43
0
    public void Correct()
    {
        if(m_coroutine != null)
            StopCoroutine(m_coroutine);

        m_gestureState = GestureState.START;

        m_playerMgr.RemoveBB();

        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);

        if(m_FXObj != null)
            Destroy(m_FXObj);

        ++gaugeCount;
        if(gaugeCount > m_fullgaugeCount)
            gaugeCount = m_fullgaugeCount;

        if(m_phase == BattlePhase.SPECIAL)
        {
            m_phase = BattlePhase.ATTACK;
            gaugeCount = 0;
            ResetGauge();
        }
        else
        {
            m_HUDService.HUDControl.SetSpecialGaugeAmt((float)gaugeCount/m_fullgaugeCount);
        }
    }
예제 #44
0
파일: Gesture.cs 프로젝트: gijs/TouchScript
        }

        internal void Reset()
        {
예제 #45
0
    IEnumerator CommenceAtkInterval()
    {
        // Testing for Emiko's Proposal
        // yield return new WaitForSeconds(m_interval);
        if (GestureGenerateMethod != null) {
            GestureGenerateMethod ();
        }

        m_HUDService.HUDControl.ShowTip(true);

        // Display Special Effect
        m_FXObj = Instantiate(Resources.Load ("Prefabs/FX/Special_Attack_Fx")) as GameObject;
        m_FXObj.transform.SetParent(m_itemParent.transform, false);
        m_FXObj.transform.localPosition = new Vector3(720, m_FXObj.transform.localPosition.y, -20);

        // Remove HUD
        m_HUDService.HUDControl.ShowTop(false);
        m_HUDService.HUDControl.ShowHPBars(false);
        m_HUDService.ShowQuestTime(false);

        m_cntDwnRnt = Utility.DelayInSeconds(m_gestureInv - m_specialCountDown,
                        (res) =>
                        {
                            GameObject obj = Instantiate(Resources.Load("Prefabs/Battle/CountDown")) as GameObject;
                            obj.transform.SetParent(m_HUDService.HUDControl.transform, false);
                            obj.transform.localScale = new Vector3(180, 180, 1);
                        } );
        StartCoroutine(m_cntDwnRnt);

        // Count Down till Gesture Failure
        yield return new WaitForSeconds(m_gestureInv);

        ClearGesture();

        m_playerMgr.RemoveBB();
        m_HUDService.HUDControl.ShowTop (true);
        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);
        m_soundService.StopMusic(m_SPECIAL);
        m_soundService.PlayMusic(m_BGM, true);

        if(m_FXObj != null)
            Destroy(m_FXObj);

        m_gestureState = GestureState.END;
        gaugeCount = 0;

        ResetGauge();

        m_phase = BattlePhase.ATTACK;

        // Move Camera to view Enemy
        Service.Get<MapService>().TweenPos(new Vector3(703f, -3.76f, 0.0f),
                                                    new Vector3(-703f, -3.76f, 0.0f),
                                                    UITweener.Method.EaseInOut,
                                                    UITweener.Style.Once,
                                                    null,
                                                    "");
    }
예제 #46
0
		internal SwipeGesture (GestureState state, Vector2 point, Vector2 surfacePoint, SwipeDirection direction) : base(state, point, surfacePoint) {
			this.Direction = direction;
		}
예제 #47
0
		public Gesture (GestureState state, Vector2 point, Vector2 surfacePoint) {
			this.State = state;
			this.Point = point;
			this.SurfacePoint = surfacePoint;
		}
예제 #48
0
    void Update()
    {
        switch(m_phase)
        {
            case BattlePhase.START:
            {
                m_phase = BattlePhase.ATTACK;

            }
            break;
            case BattlePhase.ATTACK:
            {
                m_gestureHandler.DisableGesture = true;
                if(gaugeCount >= m_fullgaugeCount)
                {
                    if(m_beginFinisher)
                    {
                        m_phase = BattlePhase.SPECIAL;
                        m_beginFinisher = false;
                    }
                }
            }
            break;
            case BattlePhase.SPECIAL:
            {
                if(m_gestureState == GestureState.START)
                {
                    m_gestureHandler.DisableGesture = false;
                    m_gestureState = GestureState.SHOWING;
                    m_gestureStart = true;
                    m_coroutine = CommenceAtkInterval();

                    GestureGenerateMethod = m_gestureGenerator.GenerateEasyGesture;
                    StartCoroutine(m_coroutine);
                }
            }
            break;
            case BattlePhase.END:
            {
                if(m_win)
                {
                    StartCoroutine(Utility.DelayInSeconds( 4.0f,
                                                        (res) =>
                                                        {
                                                            m_soundService.StopMusic(m_SPECIAL);

                                                            m_boardCollider.SetActive(true);
                                                            if(m_boardHandler != null)
                                                                m_boardHandler.Init(m_win);
                                                        } ));
                }
                else
                {
                    m_win = true; // Reset win
                    GameObject obj = Instantiate(Resources.Load("Prefabs/GeneralPopUp")) as GameObject;
                    GeneralPopUp popuphandler = obj.GetComponent<GeneralPopUp>();
                    popuphandler.Init("Use 1 Gem to Revive with full HP.", "Yes", "No", Revive, Exit);
                    m_HUDService.HUDControl.AttachMid(ref obj);

                }

                m_phase = BattlePhase.TOTAL;
            }
            break;
        }
    }
예제 #49
0
    void Start()
    {
        m_enemyMgr = EnemyManager.Get();
        m_playerMgr = PlayerManager.Get();
        m_gestureHandler = InputManager.Get();

        m_gestureStart = false;
        m_beginFinisher = false;

        m_gestureState = GestureState.START;
        m_phase = BattlePhase.START;

        gaugeCount = 0;

        m_win = true;

        Service.Init();
        m_HUDService = Service.Get<HUDService>();
        m_HUDService.StartScene();

        // Create Battle HUD
        m_HUDService.CreateBattleHUD();
        m_HUDService.ShowBottom(false);
        m_HUDService.HUDControl.SetSpecialEnable(false);

        // Create Sound Service
        m_soundService = Service.Get<SoundService>();
        m_soundService.PreloadSFXResource(new string[13]{"attack01", "attack02", "attack03",
                                                            "countdown", "enemyattack", "finalstrokeappear",
                                                            "gaugefull", "magicnotecorrect", "playermoveattack",
                                                            "sceneswish", "supermove", "win", "LadyKnight_Shine"});

        m_BGM = Resources.Load("Music/" + m_bgmMusic) as AudioClip;
        m_SPECIAL = Resources.Load("Music/supermove_jingle" ) as AudioClip;
        m_soundService.PlayMusic(m_BGM, true);
        // Create Battle HUD

        if (nextBattleArea == 1) {
            m_bgTexture.mainTexture = Resources.Load ("Texture/BG_battle3") as Texture;
        }
        else if (nextBattleArea == 2) {
            m_bgTexture.mainTexture = Resources.Load ("Texture/BG_battle2") as Texture;
        }
    }
예제 #50
0
    void OnFinishPressed()
    {
        if(m_coroutine != null)
            StopCoroutine(m_coroutine);

        m_gestureState = GestureState.START;

        m_soundService.StopMusic(m_BGM);
        m_soundService.PlayMusic(m_SPECIAL, true);

        m_HUDService.HUDControl.SetSpecialFxGlow(false);

        ResetGauge();

        m_beginFinisher = true;
        m_HUDService.HUDControl.ShowActionButtons(false);
        m_HUDService.HUDControl.SetSpecialEnable(false);
    }
예제 #51
0
 public void UpdatePosition(WavePosition position, long timeStamp)
 {
     if (CurrentPosition != position)
     {
         if (position == WavePosition.Left || position == WavePosition.Right)
         {
             if (State != GestureState.InProcess)
             {
                 State = GestureState.InProcess;
                 IterationCount = 0;
                 StartPosition = position;
             }
             ++IterationCount;
         }
         CurrentPosition = position;
         TimeStamp = timeStamp;
     }
 }
예제 #52
0
 public void Reset()
 {
     State = GestureState.None;
     TimeStamp = 0;
     StartX = 0;
     StartY = 0;
 }
예제 #53
0
        /// <summary>
        /// Actualiza la informacion de este gesto, comprobando si es posible que sea valido
        /// </summary>
        /// <param name="position">Posicion a revisar</param>
        /// <param name="currentTime">Tiempo actual</param>
        /// <param name="ending">Indica si la posicion es el final del gesto o no</param>
        public void Update(Vector2 position, float currentTime, bool ending = false)
        {
            // Si se ha descartado ya el gesto, retornar
            if (State == GestureState.Failed)
            {
                return;
            }

            // Si se esta comenzando el reconocimiento
            if (StartTime == -1)
            {
                FirstPosition = position;
                LastPosition = FirstPosition;
                StartTime = currentTime;
                return;
            }

            // Reviso que el tiempo maximo no haya sido alcanzado
            // y en caso de estar terminando el reconocimiento, que la distancia minima haya sido cubierta
            if (currentTime - StartTime > MaxTime || (ending && (FirstPosition - position).sqrMagnitude < MinDistance * MinDistance))
            {
                State = GestureState.Failed;
                return;
            }

            // Reviso las condiciones especificas del gesto
            State = CheckConditions(position);
            if (ending && State == GestureState.Possible)
            {
                State = GestureState.Recognized;
            }
        }
예제 #54
0
    public void SpecialCorrect()
    {
        if(m_coroutine != null)
            StopCoroutine(m_coroutine);
        m_gestureState = GestureState.START;

        m_playerMgr.RemoveBB();

        m_HUDService.HUDControl.ShowTop (true);
        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);

        if(m_FXObj != null)
            Destroy(m_FXObj);

        m_phase = BattlePhase.ATTACK;
        gaugeCount = 0;
        ResetGauge();
    }
예제 #55
0
파일: Gesture.cs 프로젝트: gijs/TouchScript
        /// <summary>
        /// Called to reset gesture state after it fails or recognizes.
        /// </summary>
        protected virtual void reset()
        {
        }

        /// <summary>
        /// Tries to change gesture state.
        /// </summary>
        /// <param name="value">New state.</param>
        /// <returns><c>true</c> if state was changed; otherwise, <c>false</c>.</returns>
        protected bool setState(GestureState value)
예제 #56
0
 internal void INTERNAL_SetState(GestureState value)
 {
     setState(value);
 }
예제 #57
0
 public void UpdatePosition(float x, float y, long timeStamp)
 {
     if (StartX != x || StartY != y)
     {
         if (State != GestureState.InProcess)
         {
             State = GestureState.InProcess;
             StartX = x;
             StartY = y;
             TimeStamp = timeStamp;
         }
     }
 }
예제 #58
0
 internal void INTERNAL_Reset()
 {
     activeTouches.Clear();
     numTouches = 0;
     delayedStateChange = GestureState.Possible;
     touchesNumState = TouchesNumState.TooFew;
     requiredGestureFailed = false;
     reset();
 }
예제 #59
0
		internal PanGesture (GestureState state, Vector2 point, Vector2 surfacePoint, Vector2 translation) : base(state, point, surfacePoint) {
			this.Translation = translation;
		}
예제 #60
0
        /// <summary>
        /// Tries to change gesture state.
        /// </summary>
        /// <param name="value"> New state. </param>
        /// <returns> <c>true</c> if state was changed; otherwise, <c>false</c>. </returns>
        protected bool setState(GestureState value)
        {
            if (gestureManagerInstance == null) return false;
            if (!enabled && value != GestureState.Failed) return false;
            if (requireGestureToFail != null)
            {
                switch (value)
                {
                    case GestureState.Recognized:
                    case GestureState.Began:
                        if (!requiredGestureFailed)
                        {
                            delayedStateChange = value;
                            return false;
                        }
                        break;
                    case GestureState.Possible:
                    case GestureState.Failed:
                    case GestureState.Cancelled:
                        delayedStateChange = GestureState.Possible;
                        break;
                }
            }

            var newState = gestureManagerInstance.INTERNAL_GestureChangeState(this, value);
            State = newState;

            return value == newState;
        }