void Update() { // dont process drags if we have no input if( TouchKitLite.instance.liveTouches.Count == 0 ) return; var touch = TouchKitLite.instance.liveTouches[0]; // touch down, possible chance for a swipe if( touch.phase == TouchPhase.Began ) { _swipeDetectionState = _swipesToDetect; _startPoint = touch.position; _startTime = Time.time; _didCompleteDetection = false; } else if( touch.phase == TouchPhase.Moved ) { if( !_didCompleteDetection && checkForSwipeCompletion( touch ) ) { _didCompleteDetection = true; if( onSwipeDeteced != null ) onSwipeDeteced( completedSwipeDirection ); } } }
public void swipe(SwipeDirection direction) { switch(direction){ case SwipeDirection.Down: _ref.next(); onSuccessSwipe(this,new Swipe(SwipeDirection.Down)); break; case SwipeDirection.Right: if(_pos < (_slots.Count-1)){ _pos++; onSuccessSwipe(this,new Swipe(SwipeDirection.Right)); } _ref = _slots[_pos]; break; case SwipeDirection.Left: if(_pos > 0){ _pos--; onSuccessSwipe(this,new Swipe(SwipeDirection.Left)); } _ref = _slots[_pos]; break; case SwipeDirection.Up: _ref.prev(); onSuccessSwipe(this,new Swipe(SwipeDirection.Up)); break; } }
public SwipeProgressEventArgs(SwipeDirection direction, double cumulative, double delta, double currRate) { SwipeDirection = direction; Cumulative = cumulative; CurrentRate = currRate; Delta = delta; }
void Start() { swipeDir = SwipeDirection.sNone; if(Application.platform == RuntimePlatform.Android) { TouchEnabled = true; } }
public void resetWithTouch( Touch touch ) { // Initialize the detectionState only with the swipe types we want to listen for swipeDetectionState = swipesToDetect; startPoint = touch.position; startTime = Time.time; swipeDetectionStatus = SwipeDetectionStatus.Waiting; }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = SwipeDetector.SwipeDirection.None; lastSwipeTime = 0; couldBeSwipe = true; startPos = touch.position; startTime = Time.time; break; case TouchPhase.Moved: float dist = Mathf.Abs(touch.position.x - startPos.x); float strayed = dist / Mathf.Abs(touch.position.y - startPos.y); if (strayed < comfortZone && dist > 20.0f) { Debug.Log("Not a swipe. Swipe strayed" + strayed + "amount."); couldBeSwipe = false; } break; case TouchPhase.Ended: if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = touch.position.x - startPos.x; if ((swipeTime < maxSwipeTime) && (Mathf.Abs(swipeDist) > minSwipeDist)) { // It's a swiiiiiiiiiiiipe! float swipeValue = Mathf.Sign(swipeDist); // If the swipe direction is positive, it was an upward swipe. if (swipeValue > 0) { lastSwipe = SwipeDetector.SwipeDirection.Right; Right(); } else if (swipeValue < 0) { lastSwipe = SwipeDetector.SwipeDirection.Left; Left(); } // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); } } break; } } }
public SwipeDetectionStatus swipeDetectionStatus; // Current status of the detector public TouchInfo( SwipeDirection swipesToDetect ) { this.swipesToDetect = swipesToDetect; startPoint = Vector2.zero; startTime = 0.0f; swipeDetectionState = SwipeDirection.Horizontal; completedSwipeDirection = 0; swipeDetectionStatus = SwipeDetectionStatus.Waiting; }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = SwipeDirection.None; lastSwipeTime = 0; couldBeSwipe = true; startPos = touch.position; startTime = Time.time; break; case TouchPhase.Moved: if (Mathf.Abs(touch.position.x - startPos.x) > comfortZone) { Debug.Log("Not a swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.x - startPos.x) + "px which is " + (int)(Mathf.Abs(touch.position.x - startPos.x) - comfortZone) + "px outside the comfort zone."); couldBeSwipe = false; } break; case TouchPhase.Ended: if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = (new Vector3(0, touch.position.y, 0) - new Vector3(0, startPos.y, 0)).magnitude; if ((swipeTime < maxSwipeTime) && (swipeDist > minSwipeDist)) { // It's a swiiiiiiiiiiiipe! float swipeValue = Mathf.Sign(touch.position.y - startPos.y); // If the swipe direction is positive, it was an upward swipe. // If the swipe direction is negative, it was a downward swipe. if (swipeValue > 0) lastSwipe = SwipeDirection.Up; else if (swipeValue < 0) lastSwipe = SwipeDirection.Down; // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); GameController.Instance.DoJump(); } } break; } // end of Switch }else { ApplyPCInput(); } // end of if (Input.touchCount > 0) }
public ScreenController(MainWindow window) { this._window = window; this.screenWidth = window.MainCanvas.Width; this.screenHeight = window.MainCanvas.Height; this.swipableWidth = this.screenWidth - this._window.SwipeIcon.Width; this.lastSwipeDirection = SwipeDirection.CENTER; this.initializeMediaElements(); }
private void HandleOnSwipe (SwipeDirection obj) { if (obj == SwipeDirection.Left) { ReloadTimeline(); } if (obj == SwipeDirection.Right) { ReloadTimeline(); } }
void Start() { SwipeGesture.OnSwipeEvent += (SwipeDirection swipeDirection, Vector2 direction, float degreeAngle, float radianAngle, float radius) => { actualSwipeDirection = swipeDirection; actualDirection = direction; actualDegreeAngle = degreeAngle; actualRadianAngle = radianAngle; actualRadius = radius; OnSwipe.Invoke(); }; }
/// <summary> /// Turning the last selected group to the right or left is performed /// </summary> public void Swipe(SwipeDirection _swipdir) { if (isBusy || !selectData.isSelected || selectData.LastSelected.Count <= 0) { return; } isBusy = true; float rotationfactor = (_swipdir == SwipeDirection.Left ? -1 : 1) * (360 / selectData.LastSelected.Count); Transform rotcenter = GameManager.instance.runtimeVars.selectionCenter; selectData.LastSelected.ForEach(ro => ro.transform.SetParent(rotcenter.transform)); GameManager.instance.runtimeVars.lastMovesTemp = this; IEnumerator rotate() { bool issliced = false; for (int i = 0; i < selectData.LastSelected.Count; i++) { AudioManager.PlayOneShotAudio("swipe"); List <System.Tuple <Vector2, Vector3> > ObjectPositions = selectData.LastSelected.ConvertAll(x => new System.Tuple <Vector2, Vector3>(x.gridIndex, x.transform.position)); selectData.LastSelected.SlideListOneStep(_swipdir == SwipeDirection.Left); Vector3 rot = rotcenter.transform.eulerAngles + new Vector3(0, 0, rotationfactor); rotcenter.transform.DORotate(rot, 0.2f); yield return(new WaitForSeconds(0.2f)); for (int k = 0; k < ObjectPositions.Count; k++) { selectData.LastSelected[k].gridIndex = ObjectPositions.Find(x => Vector3.Distance(x.Item2, selectData.LastSelected[k].transform.position) < 0.1f).Item1; } if (DestructionControl()) { issliced = true; Deselect(); break; } } if (!issliced) { isBusy = false; } else { GameManager.instance.SetMoves(GameManager.instance.runtimeVars.movesCount + 1); } } rotate().InvokeIE(); }
public void SwipeCards() { foreach (var player in Players) { (_swipeDirection == SwipeDirection.RIGHT ? player.RightPlayerData : player.LeftPlayerData).GiveCards(player.InHandCards); } _swipeDirection = _swipeDirection == SwipeDirection.RIGHT ? SwipeDirection.LEFT : SwipeDirection.RIGHT; }
private IEnumerator RotationSequence(SwipeDirection swipeDirection, Vector2 swipeOrigin) { _rotationSequenceActive = true; _groupHighlighter.gameObject.SetActive(false); var rotationDirection = CalculateRotationDirection(swipeDirection, SelectedGroup.Center, swipeOrigin); yield return(_rotationSequenceHandler.RotateSequence(rotationDirection)); ActionSequenceCompleted?.Invoke(); _groupHighlighter.gameObject.SetActive(true); _rotationSequenceActive = false; }
private void UpdateSwipe(Vector3 delta, float deltaMagnitude, SwipeDirection direction) { if (deltaMagnitude > SWIPE_COMMIT_THRESHOLD) { LifeCycle.HandleInput(new Move(_swipeStartCell.Column, _swipeStartCell.Row, GetMoveInputFromDelta(delta, direction))); ResetSwipe(); } else { //LifeCycle.FakeSwipe(new Move(_swipeStartCell.Column, _swipeStartCell.Row, GetMoveInputFromDelta(delta, direction)), // deltaMagnitude); } }
public SwipeDirection removeNext() { if (this.getCurHealth() <= 0) { return(SwipeDirection.NONE); } SwipeDirection res = swipeList.Dequeue(); sequence.doSequenceAnimation(res, true); this.getNextDirection(); return(res); }
void StartSwipe() { this.swipeDirection = (transform.position.x > startPosition.x) ? SwipeDirection.Right : SwipeDirection.Left; this.targetPosition = this.startPosition; if (this.swipeDirection == SwipeDirection.Left) { this.targetPosition.x -= this.startPosition.x + Screen.width * 0.7f; } else { this.targetPosition.x += this.startPosition.x + Screen.width * 0.7f; } }
// ----------------------- TOUCH & MOUSE CONTROLLER ------------------------ public SwipeDirection getSwipeDirection() { if (sSwipeDirection != SwipeDirection.Null) { var etempSwipeDirection = sSwipeDirection; sSwipeDirection = SwipeDirection.Null; return(etempSwipeDirection); } else { return(SwipeDirection.Null); } }
void OnMouseUp() { // We get the camera to cancel the Z vector and ScreenToWorldPoint returns distances in the same Z value float cameraZPos = Camera.main.transform.position.z; finalTouchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0f, 0f, -cameraZPos)); if (OnMouseOverItemEventHandler != null) { SwipeDirection direction = InputHelpers.GetSwipeDirection(new Vector2(x, y), finalTouchPosition, 0.5f); OnMouseOverItemEventHandler(this, direction); } }
private void _multiStepProcessHorizontal_WillTransition(object sender, UIPageViewControllerTransitionEventArgs e) { var pendingStep = e.PendingViewControllers.FirstOrDefault() as IMultiStepProcessStep; if (pendingStep == null) { return; } _swipeDirection = pendingStep.StepIndex > _pageControl.CurrentPage ? SwipeDirection.Forward : SwipeDirection.Backward; }
public override void ActionTrigger(SwipeDirection direction, SwipeConfig config, AnimationCallback beginTriggerCallback, Action triggerCompleteCallback) { var targetX = config.Direction == SwipeDirection.Left ? config.ItemActualWidth : -config.ItemActualWidth; var clipScaleX = config.ItemActualWidth / config.CurrentSwipeWidth; beginTriggerCallback?.Invoke(config.EasingFunc, targetX, config.Duration); DisplayAnimation(config, targetX, clipScaleX, () => { triggerCompleteCallback?.Invoke(); config.AdjustForNotSwipeFixCompleted(); }); }
private void TriggerSwipe(SwipeDirection direction) { SwipeData data = new SwipeData() { startPosition = startPressPosition, endPosition = endPressPosition, actualSwipe = currentSwipe, swipeDirection = direction }; //Debug.Log(OnSwipe.GetInvocationList().Length); OnSwipe(data); }
private void SendSwipe(SwipeDirection direction) { SwipeData swipeData = new SwipeData() { Direction = direction, StartPosition = fingerDownPosition, EndPosition = fingerUpPosition }; IOTouchSwipeHandler.mInstance.SwipeDetectorHandle(swipeData); //IOTouchSwipeHandler(swipeData); text.text = "fingerUpPosition: " + fingerUpPosition.y + " fingerDownPosition: " + fingerDownPosition.y; }
private float fDistance; //magnitude of distance between two positions // Use this for initialization void Start() { fInitialX = 0.0f; fInitialY = 0.0f; fFinalX = 0.0f; fFinalY = 0.0f; inputX = 0.0f; inputY = 0.0f; iTouchStateFlag = 0; sSwipeDirection = SwipeDirection.Null; }
public void OnCardSwiped(SwipeDirection direction) { try { Index = CardStack.TopIndex - 1; Direction = direction; new Handler(Looper.MainLooper).Post(new Runnable(Run)); } catch (Exception e) { Console.WriteLine(e); } }
private void CallEventOnGesture(SwipeDirection swipeDirection) { GestureStackLayout qestureStackLayout = (GestureStackLayout)Element; if (swipeDirection == SwipeDirection.Left) { qestureStackLayout.OnSwipeLeft(); } else { qestureStackLayout.OnSwipeRight(); } }
public SwipeDirection GetSwipeDirection() // to be used by Update() { if (swipeDirection != SwipeDirection.Null) //if a swipe is detected { SwipeDirection etempSwipeDirection = swipeDirection; swipeDirection = SwipeDirection.Null; return(etempSwipeDirection); } else { return(SwipeDirection.Null);//if no swipe was detected } }
internal async void OnSwiped(SwipeDirection swipeDirection) { await Task.Delay(1); if (isGestureStarted) { return; } var state = ResolveSwipeState(swipeDirection == SwipeDirection.Right); UpdateState(state, true); }
private void OnSwipe(SwipeDirection direction) { if (direction == SwipeDirection.LeftToRight && !_drawerOpen) { _drawerOpen = true; StateHasChanged(); } else if (direction == SwipeDirection.RightToLeft && _drawerOpen) { _drawerOpen = false; StateHasChanged(); } }
void Pan() { swipeDirection = SwipeDirection.None; // Calculate Distance GetPanData(); // limit initial movment with a rqadius. // If the distance is smaller do nothing if (radius >= swipeResistanceRadius) { // Check direction of swipe by angle CheckAngle(); } }
/// <summary> /// Initializes a new instance of the <see cref="PlatformSwipeRecognizer{TView}"/> class. /// </summary> /// <param name="view">The native view.</param> /// <param name="directionMask">The direction mask.</param> /// <param name="numberOfTouchesRequired">The number of touches required.</param> /// <param name="threshold">Optional threshold in pixels before a swipe is detected.</param> protected PlatformSwipeRecognizer(TView view, SwipeDirection directionMask, int numberOfTouchesRequired, int threshold = Defaults.Threshold) : base(view, numberOfTouchesRequired) { if (threshold < Defaults.Threshold) { throw new ArgumentException(nameof(numberOfTouchesRequired), $"Threshold must be greater than {Defaults.Threshold}."); } DirectionMask = directionMask; Threshold = threshold; _swipedSubject = new Subject <SwipeDirection>(); Swiped = _swipedSubject.AsObservable(); }
public void ProcessSwipe(SwipeDirection swipe) { Debug.Log(swipe.ToString()); bool moveMadeThisTurn = false; ResetTileMergedFlags(); for (int i = 0; i < rows.Count; i++) { switch (swipe) { case SwipeDirection.Down: while (ShiftByOneIndexUp(columns[i])) { moveMadeThisTurn = true; } break; case SwipeDirection.Up: while (ShiftByOneIndexDown(columns[i])) { moveMadeThisTurn = true; } break; case SwipeDirection.Left: while (ShiftByOneIndexDown(rows[i])) { moveMadeThisTurn = true; } break; case SwipeDirection.Right: while (ShiftByOneIndexUp(rows[i])) { moveMadeThisTurn = true; } break; } } if (moveMadeThisTurn)//Generate a new tile only after a move is made successfully { UpdateEmptyTiles(); GenerateRandomTile(); if (!IsMovePossible())//Trigger Game over if no moves are possible { GameOver(); } } }
public void OnChangeDirection(SwipeDirection direction) { leftAvailable = true; rightAvailable = true; if (Swipe.state != SwipeState.DRAG || !gameObject.activeSelf) { return; } //if (this.me == false) // return; List <ConditionData> _conditions = null; if (me == true) { _conditions = direction == SwipeDirection.RIGHT ? this.data.right.conditions : this.data.left.conditions; } else { _conditions = direction == SwipeDirection.RIGHT ? this.data.eRight.conditions : this.data.eLeft.conditions; } int time = GameTime.GetTime(); List <ConditionData> conditions = Services.data.GetUnavailableConditions(_conditions, time, false, me); if (conditions.Count == 0) { return; } //sort conditions ConditionData one = conditions.Find(c => c.enemy == false); if (one == null) { return; } if (direction == SwipeDirection.RIGHT) { rightAvailable = false; } else { leftAvailable = false; } OnUnavailableCondition?.Invoke(one); }
public void recievedInput(SwipeDirection direction) { switch (direction) { case SwipeDirection.UP: if (ducking) { ducking = false; } else { if (!inJump) { inJump = true; jumpTimer = maxJumpTime; } } break; case SwipeDirection.RIGHT: currentPlayerLane++; break; case SwipeDirection.DOWN: if (inJump) { inJump = false; } else { if (!ducking) { ducking = true; duckTimer = maxDuckTime; } } break; case SwipeDirection.LEFT: currentPlayerLane--; break; } if ((int)currentPlayerLane > 2) { currentPlayerLane = RoadLane.RIGHT; } if ((int)currentPlayerLane < 0) { currentPlayerLane = RoadLane.LEFT; } }
void Update() { if (Input.GetMouseButtonDown(0)) { mouseDownPos = Input.mousePosition; mouseDownTime = Time.realtimeSinceStartup; } if (Input.GetMouseButton(0)) { GridPosition targetGridPosition = controller.board.WorldPosition2GridPosition(Camera.main.ScreenToWorldPoint(mouseDownPos)); if (targetGridPosition.x == -1 || targetGridPosition.y == -1) { return; } Vector2 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mouseRelPos = mouseWorldPos - (Vector2)Camera.main.ScreenToWorldPoint(mouseDownPos); TileProcessor.inst.ReactToInput(controller, targetGridPosition, mouseRelPos, 0.5f, 0.033f); } if (Input.GetMouseButtonUp(0)) { Vector2 mouseUpPos = Input.mousePosition; float mouseUpTime = Time.realtimeSinceStartup; GridPosition targetGridPosition = controller.board.WorldPosition2GridPosition(Camera.main.ScreenToWorldPoint(mouseDownPos)); Tile targetTile = null; if (controller.board.GridPositionIsWithinBounds(targetGridPosition)) { targetTile = controller.board.Tiles[targetGridPosition.x][targetGridPosition.y]; } if (CheckSwipeOccoured(mouseDownPos, mouseUpPos, mouseDownTime, mouseUpTime, 40f, float.MaxValue)) { Vector2 dir = mouseUpPos - mouseDownPos; SwipeDirection swipeDir = VectorToSwipeDirection(dir); if (swipeDir != SwipeDirection.NONE && targetTile != null) { controller.PerformTileMove(targetTile, swipeDir); } } else if (targetTile != null) { controller.MoveTileToItsGridPosition(targetTile); } } }
/* * Checks the move made */ private IEnumerator CheckMoveMade_Cor() { yield return(new WaitForSeconds(gameBoard.GetDestructionWaitTime())); // Handle Avatar Tile Move if (tileType == TileType.Avatar) { matchesManager.MatchAvatarTile(otherTile); hasMatched = true; } else if (otherTile.GetComponent <GameTileBase>().GetTileType() == TileType.Avatar) { matchesManager.MatchAvatarTile(gameObject); otherTile.GetComponent <GameTileBase>().SetHasMatched(true); } // Handle other tile types if (otherTile) { // Changes tile location // When no match is found if (!hasMatched && !otherTile.GetComponent <GameTileBase>().hasMatched) { otherTile.GetComponent <GameTileBase>().currentCol = currentCol; otherTile.GetComponent <GameTileBase>().currentRow = currentRow; currentCol = previousCol; currentRow = previousRow; yield return(new WaitForSeconds(gameBoard.GetDestructionWaitTime())); gameBoard.currentTile = null; gameBoard.currentPlayerState = PlayerState.Active; } // When match is found else { // Changes moves made/left if (scoreManager) { scoreManager.ChangeMovesCounter(); } gameBoard.MatchedCoroutine(); } swipeDirection = SwipeDirection.None; swipeAngle = 0; otherTile = null; } }
private void DetectSwipe() { if (isSwipeDetected()) { if (isVerticalSwipe()) { SwipeDirection direction = fingerDownPosition.y - fingerUpPosition.y > 0 ? SwipeDirection.Up : SwipeDirection.Down; } else { SwipeDirection direction = fingerDownPosition.x - fingerUpPosition.x > 0 ? SwipeDirection.Right : SwipeDirection.Left; } } }
private void UpdateControls() { // Swipe Controls SwipeDirection direction = GameGlobals.Instance.touchController.getSwipeDirection(); //get the swipe direction if (direction != SwipeDirection.Null) { if (direction == SwipeDirection.Up) { HandleSwipe(SwipeDirection.Up); } if (direction == SwipeDirection.Down) { HandleSwipe(SwipeDirection.Down); } if (direction == SwipeDirection.Left) { HandleSwipe(SwipeDirection.Left); } if (direction == SwipeDirection.Right) { HandleSwipe(SwipeDirection.Right); } } // Keyboard Controls if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))//Up/ jump { HandleSwipe(SwipeDirection.Up); } else if ((Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))) { HandleSwipe(SwipeDirection.Down); } else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))//Left { HandleSwipe(SwipeDirection.Right); } else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))//Right { HandleSwipe(SwipeDirection.Left); } if (Input.GetButtonDown("Fire1")) { CharacterObstacle.onClick(player.transform.position); } }
private Tuple <int, int, nfloat> ProgressiveIndicatorData(uint virtualPage) { var count = ViewControllers.Count(); int fromIndex = (int)CurrentIndex; int toIndex = (int)CurrentIndex; SwipeDirection direction = SwipeDirection; if (direction == SwipeDirection.Left) { if (virtualPage > count - 1) { fromIndex = count - 1; toIndex = count; } else { if (ScrollPercentage >= 0.5) { fromIndex = Math.Max(toIndex - 1, 0); } else { toIndex = fromIndex + 1; } } } else if (direction == SwipeDirection.Right) { if (virtualPage < 0) { fromIndex = 0; toIndex = -1; } else { if (ScrollPercentage > 0.5) { fromIndex = Math.Min(toIndex + 1, count - 1); } else { toIndex = fromIndex - 1; } } } var scrollPercentage = PagerBehaviour.ElasticIndicatorLimit == true ? ScrollPercentage : ((toIndex < 0 || toIndex >= count) ? 0.0 : ScrollPercentage); return(new Tuple <int, int, nfloat>(fromIndex, toIndex, new nfloat(scrollPercentage))); }
/* * FUNCTION: Return swipe direction. * RETURNS: Returns NULL if no swipes are detected. * Returns SwipeDirection if a swipe is detected */ public SwipeDirection getSwipeDirection() { if (sSwipeDirection != SwipeDirection.Null) //if a swipe is detected { var etempSwipeDirection = sSwipeDirection; sSwipeDirection = SwipeDirection.Null; return(etempSwipeDirection); } else { return(SwipeDirection.Null); //if no swipe was detected } }
public Swaper Swap(SwipeDirection direction, float x, float y) { if (!swaping && IsEnabled) { X = x; Y = y; SwipeDirection = direction; swaping = true; OnSwap?.Invoke(this); swaping = false; } return(this); }
StackPanel Getpanel(object sender, SwipeDirection direction) { var llmItem = sender as LLMListViewItem; StackPanel panel = null; if (direction == SwipeDirection.Right) { panel = llmItem.GetSwipeControl<StackPanel>(direction, "RightPanel"); } else { panel = llmItem.GetSwipeControl<StackPanel>(direction, "LeftPanel"); } return panel; }
public void OnSwipe(SwipeDirection sd) { if(sd == SwipeDirection.Up) { IncreaseAcceleration(); } if(sd == SwipeDirection.Left) { inputTilt = -1f; tiltBackToDefault = 0.0f; } if(sd == SwipeDirection.Right) { inputTilt = 1f; tiltBackToDefault = 0.0f; } }
void ApplyPCInput() { if (Input.GetMouseButtonDown(0)){ lastSwipe = SwipeDirection.None; lastSwipeTime = 0; couldBeSwipe = true; startPos = Input.mousePosition; startTime = Time.time; } if (couldBeSwipe && Mathf.Abs(Input.mousePosition.x - startPos.x) > comfortZone) { Debug.Log("Not a swipe. Swipe strayed " + (int)Mathf.Abs(Input.mousePosition.x - startPos.x) + "px which is " + (int)(Mathf.Abs(Input.mousePosition.x - startPos.x) - comfortZone) + "px outside the comfort zone."); couldBeSwipe = false; } if (Input.GetMouseButtonUp(0)){ if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = (new Vector3(0, Input.mousePosition.y, 0) - new Vector3(0, startPos.y, 0)).magnitude; if ((swipeTime < maxSwipeTime) && (swipeDist > minSwipeDist)) { // It's a swiiiiiiiiiiiipe! float swipeValue = Mathf.Sign(Input.mousePosition.y - startPos.y); // If the swipe direction is positive, it was an upward swipe. // If the swipe direction is negative, it was a downward swipe. if (swipeValue > 0) lastSwipe = SwipeDirection.Up; else if (swipeValue < 0) lastSwipe = SwipeDirection.Down; // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); } } } }
// Update is called once per frame void Update() { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (Input.GetTouch(0).phase) { case TouchPhase.Began: Debug.Log("Touch Begin"); triggerSwipe = true; startTouchPos = touch.position; break; case TouchPhase.Moved: break; case TouchPhase.Ended: Debug.Log("Touch Ended"); float distance = Vector2.Distance(startTouchPos, touch.position); Debug.Log("Distance "+distance); float pointX = (touch.position.x - startTouchPos.x); Debug.Log("point X "+pointX); if(pointX>0) { swipeType = SwipeDirection.right; Debug.Log("Moving Right---->"); } else if(pointX<0){ swipeType = SwipeDirection.left; Debug.Log("Moving Left---->"); } break; } } if (swipeType == SwipeDirection.left) { transform.Translate (-20, 20, 0); } else if (swipeType == SwipeDirection.right) { transform.Translate (20, 20, 0); } }
/// base constructor /// @param timeToHoldPose the time the user is required to hold the pose. /// @param maxMoveSpeed the maximum speed (in mm/sec) allowed for each of the relevant joints. /// @param angleTolerance This is the allowed tolerance in degrees /// @param timeToSavePoints the time we use to average points public SwipeGestureDetector(SwipeDirection direction, bool useRightHand, float swipeMinimalLength, float swipeMaximalHeight, int swipeMininalDuration, int swipeMaximalDuration, float detectionThreshHold) { m_swipeDirection = direction; m_useRightHand = useRightHand; m_swipeMinimalLength = swipeMinimalLength; m_swipeMaximalHeight = swipeMaximalHeight; m_swipeMininalDuration = swipeMininalDuration; m_swipeMaximalDuration = swipeMaximalDuration; m_detectionThreshHold = detectionThreshHold; m_maxMoveSpeed = 100f; m_timeToHoldPose = 1f; m_timeToSavePoints = 0.5f; m_holdingPose = false; m_timeDetectedPose = 0; m_firedEvent = false; m_pointsHand = new TimedPointList(15); m_pointsTorso = new NITimedPointSpeedListUtility (m_timeToSavePoints); //m_pointsElbow = new NITimedPointSpeedListUtility(timeToSavePoints); //m_pointsShoulder = new NITimedPointSpeedListUtility(timeToSavePoints); }
// Use this for initialization void Start() { swipeType = SwipeDirection.None; }
private bool checkForSwipeCompletion( TKLTouch touch ) { // if we have a time stipulation and we exceeded it stop listening for swipes if( timeToSwipe > 0.0f && ( Time.time - _startTime ) > timeToSwipe ) { return false; } // when dealing with standalones (non touch-based devices) we need to be careful what we examaine // we filter out all touches (mouse movements really) that didnt move #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL if( touch.deltaPosition.x != 0.0f || touch.deltaPosition.y != 0.0f ) { #endif // check the delta move positions. We can rule out at least 2 directions if( touch.deltaPosition.x > 0.0f ) _swipeDetectionState &= ~SwipeDirection.Left; if( touch.deltaPosition.x < 0.0f ) _swipeDetectionState &= ~SwipeDirection.Right; if( touch.deltaPosition.y < 0.0f ) _swipeDetectionState &= ~SwipeDirection.Up; if( touch.deltaPosition.y > 0.0f ) _swipeDetectionState &= ~SwipeDirection.Down; #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL } #endif //Debug.Log( string.Format( "swipeStatus: {0}", swipeDetectionState ) ); // Grab the total distance moved in both directions var xDeltaAbsCm = Mathf.Abs( _startPoint.x - touch.position.x ) / TouchKitLite.instance.screenPixelsPerCm; var yDeltaAbsCm = Mathf.Abs( _startPoint.y - touch.position.y ) / TouchKitLite.instance.screenPixelsPerCm; // only check for swipes in directions that havent been ruled out yet // left check if( ( _swipeDetectionState & SwipeDirection.Left ) != 0 ) { if( xDeltaAbsCm > _minimumDistance ) { if( yDeltaAbsCm < _allowedVariance ) { completedSwipeDirection = SwipeDirection.Left; swipeVelocity = xDeltaAbsCm / ( Time.time - _startTime ); return true; } // We exceeded our variance so this swipe is no longer allowed _swipeDetectionState &= ~SwipeDirection.Left; } } // right check if( ( _swipeDetectionState & SwipeDirection.Right ) != 0 ) { if( xDeltaAbsCm > _minimumDistance ) { if( yDeltaAbsCm < _allowedVariance ) { completedSwipeDirection = SwipeDirection.Right; swipeVelocity = xDeltaAbsCm / ( Time.time - _startTime ); return true; } // We exceeded our variance so this swipe is no longer allowed _swipeDetectionState &= ~SwipeDirection.Right; } } // up check if( ( _swipeDetectionState & SwipeDirection.Up ) != 0 ) { if( yDeltaAbsCm > _minimumDistance ) { if( xDeltaAbsCm < _allowedVariance ) { completedSwipeDirection = SwipeDirection.Up; swipeVelocity = yDeltaAbsCm / ( Time.time - _startTime ); return true; } // We exceeded our variance so this swipe is no longer allowed _swipeDetectionState &= ~SwipeDirection.Up; } } // down check if( ( _swipeDetectionState & SwipeDirection.Down ) != 0 ) { if( yDeltaAbsCm > _minimumDistance ) { if( xDeltaAbsCm < _allowedVariance ) { completedSwipeDirection = SwipeDirection.Down; swipeVelocity = yDeltaAbsCm / ( Time.time - _startTime ); return true; } // We exceeded our variance so this swipe is no longer allowed _swipeDetectionState &= ~SwipeDirection.Down; } } return false; }
public KinectSwipeEventArgs(SwipeDirection swipedirection) { this.swipedirection = swipedirection; }
public SwipeEventArgs(Vector2 endPoint, float swipeSpeed, Vector2 tapPoint, SwipeDirection swipeDirection) { this.endPoint = endPoint; this.swipeSpeed = swipeSpeed; this.tapPoint = tapPoint; this.swipeDirection = swipeDirection; }
public void SwipeDirectionChange(SwipeDirection direction) { swipeDirectionModifier = (direction == SwipeDirection.Forward) ? 1f : -1f; }
internal SwipeGesture (GestureState state, Vector2 point, Vector2 surfacePoint, SwipeDirection direction) : base(state, point, surfacePoint) { this.Direction = direction; }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = SwipeDetector.SwipeDirection.None; lastSwipeTime = 0; startPos = touch.position; startTime = Time.time; couldBeSwipe = true; if(!VerifIfCube(startPos)) { couldBeSwipe = false; return; } break; case TouchPhase.Moved: if (Mathf.Abs(touch.position.y - startPos.y) > comfortZone) { Debug.Log("Not a swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.y - startPos.y) + "px which is " + (int)(Mathf.Abs(touch.position.y - startPos.y) - comfortZone) + "px outside the comfort zone."); couldBeSwipe = false; } break; case TouchPhase.Ended: if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = (new Vector3(0, touch.position.x, 0) - new Vector3(0, startPos.x, 0)).magnitude; if ((swipeTime < maxSwipeTime) && /*||*/ (swipeDist > minSwipeDist)) { // It's a swiiiiiiiiiiiipe! float swipeValue = Mathf.Sign(touch.position.x - startPos.x); // If the swipe direction is positive, it was an upward swipe. // If the swipe direction is negative, it was a downward swipe. if (swipeValue > 0) { lastSwipe = SwipeDetector.SwipeDirection.Left; clickedCube.SwipteType(true); } else if (swipeValue < 0) { lastSwipe = SwipeDetector.SwipeDirection.Right; clickedCube.SwipteType(false); } // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); }else { Debug.Log ("Create a wave"); clickedCube.CreateWave(); } } couldBeSwipe = false; break; } } }
private void CreateGesture2Finger(EventName message,Vector2 startPosition,Vector2 position,Vector2 deltaPosition, float actionTime, SwipeDirection swipe, float swipeLength,Vector2 swipeVector,float twist,float pinch, float twoDistance){ bool firingEvent = true; Gesture gesture = new Gesture(); gesture.isOverGui = false; // NGui if (enabledNGuiMode && message == EventName.On_TouchStart2Fingers){ gesture.isOverGui = gesture.isOverGui || ( IsTouchOverNGui(twoFinger.position) && IsTouchOverNGui(twoFinger.position)); } gesture.touchCount=2; gesture.fingerIndex=-1; gesture.startPosition = startPosition; gesture.position = position; gesture.deltaPosition = deltaPosition; gesture.actionTime = actionTime; gesture.deltaTime=Time.deltaTime; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = pinch; gesture.twistAngle = twist; gesture.twoFingerDistance = twoDistance; gesture.pickedObject = twoFinger.pickedObject; gesture.pickedCamera = twoFinger.pickedCamera; gesture.isGuiCamera= twoFinger.isGuiCamera; if (autoUpdatePickedObject){ if (message != EventName.On_Drag && message != EventName.On_DragEnd && message != EventName.On_Twist && message != EventName.On_TwistEnd && message != EventName.On_Pinch && message != EventName.On_PinchEnd && message != EventName.On_PinchIn && message != EventName.On_PinchOut){ if (GetTwoFingerPickedObject()){ gesture.pickedObject = pickedObject.pickedObj; gesture.pickedCamera = pickedObject.pickedCamera; gesture.isGuiCamera= pickedObject.isGUI; } else{ twoFinger.ClearPickedObjectData(); } } } gesture.pickedUIElement = twoFinger.pickedUIElement; gesture.isOverGui = twoFinger.isOverGui; if (allowUIDetection && autoUpdatePickedUI){ if (message != EventName.On_Drag && message != EventName.On_DragEnd && message != EventName.On_Twist && message != EventName.On_TwistEnd && message != EventName.On_Pinch && message != EventName.On_PinchEnd && message != EventName.On_PinchIn && message != EventName.On_PinchOut){ if (message == EventName.On_SimpleTap2Fingers) if (GetTwoFingerPickedUIElement()){ gesture.pickedUIElement = pickedObject.pickedObj; gesture.isOverGui = true; } else{ twoFinger.ClearPickedUIData(); } } } // Firing event ? if ((enableUIMode || (enabledNGuiMode && allowUIDetection) ) ){ firingEvent = !gesture.isOverGui; } // Firing event if ( firingEvent){ RaiseEvent(message, gesture); } else if (gesture.isOverGui){ if (message == EventName.On_TouchUp2Fingers){ RaiseEvent(EventName.On_UIElementTouchUp, gesture); } else{ RaiseEvent(EventName.On_OverUIElement, gesture); } } }
private void CreateGesture(int touchIndex,EventName message,Finger finger, SwipeDirection swipe, float swipeLength, Vector2 swipeVector){ bool firingEvent = true; if (autoUpdatePickedUI && allowUIDetection){ finger.isOverGui = IsScreenPositionOverUI( finger.position ); finger.pickedUIElement = GetFirstUIElementFromCache(); } // NGui if (enabledNGuiMode && message == EventName.On_TouchStart){ finger.isOverGui = finger.isOverGui || IsTouchOverNGui(finger.position); } // firing event ? if ((enableUIMode || enabledNGuiMode)){ firingEvent = !finger.isOverGui; } // The new gesture Gesture gesture = finger.GetGesture(); // Auto update picked object if (autoUpdatePickedObject && autoSelect){ if (message != EventName.On_Drag && message != EventName.On_DragEnd && message != EventName.On_DragStart){ if (GetPickedGameObject(finger)){ gesture.pickedObject = pickedObject.pickedObj; gesture.pickedCamera = pickedObject.pickedCamera; gesture.isGuiCamera = pickedObject.isGUI; } else{ gesture.pickedObject = null; gesture.pickedCamera = null; gesture.isGuiCamera = false; } } } gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = 0; gesture.twistAngle = 0; // Firing event if ( firingEvent){ RaiseEvent(message, gesture); } else if (finger.isOverGui){ if (message == EventName.On_TouchUp){ RaiseEvent(EventName.On_UIElementTouchUp, gesture); } else{ RaiseEvent(EventName.On_OverUIElement, gesture); } } }
void Update() { //Reset direction every next frame, after sending the gesture to all script that need it ResetDirection (); //Exit, if no touch detected if (Input.touchCount != 0) { Touch touch = Input.GetTouch(0); switch (touch.phase) { case TouchPhase.Began: startPosition = touch.position; startTime = Time.time; isHorizontalSwipe = false; isVerticalSwipe = false; break; case TouchPhase.Moved: //Define the swipe direction, by calculating the current position to the start position //Is it far enough from the start position, to be considered starying? if (Mathf.Abs(touch.position.y - startPosition.y) > strayThreshold) { isVerticalSwipe = true; } if (Mathf.Abs(touch.position.x - startPosition.x) > strayThreshold) { isHorizontalSwipe = true; } break; case TouchPhase.Ended: //Get the swipe time float swipeTime = Time.time - startTime; //Does the swipe satisfy the minimum swipe time? if(swipeTime <= minimumSwapTime) { //Process horizontal swipe if(isHorizontalSwipe) { //Calculate swipe distance on X axis only float swipeDistance = (new Vector2(touch.position.x, 0) - new Vector2(startPosition.x, 0)).sqrMagnitude; //Does the swipe distance satisfy the minimum swipe distance? if(swipeDistance >= sqrMinimum) { //Calculate the swipe sign + / - float swipeSign = Mathf.Sign(touch.position.x - startPosition.x); //Positive means the swipe is to the right, vice versa. if(swipeSign > 0) swipeDirection = SwipeDirection.right; else swipeDirection = SwipeDirection.left; isReseting = true; } } //Identical to horizontal swipe if (isVerticalSwipe) { float swipeDistance = (new Vector2(0, touch.position.y) - new Vector2(0, startPosition.y)).sqrMagnitude; if(swipeDistance >= sqrMinimum) { float swipeSign = Mathf.Sign(touch.position.y - startPosition.y); if(swipeSign > 0) swipeDirection = SwipeDirection.up; else swipeDirection = SwipeDirection.down; isReseting = true; } } } break; } } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = SwipeDetector.SwipeDirection.None; lastSwipeTime = 0; couldBeHorizontalSwipe = true; couldBeVerticalSwipe = true; startPos = touch.position; startTime = Time.time; break; case TouchPhase.Moved: if (Mathf.Abs(touch.position.x - startPos.x) > comfortZone) { Debug.Log("Not a vertical swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.x - startPos.x) + "px which is " + (int)(Mathf.Abs(touch.position.x - startPos.x) - comfortZone) + "px outside the comfort zone."); couldBeVerticalSwipe = false; } if (Mathf.Abs(touch.position.y - startPos.y) > comfortZone) { Debug.Log("Not a horizontal swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.y - startPos.y) + "px which is " + (int)(Mathf.Abs(touch.position.y - startPos.y) - comfortZone) + "px outside the comfort zone."); couldBeHorizontalSwipe = false; } break; case TouchPhase.Ended: if (couldBeVerticalSwipe || couldBeHorizontalSwipe) { float swipeTime = Time.time - startTime; float swipeDistY = (new Vector3(0, touch.position.y, 0) - new Vector3(0, startPos.y, 0)).magnitude; float swipeDistX = (new Vector3(0, touch.position.x, 0) - new Vector3(0, startPos.x, 0)).magnitude; if ((swipeTime < maxSwipeTime) && (swipeDistX > minSwipeDist || swipeDistY > minSwipeDist)) // It's a swiiiiiiiiiiiipe! { if (couldBeVerticalSwipe) // Our swipe is vertical { float swipeValue = Mathf.Sign(touch.position.y - startPos.y); // If the swipe direction is positive, it was an upward swipe. // If the swipe direction is negative, it was a downward swipe. if (swipeValue > 0) lastSwipe = SwipeDetector.SwipeDirection.Up; else if (swipeValue < 0) lastSwipe = SwipeDetector.SwipeDirection.Down; } else if(couldBeHorizontalSwipe) // Our swipe is horizontal { float swipeValue = Mathf.Sign(touch.position.x - startPos.x); // If the swipe direction is positive, it was a rightward swipe. // If the swipe direction is negative, it was a leftward swipe. if (swipeValue > 0) lastSwipe = SwipeDetector.SwipeDirection.Right; else if (swipeValue < 0) lastSwipe = SwipeDetector.SwipeDirection.Left; } // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); } } break; } } }
void Update() { //if (Input.touchCount >1) if ( iPhoneInput.touchCount == 2 ) { Touch touch = Input.touches[1]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = SwipeDetector2.SwipeDirection.None; lastSwipeTime = 0; couldBeSwipe = true; startPos = touch.position; startTime = Time.time; break; case TouchPhase.Moved: if (Mathf.Abs(touch.position.y - startPos.y) > comfortZone) { Debug.Log("Not a swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.y - startPos.y) + "px which is " + (int)(Mathf.Abs(touch.position.y - startPos.y) - comfortZone) + "px outside the comfort zone."); couldBeSwipe = false; } break; case TouchPhase.Ended: if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = (new Vector3(touch.position.x, 0, 0) - new Vector3(startPos.x, 0, 0)).magnitude; if ((swipeTime < maxSwipeTime) && (swipeDist > minSwipeDist)) { // It's a swiiiiiiiiiiiipe! float swipeValue = Mathf.Sign(touch.position.x - startPos.x); // If the swipe direction is positive, it was an upward swipe. // If the swipe direction is negative, it was a downward swipe. //if (swipeValue > 0) // lastSwipe = SwipeDetector.SwipeDirection.Up; //else if (swipeValue < 0) // lastSwipe = SwipeDetector.SwipeDirection.Down; // Set the time the last swipe occured, useful for other scripts to check: lastSwipeTime = Time.time; Debug.Log("Found a swipe! Direction: " + lastSwipe); { Vector3 position = transform.position; position.x = Mathf.Clamp(position.x, 0f, 10f); transform.position = position; } } } break; } } }
// Swipe callback public void onSwipe( UISwipeDetector sender, SwipeDirection direction ) { swipeText.text = direction.ToString(); }
// Do Graphic & Input updates here void Update() { if(dead) { deathCooldown -= Time.deltaTime; if(deathCooldown <= 0) { AutoFade.LoadLevel("EndMenu" ,0.5f,0.5f,Color.white); } } else { /*if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) ) { didFlap = true; }*/ if (Input.touchCount > 0) { Touch touch = Input.touches[0]; switch (touch.phase) { case TouchPhase.Began: lastSwipe = BirdMovement.SwipeDirection.None; lastSwipeTime = 0; couldBeSwipe = true; startPos = touch.position; startTime = Time.time; break; case TouchPhase.Moved: if (Mathf.Abs(touch.position.x - startPos.x) > comfortZone) { Debug.Log("Not a swipe. Swipe strayed " + (int)Mathf.Abs(touch.position.x - startPos.x) + "px which is " + (int)(Mathf.Abs(touch.position.x - startPos.x) - comfortZone) + "px outside the comfort zone."); couldBeSwipe = false; } break; case TouchPhase.Ended: if (couldBeSwipe) { float swipeTime = Time.time - startTime; float swipeDist = (new Vector3(0, touch.position.y, 0) - new Vector3(0, startPos.y, 0)).magnitude; if ((swipeTime < maxSwipeTime) && (swipeDist > minSwipeDist)) { // Swipe GetComponent<AudioSource>().PlayOneShot(swoosh,0.9f); float swipeValue = Mathf.Sign(touch.position.y - startPos.y); // If positive swipe direction = upward swipe. // If negative swipe direction = downward swipe. if (swipeValue > 0){ lastSwipe = BirdMovement.SwipeDirection.Up; didFlap = true; velocityOfSwipe = swipeDist/swipeTime/50; } else if (swipeValue < 0){ lastSwipe = BirdMovement.SwipeDirection.Down; didFlap = true; velocityOfSwipe = -swipeDist/swipeTime/50; } lastSwipeTime = Time.time; } } break; } } } }