コード例 #1
0
ファイル: TouchInput.cs プロジェクト: IvanKelber/Flips
    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));
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
ファイル: Employee.cs プロジェクト: mmholtman/oopfundamentals
 public Employee(ISwipeable swipeable)
 {
     _swipeable = swipeable;
 }
コード例 #3
0
 public void SetCard(GameObject card)
 {
     swipeable  = card.GetComponent <ISwipeable>();
     cachedRect = card.transform as RectTransform;
 }
コード例 #4
0
ファイル: UISwiper.cs プロジェクト: Gui-Lima/TinderWithPerks
 /// <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;
 }
コード例 #5
0
ファイル: Employee.cs プロジェクト: Mjmarek/DotNetReview
 public Employee(ISwipeable swipeable)
 {
     _swipeable = swipeable; //exposes private field
 }
コード例 #6
0
 public Employee(ISwipeable swipeable)//set up for dependency injection
 {
     _swipeable = swipeable;
 }