Vector2 DetectSwipe(Vector2 deltaVector) { if (Mathf.Abs(deltaVector.x) > Mathf.Abs(deltaVector.y)) //X Axis { if (deltaVector.x > 0) { currentSwipe = SwipeType.Right; } else if (deltaVector.x < 0) { currentSwipe = SwipeType.Left; } } else if (Mathf.Abs(deltaVector.x) < Mathf.Abs(deltaVector.y))//Y Axis { if (deltaVector.y > 0) { currentSwipe = SwipeType.Up; } else if (deltaVector.y < 0) { currentSwipe = SwipeType.Down; } } else { currentSwipe = SwipeType.None; } return(deltaVector); }
bool ChangeState(int touchCount, TouchPhase phase, Vector2 delta) { if (phase == TouchPhase.Ended || touchCount == 0 && swipeTime >= minSwipeTime && delta.magnitude < cancelRadius) // Any -> 0 { // End State currentState = SwipeType.None; } else if ((int)currentState == touchCount) // X -> X (X!=0) { // Keep State swipeTime += Time.deltaTime; cancelTimeout = 0; } else if (phase == TouchPhase.Began && currentState == SwipeType.None && touchCount > 0) // 0 -> X (X!=0) { // Begin State currentState = (SwipeType)touchCount; swipeTime = 0; } else // X -> Y (X!=0, Y!=0) { // Cancel State if (cancelTimeout > timeToCancelTimeout) { currentState = SwipeType.None; return(true); } cancelTimeout += Time.deltaTime; } return(false); }
public void OnEndDrag(PointerEventData eventData) { _finalSwipeTime = Time.time; if (Mathf.Abs(_finalSwipeTime - _initialSwipeTime) > SwipeMaxDuration) { return; } _finalSwipePoint = eventData.pointerCurrentRaycast.worldPosition; _diffPoint = _finalSwipePoint - _initialSwipePoint; _diffPoint = new Vector2(Mathf.Abs(_diffPoint.x), Mathf.Abs(_diffPoint.y)); if (_diffPoint.x <= SwipeDeadArea && _diffPoint.y <= SwipeDeadArea) { return; } _type = SwipeType.Free; _direction = SwipeDirection.Free; if (_diffPoint.x > _diffPoint.y) { _type = SwipeType.Horizontal; _direction = _finalSwipePoint.x > _initialSwipePoint.x ? SwipeDirection.Right : SwipeDirection.Left; } else { _type = SwipeType.Vertical; _direction = _finalSwipePoint.y > _initialSwipePoint.y ? SwipeDirection.Up : SwipeDirection.Down; } SendOnSwipeCompleted(_type, _direction); }
private static void SampleUsingSwipeType(SwipeType swipeType) { Stopwatch stopwatch = new Stopwatch(); string[] testCases = { "heqerqllo", "qwertyuihgfcvbnjk", "wertyuioiuytrtghjklkjhgfd", "dfghjioijhgvcftyuioiuytr", "aserfcvghjiuytedcftyuytre", "asdfgrtyuijhvcvghuiklkjuytyuytre", "mjuytfdsdftyuiuhgvc", "vghjioiuhgvcxsasdvbhuiklkjhgfdsaserty" }; foreach (var s in testCases) { stopwatch.Start(); var result = swipeType.GetSuggestion(s, 10); stopwatch.Stop(); stopwatch.Reset(); int length = result.Length; for (int i = 0; i < length; ++i) { i = i; //Console.WriteLine($"match {i + 1}: {result[i]}"); } } }
void SwipeHappened(SwipeType type) { foreach(Action<SwipeType> action in SwipeEvents) { action(type); } isSwipe = false; }
/// <summary> /// Either pass or like a user /// </summary> /// <param name="type">Pass or Like</param> /// <param name="user_id">The id of the user to perform the action on</param> /// <returns>UserLikeStatus Object</returns> public async Task <UserLikeStatus?> SwipeAsync(SwipeType type, ulong user_id) { var obj = new CardActionPayload() { Votes = new List <ProfileVote>() { new ProfileVote() { IsLike = type == SwipeType.Like, UserId = user_id } } }; var req = new HttpRequestMessage(HttpMethod.Post, new Uri($"{this.BaseAddress}/likes/batch")) { Content = new StringContent(JsonConvert.SerializeObject(obj)) }; var res = await this.Http.SendAsync(req).ConfigureAwait(false); var cont = await res.Content.ReadAsStringAsync().ConfigureAwait(false); if (res.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <UserLikeStatus>(cont)); } else { return(null); } }
/// <summary> /// Triggered when player swipes /// </summary> /// <param name="type"></param> private void DoSwipe(SwipeType type) { _swiping = false; if (OnSwipe != null) { OnSwipe(type); } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); switch (touch.phase) { case TouchPhase.Began: initPosition = touch.position; isDragging = true; break; case TouchPhase.Canceled: isDragging = false; break; case TouchPhase.Ended: endPosition = touch.position; swipeDirection = (endPosition - initPosition); if (swipeDirection.magnitude > 50f) { swipeAngle = Vector2.SignedAngle(Vector2.right, swipeDirection); if (swipeAngle < 0) { swipeAngle = swipeAngle + 360; } isFacingRight = CharacterMovement.GetIsFacingRight(); mostRecentSwipeType = SwipeTypeOfAngle(swipeAngle, isFacingRight); string mostRecentInput = mostRecentSwipeType == SwipeType.swipeDown ? "Down" : mostRecentSwipeType == SwipeType.swipeBackwards ? "Backwards" : mostRecentSwipeType == SwipeType.swipeForwardUp ? "Forward" : "Unknown input"; if (inputText != null) { inputText.text = (intoTextString + mostRecentInput + " " + swipeAngle); } //Might have to make this a switch-case: if (GameManager.GetGameState() == GameStateScriptableObject.GameState.mainGameplayLoop) { onSwipeEvent.Raise(); } if (GameManager.GetGameState() == GameStateScriptableObject.GameState.cinematic) { onSwipeInCinematicEvent.Raise(); } } else if (timeDragged < 0.125f) { onClickEvent.Raise(); } isDragging = false; break; } timeDragged = isDragging ? timeDragged += Time.deltaTime : 0; } }
public void HandlePanUpdated(GestureData data) { SwipeType swipe = SwipeType.None; OutputLine line = null; Section sect = null; switch (data.status) { case GestureStatus.Started: initialX = data.totalX; initialY = data.totalY; break; case GestureStatus.Running: // Translate and ensure we don't pan beyond the wrapped user interface element bounds. x = data.totalX; y = data.totalY; swipe = this.GetSwipe(); sect = (data.sender as View).Parent.Parent.BindingContext as Section; if (sect != null) { sect.OnDragCmd.Execute(new SwipeAction() { Type = swipe, Finished = false }); } break; case GestureStatus.Completed: swipe = this.GetSwipe(); try { line = (data.sender as View).Parent.Parent.BindingContext as OutputLine; sect = (data.sender as View).Parent.Parent.BindingContext as Section; if (line != null) { line.OnDragCmd.Execute(swipe as object); } else if (sect != null) { sect.OnDragCmd.Execute(new SwipeAction() { Type = swipe, Finished = true }); } } catch (Exception ex) { StoreFactory.CurrentVM.Logs.Add("Swipe exception: " + ex.Message); } break; } }
public void SetMostRecentSwipeType(SwipeType swipeType) { mostRecentSwipeType = swipeType; if (GameManager.GetGameState() == GameStateScriptableObject.GameState.mainGameplayLoop) { onSwipeEvent.Raise(); } if (GameManager.GetGameState() == GameStateScriptableObject.GameState.cinematic) { onSwipeInCinematicEvent.Raise(); } }
void SwipeMethod(SwipeType sw)// determine if user moves car to right or left { int direction = 0; switch (sw) { case SwipeType.RIGHT: endXPos = transform.position.x + 1.5f; direction = +1; break; case SwipeType.LEFT: endXPos = transform.position.x - 1.5f; direction = -1; break; } //endXPos = Mathf.Clamp(endXPos, -3, 3); if (-6 <= endXPos && endXPos <= 6) { transform.DOMoveX(endXPos, 0.15f); for (int i = 0; i < Convoy_List.Count; i++) { if ((Convoy_List[i].transform.position.x + (direction * 1.5f) > 6 || -6 > Convoy_List[i].transform.position.x + (direction * 1.5f))) // if the guards moves out from the road then it will be destroyed { DOTween.Kill(Convoy_List[i].gameObject); // killing the guard Destroy(Convoy_List[i].gameObject); //killing the guard Convoy_List[i] = null; // gameobject which just destroyed, is made equal to null for ease in rearranging the guard array List <GameObject> new_convoy_list = new List <GameObject>(); foreach (var game_obj in Convoy_List) // rearrange the guard array { if (game_obj != null) { new_convoy_list.Add(game_obj); } } Convoy_List.Clear(); Convoy_List = new_convoy_list; } else // if the guard's next position which it tries to go, is not in out of the road, then it will move that position { Convoy_List[i].transform.DOMoveX(Convoy_List[i].transform.position.x + (direction * 1.5f), 0.15f); } } } }
/// <summary> /// Event that gets triggered by the swiping gestures /// </summary> /// <param name="type">Type of swipe up, down, left and right</param> private void OnSwipe(SwipeType type) { switch (type) { case SwipeType.UP: TowerController.Instance.Begin(); _swipeToStart.gameObject.SetActive(false); GestureController.Instance.OnSwipe -= OnSwipe; break; } }
protected override void Swipe(Vector2 from, Vector2 to, SwipeType type) { switch (type) { case SwipeType.left: lane--; break; case SwipeType.right: lane++; break; } }
public void Hitted(HitKey hitKey, SwipeType type) { if (hitKey.Type != type) { Missed(MissType.WrongDirection); } else { TotalPoints += hitKey.points; OnPointsChanged?.Invoke(TotalPoints); OnHit?.Invoke(PointsPercentage); OnHitfeedback?.Play(Vector3.zero); } }
private void InputIncome(SwipeType type) { Collider2D collision = Physics2D.OverlapCircle(HitTransform.position, HitRadius); if (collision == null) { Missed(MissType.NoObject); } else { Hitted(collision.GetComponent <HitKeyComponent>().hitKey, type); Destroy(collision.gameObject); } }
public void ColorRows() { foreach (DataGridViewRow row in dgvAllSwipes.Rows) { SwipeType type = (SwipeType)row.Cells[5].Value; if (type == SwipeType.Access) { row.DefaultCellStyle.BackColor = Color.Yellow; } else if (type == SwipeType.Attendance) { row.DefaultCellStyle.BackColor = Color.YellowGreen; } } }
private void Update() { List <RawInput> Swipes = gestureRecognizer.InputThrottle.Consume(); if (Swipes != null) { //print("Swipe Count: " + Swipes.Count + " Touch Count: " + Input.touchCount + " / prev: " + _inputTouches); OnAnyInput?.Invoke(); foreach (RawInput s in Swipes) { Vector2 startPosition = ScreenToWorldCoordinates(s.StartPosition); Vector2 delta = ScreenToWorldCoordinates(s.Position) - startPosition; SwipeType previousState = currentState; int touchCount = Input.touchCount; #if UNITY_EDITOR touchCount = Convert.ToInt32(Input.GetMouseButton(0)) + Convert.ToInt32(Input.GetMouseButton(1)); #endif bool cancel = ChangeState(touchCount, s.Phase, delta); //print(s.Phase +" | "+ previousState +" -> "+ currentState +" (" +cancel+")"); //if (previousState != currentState) // print(currentState); if (cancel) { InvokeSwipeEvents(previousState, startPosition, delta, TouchPhase.Canceled); } else if (previousState != SwipeType.None && currentState == SwipeType.None) { InvokeSwipeEvents(previousState, startPosition, delta, TouchPhase.Ended); } else if (previousState == SwipeType.None && currentState != SwipeType.None) { InvokeSwipeEvents(currentState, startPosition, delta, TouchPhase.Began); } else if (previousState == currentState) { InvokeSwipeEvents(currentState, startPosition, delta, s.Phase); } } _inputTouches = Input.touchCount; } }
private void DetectSwipe() //decide swipe direction and swipe { swipe = SwipeType.NONE; difference = endPos - startPos; //get the difference if (difference.magnitude > swipeThreshold * Screen.width) //check if magnitude is more than Threshold { if (difference.x > 0) //right swipe { swipe = SwipeType.RIGHT; } else if (difference.x < 0) //left swipe { swipe = SwipeType.LEFT; } } swipeCallback(swipe); //call the event }
public static System.Windows.Input.ICommand GetMoveSectionCmd(CommonBaseVM vm, IOrdered line) { return(new Command((arg) => { line.TimeStamp = DateTime.Now; Task.Factory.StartNew(() => Task.Delay(3000)) .ContinueWith((t, x) => { if ((DateTime.Now.Subtract((x as IOrdered).TimeStamp).TotalSeconds > 3)) { (x as IOrdered).OrderImageName = "empty.png"; } }, line); SwipeAction swipe = (arg as SwipeAction?).Value; SwipeType swipeType = SwipeType.None; if ((swipe.Type & SwipeType.Up) != 0 || (swipe.Type & SwipeType.Left) != 0) { line.OrderImageName = "up.png"; swipeType = SwipeType.Up; } else if ((swipe.Type & SwipeType.Down) != 0 || (swipe.Type & SwipeType.Right) != 0) { line.OrderImageName = "down.png"; swipeType = SwipeType.Down; } else { line.OrderImageName = "empty.png"; } if (swipe.Finished) { vm.Order.MoveOutputLine(line, -1, swipeType); line.OrderImageName = "empty.png"; } vm.RaiseChanges(); })); }
/// <summary> /// Triggered when the player swipes /// </summary> /// <param name="type"></param> private void OnSwipe(SwipeType type) { switch (type) { case SwipeType.UP: float final = 0f; float squaredAcceleration = final - 2 * _gravity * _jumpHeight; _jumpAcceleration = Mathf.Sqrt(squaredAcceleration); break; case SwipeType.LEFT: _direction = -1; break; case SwipeType.RIGHT: _direction = 1; break; } }
void ActionOnSwipe(SwipeType swipeType) //method alled on swipe action of InputManager { if (GameManager.singeton.gameStatus == GameStatus.PLAYING) //is gamestatus is playing { switch (swipeType) { case SwipeType.LEFT: //if we left swipe endXPos = transform.position.x - 3; //change endXPos by 3 to left break; case SwipeType.RIGHT: //if we right swipe endXPos = transform.position.x + 3; //change endXPos by 3 to right break; } endXPos = Mathf.Clamp(endXPos, -3, 3); //clamp endXPos between -3 and 3 transform.DOMoveX(endXPos, 0.15f); //move the car } }
public virtual void MoveOutputLine(IOrdered line, int destinationIndex = -1, SwipeType swipe = SwipeType.Up) { if (destinationIndex == -1) { destinationIndex = swipe == SwipeType.Up ? line.Index - 1 : line.Index + 1; } if (swipe == SwipeType.Up) { this.Lines.Move(line.Index, destinationIndex - (line.Index < destinationIndex ? 1 : 0)); } else if (swipe == SwipeType.Down) { this.Lines.Move(line.Index, destinationIndex + (line.Index < destinationIndex ? 0 : 1)); } this.Reindex(); this.RaiseChanges(); line.LineMoveStatus = MoveStatus.Finished; this.LineForMove = null; }
void ActionOnSwipe(SwipeType sw) { switch (sw) { case SwipeType.RIGHT: if (currentCarIndex > 0) { currentCarIndex--; } break; case SwipeType.LEFT: if (currentCarIndex < LevelManager.instance.vehicleprefabs.Length - 1) { currentCarIndex++; } break; } SelectCarPos(); // will move our car holder to respected car's pos }
/*处理事件*/ void Update() { /*注:如果考虑在手机屏幕滑动,需要使用touch或者第三方插件都可以,这里只是为了简单快速实现功能故使用的Mouse*/ if (Input.GetMouseButtonDown(0)) { mMomentum = Vector2.zero; mMomentumTime = Time.realtimeSinceStartup; mCanMoveMomentum = false; mMomentumDistance = 0.0F; mPreMousePos = Input.mousePosition; if (onDragCameraStart != null) { onDragCameraStart(gameObject); } } else if (Input.GetMouseButton(0)) { UserDrag(Input.mousePosition - mPreMousePos); mSwipeType = GetSwipe(mPreMousePos, Input.mousePosition); mPreMousePos = Input.mousePosition; if (onDragCamera != null) { onDragCamera(gameObject); } } else if (Input.GetMouseButtonUp(0)) { mMomentumTime = Time.realtimeSinceStartup - mMomentumTime; mCanMoveMomentum = true; mPreMousePos = Input.mousePosition; if (onDragCameraEnd != null) { onDragCameraEnd(gameObject); } } }
void ActionOnSwipe(SwipeType swipeType) //method called on swipe action by InputManager { switch (swipeType) { case SwipeType.RIGHT: //if swipeType is right if (currentSelectedCarIndex > 0) //check if currentSelectedCarIndex more than zero { currentSelectedCarIndex--; //reduce the currentSelectedCarIndex by 1 } break; case SwipeType.LEFT: //if swipeType is left //check if currentSelectedCarIndex less than total cars if (currentSelectedCarIndex < LevelManager.instance.VehiclePrefabs.Length - 1) { currentSelectedCarIndex++; //increase the currentSelectedCarIndex by 1 } break; } SetCarHolderPos(); }
void DetectSwipe() // if it is a swipe then decide which direction it occured { swipetype = SwipeType.NONE; difference = endPos - startPos; if (difference.magnitude > swipeThreshold * Screen.width) { if (endPos.x > startPos.x) { swipetype = SwipeType.RIGHT; } else if (startPos.x > endPos.x) { swipetype = SwipeType.LEFT; } } if (swipeCallback != null) { swipeCallback(swipetype); } }
private void SendOnSwipeCompleted(SwipeType type, SwipeDirection direction) { if (!IsActive() || !IsEnabled) { return; } _onSwipe.Invoke(this); if (type == SwipeType.Vertical) { _onVerticalSwipe.Invoke(this); if (direction == SwipeDirection.Up) { _onVerticalSwipeUp.Invoke(this); } if (direction == SwipeDirection.Down) { _onVerticalSwipeDown.Invoke(this); } } if (type == SwipeType.Horizontal) { _onHorizontalSwipe.Invoke(this); if (direction == SwipeDirection.Left) { _onHorizontalSwipeLeft.Invoke(this); } if (direction == SwipeDirection.Right) { _onHorizontalSwipeRight.Invoke(this); } } }
void InvokeSwipeEvents(SwipeType type, Vector2 pos, Vector2 delta, TouchPhase phase) { if (type == SwipeType.Single) { OnSingleSwipeDetails?.Invoke(pos, delta, phase); if (phase == TouchPhase.Ended) { print($"Single Swipe Direction: {InQuadrant(delta)}."); if (OnSingleSwipe) { OnSingleSwipe.Raise(pos, delta, InQuadrant(delta)); } else { Debug.LogError("OnSingleSwipe not assigned."); } } } if (type == SwipeType.Double) { OnDoubleSwipeDetails?.Invoke(pos, delta, phase); if (phase == TouchPhase.Ended) { print($"Double Swipe Direction: {InQuadrant(delta)}."); if (OnDoubleSwipe) { OnDoubleSwipe.Raise(pos, delta, InQuadrant(delta)); } else { Debug.LogError("OnDoubleSwipe not assigned."); } } } }
/// <summary> /// Perform a swipe action (Like, Superlike, Pass) on a user. /// </summary> /// <param name="user_id">User Id</param> /// <param name="type">Swipe Type (Like, Superlike, Pass)</param> /// <param name="locale">Locale</param> /// <returns></returns> public async Task <object> SwipeAsync(string user_id, SwipeType type, string locale = "en-GB") { object ret; switch (type) { case SwipeType.Like: ret = await LikeAsync(user_id, locale).ConfigureAwait(false); break; case SwipeType.Superlike: ret = await SuperLikeAsync(user_id, locale).ConfigureAwait(false); break; default: ret = await PassAsync(user_id, locale).ConfigureAwait(false); break; } return(ret); }
/// <summary> /// Perform a swipe action (Like, Superlike, Pass) on a user. /// </summary> /// <param name="profile">The profile retrieved from calling GetAllCardsAsync()</param> /// <param name="type">Swipe Type (Like, Superlike, Pass)</param> /// <param name="locale">Locale</param> /// <returns></returns> public async Task <object> SwipeAsync(CardProfile profile, SwipeType type, string locale = "en-GB") { var user_id = profile.UserInfo.Id; object ret; switch (type) { case SwipeType.Like: ret = await LikeAsync(user_id, locale).ConfigureAwait(false); break; case SwipeType.Superlike: ret = await SuperLikeAsync(user_id, locale).ConfigureAwait(false); break; default: ret = await PassAsync(user_id, locale).ConfigureAwait(false); break; } return(ret); }
private static void SampleUsingSwipeType(SwipeType swipeType) { Console.WriteLine($"Test {swipeType.GetType()}"); Stopwatch stopwatch = new Stopwatch(); string[] testCases = { "heqerqllo", "qwertyuihgfcvbnjk", "wertyuioiuytrtghjklkjhgfd", "dfghjioijhgvcftyuioiuytr", "aserfcvghjiuytedcftyuytre", "asdfgrtyuijhvcvghuiklkjuytyuytre", "mjuytfdsdftyuiuhgvc", "vghjioiuhgvcxsasdvbhuiklkjhgfdsaserty" }; foreach (var s in testCases) { Console.WriteLine("#===============================#"); Console.WriteLine($"Raw string: {s}"); stopwatch.Start(); var result = swipeType.GetSuggestion(s, 10); stopwatch.Stop(); Console.WriteLine($"Match time: {stopwatch.ElapsedMilliseconds} ms"); stopwatch.Reset(); int length = result.Count(); for (int i = 0; i < length; ++i) { Console.WriteLine($"match {i + 1}: {result.ElementAt(i)}"); } } }
private void CreateGesture2Finger(EventName message,Vector2 startPosition,Vector2 position,Vector2 deltaPosition, float actionTime, SwipeType swipe, float swipeLength,Vector2 swipeVector,float twist,float pinch) { //Creating the structure with the required information Gesture gesture = new Gesture(); gesture.touchCount=2; gesture.fingerIndex=-1; gesture.startPosition = startPosition; gesture.position = position; gesture.deltaPosition = deltaPosition; gesture.actionTime = actionTime; if (fingers[twoFinger0]!=null) gesture.deltaTime = fingers[twoFinger0].deltaTime; else if (fingers[twoFinger1]!=null) gesture.deltaTime = fingers[twoFinger1].deltaTime; else gesture.deltaTime=0; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = pinch; gesture.twistAngle = twist; if (message!= EventName.On_Cancel2Fingers){ gesture.pickObject = pickObject2Finger; } else { gesture.pickObject = oldPickObject2Finger; } gesture.otherReceiver = receiverObject; if (useBroadcastMessage){ SendGesture2Finger(message,gesture ); } else{ RaiseEvent(message, gesture); } }
private bool CreateGesture(EventName message,Finger finger,float actionTime, SwipeType swipe, float swipeLength, Vector2 swipeVector) { //Creating the structure with the required information Gesture gesture = new Gesture(); gesture.fingerIndex = finger.fingerIndex; gesture.touchCount = finger.touchCount; gesture.startPosition = finger.startPosition; gesture.position = finger.position; gesture.deltaPosition = finger.deltaPosition; gesture.actionTime = actionTime; gesture.deltaTime = finger.deltaTime; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = 0; gesture.twistAngle = 0; gesture.pickObject = finger.pickedObject; gesture.otherReceiver = receiverObject; if (useBroadcastMessage){ SendGesture(message,gesture); } if (!useBroadcastMessage || joystickAddon){ RaiseEvent(message, gesture); } return true; }
private void CreateGesture2Finger(EventName message,Vector2 startPosition,Vector2 position,Vector2 deltaPosition, float actionTime, SwipeType swipe, float swipeLength,Vector2 swipeVector,float twist,float pinch, float twoDistance) { if (message == EventName.On_TouchStart2Fingers){ isStartHoverNGUI = IsTouchHoverNGui(twoFinger1) & IsTouchHoverNGui(twoFinger0); } if (!isStartHoverNGUI){ //Creating the structure with the required information Gesture gesture = new Gesture(); gesture.touchCount=2; gesture.fingerIndex=-1; gesture.startPosition = startPosition; gesture.position = position; gesture.deltaPosition = deltaPosition; gesture.actionTime = actionTime; if (fingers[twoFinger0]!=null) gesture.deltaTime = fingers[twoFinger0].deltaTime; else if (fingers[twoFinger1]!=null) gesture.deltaTime = fingers[twoFinger1].deltaTime; else gesture.deltaTime=0; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = pinch; gesture.twistAngle = twist; gesture.twoFingerDistance = twoDistance; if (fingers[twoFinger0] != null){ gesture.pickCamera = fingers[twoFinger0].pickedCamera; gesture.isGuiCamera = fingers[twoFinger0].isGuiCamera; } else if (fingers[twoFinger1] != null){ gesture.pickCamera = fingers[twoFinger1].pickedCamera; gesture.isGuiCamera = fingers[twoFinger1].isGuiCamera; } if (message!= EventName.On_Cancel2Fingers){ gesture.pickObject = pickObject2Finger; } else { gesture.pickObject = oldPickObject2Finger; } gesture.otherReceiver = receiverObject; if (fingers[twoFinger0] != null){ gesture.isHoverReservedArea = IsTouchReservedArea( fingers[twoFinger0].fingerIndex); } if (fingers[twoFinger1] != null){ gesture.isHoverReservedArea = gesture.isHoverReservedArea || IsTouchReservedArea( fingers[twoFinger1].fingerIndex); } if (useBroadcastMessage){ SendGesture2Finger(message,gesture ); } else{ RaiseEvent(message, gesture); } } }
private void CreateGesture(int touchIndex,EventName message,Finger finger,float actionTime, SwipeType swipe, float swipeLength, Vector2 swipeVector) { if (message == EventName.On_TouchStart || message == EventName.On_TouchUp){ isStartHoverNGUI = IsTouchHoverNGui(touchIndex); } //if (message == EventName.On_Cancel || message == EventName.On_TouchUp){ // isStartHoverNGUI = false; //} if (!isStartHoverNGUI){ //Creating the structure with the required information Gesture gesture = new Gesture(); gesture.fingerIndex = finger.fingerIndex; gesture.touchCount = finger.touchCount; gesture.startPosition = finger.startPosition; gesture.position = finger.position; gesture.deltaPosition = finger.deltaPosition; gesture.actionTime = actionTime; gesture.deltaTime = finger.deltaTime; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = 0; gesture.twistAngle = 0; gesture.pickObject = finger.pickedObject; gesture.otherReceiver = receiverObject; gesture.isHoverReservedArea = IsTouchReservedArea( touchIndex); gesture.pickCamera = finger.pickedCamera; gesture.isGuiCamera = finger.isGuiCamera; gesture.hitPoint = finger.hitPoint; //zs if (useBroadcastMessage){ SendGesture(message,gesture); } if (!useBroadcastMessage || isExtension){ RaiseEvent(message, gesture); } } }
private void CreateGesture2Finger(EventName message, Vector2 startPosition, Vector2 position, Vector2 deltaPosition, float actionTime, SwipeType swipe, float swipeLength, Vector2 swipeVector, float twist, float pinch, float twoDistance) { if (message == EventName.On_TouchStart2Fingers) { this.isStartHoverNGUI = this.IsTouchHoverNGui(this.twoFinger1) & this.IsTouchHoverNGui(this.twoFinger0); } if (!this.isStartHoverNGUI) { Gesture gesture = new Gesture(); gesture.touchCount = 2; gesture.fingerIndex = -1; gesture.startPosition = startPosition; gesture.position = position; gesture.deltaPosition = deltaPosition; gesture.actionTime = actionTime; if (this.fingers[this.twoFinger0] != null) { gesture.deltaTime = this.fingers[this.twoFinger0].deltaTime; } else if (this.fingers[this.twoFinger1] != null) { gesture.deltaTime = this.fingers[this.twoFinger1].deltaTime; } else { gesture.deltaTime = 0f; } gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = pinch; gesture.twistAngle = twist; gesture.twoFingerDistance = twoDistance; if (this.fingers[this.twoFinger0] != null) { gesture.pickCamera = this.fingers[this.twoFinger0].pickedCamera; gesture.isGuiCamera = this.fingers[this.twoFinger0].isGuiCamera; } else if (this.fingers[this.twoFinger1] != null) { gesture.pickCamera = this.fingers[this.twoFinger1].pickedCamera; gesture.isGuiCamera = this.fingers[this.twoFinger1].isGuiCamera; } if (message != EventName.On_Cancel2Fingers) { gesture.pickObject = this.pickObject2Finger; } else { gesture.pickObject = this.oldPickObject2Finger; } gesture.otherReceiver = this.receiverObject; if (this.fingers[this.twoFinger0] != null) { gesture.isHoverReservedArea = this.IsTouchReservedArea(this.fingers[this.twoFinger0].fingerIndex); } if (this.fingers[this.twoFinger1] != null) { gesture.isHoverReservedArea = gesture.isHoverReservedArea || this.IsTouchReservedArea(this.fingers[this.twoFinger1].fingerIndex); } if (this.useBroadcastMessage) { this.SendGesture2Finger(message, gesture); } else { this.RaiseEvent(message, gesture); } } }
private void CreateGesture(int touchIndex, EventName message, Finger finger, float actionTime, SwipeType swipe, float swipeLength, Vector2 swipeVector) { if ((message == EventName.On_TouchStart) || (message == EventName.On_TouchUp)) { this.isStartHoverNGUI = this.IsTouchHoverNGui(touchIndex); } if (!this.isStartHoverNGUI) { Gesture gesture = new Gesture(); gesture.fingerIndex = finger.fingerIndex; gesture.touchCount = finger.touchCount; gesture.startPosition = finger.startPosition; gesture.position = finger.position; gesture.deltaPosition = finger.deltaPosition; gesture.actionTime = actionTime; gesture.deltaTime = finger.deltaTime; gesture.swipe = swipe; gesture.swipeLength = swipeLength; gesture.swipeVector = swipeVector; gesture.deltaPinch = 0f; gesture.twistAngle = 0f; gesture.pickObject = finger.pickedObject; gesture.otherReceiver = this.receiverObject; gesture.isHoverReservedArea = this.IsTouchReservedArea(touchIndex); gesture.pickCamera = finger.pickedCamera; gesture.isGuiCamera = finger.isGuiCamera; if (this.useBroadcastMessage) { this.SendGesture(message, gesture); } if (!this.useBroadcastMessage || this.isExtension) { this.RaiseEvent(message, gesture); } } }