private void FireSwipeEvent() { Debug.Log("swipe!"); Vector2 diff = end_pos - start_pos; GameObject hitObject = GetHit(start_pos); Directions dir; //swiping left or right if (Mathf.Abs(diff.x) > Mathf.Abs(diff.y)) { if (diff.x > 0) { Debug.Log("swiped right!"); dir = Directions.RIGHT; } else { Debug.Log("swiped left!"); dir = Directions.LEFT; } } //swiping up or down else { if (diff.y > 0) { Debug.Log("swiped upwards!"); dir = Directions.UP; } else { Debug.Log("swiped downwards!"); dir = Directions.DOWN; } } SwipeEventArgs args = new SwipeEventArgs(start_pos, diff, dir, hitObject); if (OnSwipe != null) { OnSwipe(this, args); } if (hitObject != null) { ISwiped iswiped = hitObject.GetComponent <ISwiped>(); if (iswiped != null) { iswiped.OnSwipe(args); } } }
private void FireSwipeFunction() { Debug.Log("SWIPE"); Vector2 diff = end_pos - start_pos; GameObject hitObject = GetHit(start_pos); Directions dir; if (Mathf.Abs(diff.x) > Mathf.Abs(diff.y)) { if (diff.x > 0) { Debug.Log("Right"); dir = Directions.RIGHT; } else { Debug.Log("Left"); dir = Directions.LEFT; } } else { if (diff.y > 0) { Debug.Log("up"); dir = Directions.UP; } else { Debug.Log("down"); dir = Directions.DOWN; } } SwipeEventArgs args = new SwipeEventArgs(start_pos, diff, dir, hitObject); if (OnSwipe != null) { OnSwipe(this, args); } if (hitObject != null) { ISwiped iSwipe = hitObject.GetComponent <ISwiped>(); if (iSwipe != null) { iSwipe.OnSwipe(args); } } }