private void Update() { if (Input.touchCount > 0) { // Debug.Log("Touching"); Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { fingerDown = touch; fingerUp = touch; onFingerDownTouchables = GetTouchablesFromPoint(fingerDown.position); onFingerDownTime = Time.time; } else if (touch.phase == TouchPhase.Ended) { fingerUp = touch; onFingerUpTime = Time.time; if (touchSettings.requireLiftInCollider) { HashSet <ITouchable> onFingerUpTouchables = GetTouchablesFromPoint(fingerUp.position); onFingerDownTouchables.IntersectWith(onFingerUpTouchables); } foreach (ITouchable touchable in onFingerDownTouchables) { if (IsTap(fingerDown.position, fingerUp.position)) { ITappable tap = (touchable as ITappable); if (tap != null) { tap.OnTap(); } } else if (IsSwipe(fingerDown.position, fingerUp.position)) { ISwipeable swipe = (touchable as ISwipeable); if (swipe != null) { swipe.OnSwipe(new SwipeInfo(fingerDown, fingerUp, onFingerUpTime - onFingerDownTime)); } } } } } }
public Employee(ISwipeable swipeable) { _swipeable = swipeable; }
public void SetCard(GameObject card) { swipeable = card.GetComponent <ISwipeable>(); cachedRect = card.transform as RectTransform; }
/// <summary> /// Set the target. /// </summary> /// <param name="target"></param> /// <param name="swipeable"></param> public void SetTarget(GameObject target, ISwipeable swipeable) { cachedRect = target.transform as RectTransform; this.swipeable = swipeable; }
public Employee(ISwipeable swipeable) { _swipeable = swipeable; //exposes private field }
public Employee(ISwipeable swipeable)//set up for dependency injection { _swipeable = swipeable; }