public Bind(int fCount, FingerGesture fGesture, float fSensitivty, KeyCode kNegative, KeyCode kPositive, KeyCode kNegativeAlt, KeyCode kPositiveAlt, float kSensitivity) { FingerCount = fCount; FingerGesture = fGesture; FingerSensitivity = fSensitivty; KeyNegative = kNegative; KeyPositive = kPositive; KeyNegativeAlt = kNegativeAlt; KeyPositiveAlt = kPositiveAlt; KeySensitivity = kSensitivity; }
// Double tap boolean. Three since the initial release of the cut is counted. public bool DoubleTap() { if(fingerGesture == FingerGesture.TOGGLETORNPIECE){ fingerGesture = FingerGesture.NONE; return true; } else{ return false; } /*return (releasedCount >= 2 && releaseWatch.ElapsedMilliseconds <= DOUBLE_TAP_TIME_LIMIT);*/ }
private void DetermineInitGesture() { if(gameStateManagerRef.OnMobileDevice() && fingerGesture == FingerGesture.NONE){ if(touchController.GetLastFingerPosition() != TouchController.NULL_VECTOR){ if(((!foldRef.isFolded && worldCollisionRef.PointInsideObject(foldBorder, touchController.GetLastFingerPosition()) && !worldCollisionRef.PointInsideObject(moveBorder, touchController.GetLastFingerPosition())) || (foldRef.isFolded && worldCollisionRef.PointInsideObject( unfoldBorder, touchController.GetLastFingerPosition()) && !worldCollisionRef.PointInsideObject( unfoldBlocker, touchController.GetLastFingerPosition()))) && !(unfoldCollisionRef.getOverPlayer() && !foldRef.currentlyFolding) && foldMode){ //UnityEngine.Debug.Log("GESTURE IS FOLD"); fingerGesture = FingerGesture.FOLD; } else if(tearManagerRef.HaveTornOnce && worldCollisionRef.PointInsideObject(tornPiece, touchController.GetLastFingerPosition()) && !movingTornPiece && tearMode){ movingTornPiece = true; fingerGesture = FingerGesture.TOGGLETORNPIECE; } else if( //This selection of code was commented out for controls by Douglas Weller /*worldCollisionRef.PointInsideObject(moveBorder, touchController.GetLastFingerPosition()) || worldCollisionRef.PointInsideObject(unfoldBlocker, touchController.GetLastFingerPosition()) || (foldRef.isFolded && !worldCollisionRef.PointInsideObject( unfoldBorder, touchController.GetLastFingerPosition()) && worldCollisionRef.PointInsideObject(foldBorder, touchController.GetLastFingerPosition())) || (unfoldCollisionRef.getOverPlayer() && !foldRef.currentlyFolding && (worldCollisionRef.PointInsideObject(foldBorder, touchController.GetLastFingerPosition()) || worldCollisionRef.PointInsideObject( unfoldBorder, touchController.GetLastFingerPosition())))*/ moveMode){ //UnityEngine.Debug.Log("GESTURE IS MOVE"); fingerGesture = FingerGesture.MOVE; } else if(worldCollisionRef.PointInsideObject(tearBorder, touchController.GetLastFingerPosition()) && !worldCollisionRef.PointInsideObject(menuButton, touchController.GetLastFingerPosition()) && !worldCollisionRef.PointInsideObject(restartButton, touchController.GetLastFingerPosition()) && tearMode){ //UnityEngine.Debug.Log("GESTURE IS TEAR"); fingerGesture = FingerGesture.TEAR; //UnityEngine.Debug.Log("tearmode"); } } } }
// Logic needed when release input is detected. private void OnRelease() { //UnityEngine.Debug.Log("BUFFER " + bufferWatch.ElapsedMilliseconds); //UnityEngine.Debug.Log("PREV " + prevPressState); /* With configuring our own 'just pressed' logic, the player can skip press states ie Normal Press State Flow): JUST_PRESSED -> DOWN -> JUST_RELEASED -> UP instead, if released fast enough you can have this instead: JUST_PRESSED -> JUST_RELEASED -> UP skipping the down state completely. so with the above said, a previous press state for just release could either be just pressed or the expected down so if just pressed or down && bufferWatch has started and not in the buffer zone accept new input */ if(prevPressState.Equals(PressState.JUST_PRESSED) || prevPressState.Equals(PressState.UP) && (bufferWatch.ElapsedMilliseconds == 0 || bufferWatch.ElapsedMilliseconds > TAP_INPUT_BUFFER)){ // Start buffer watch if it has not already started. if(bufferWatch.ElapsedMilliseconds == 0){ bufferWatch.Start(); } // If beyond buffer threshold, restart watch. else if (bufferWatch.ElapsedMilliseconds > TAP_INPUT_BUFFER){ bufferWatch.Reset(); bufferWatch.Start(); } inputInit = false; // Trigger the OnRelease function used right now for double taps. DoubleTapRelease(); } // Stop the swipe watch from to determine amount of time the player pressed and released the touch device. // Used primarily for detecting jump input. swipeWatch.Stop(); justPressedWatch.Reset(); justPressedWatch.Stop(); if(!foldRef.currentlyFolding && !tearManagerRef.GetMovingPiece() && fingerGesture != FingerGesture.NONE){ //UnityEngine.Debug.Log("GESTURE IS NONE"); fingerGesture = FingerGesture.NONE; } }