Exemple #1
0
 void localAxis(InputTouch touch)
 {
     if (dpadMode == EasyInputConstants.REGISTER_MODE.RegisterAlways || isClicking)
     {
         //check to see if we've exceeded the deadzone
         if (Mathf.Sqrt(Mathf.Pow(touch.currentTouchPosition.x, 2) + Mathf.Pow(touch.currentTouchPosition.y, 2)) > deadZone)
         {
             //we have a valid touch
             if (directionMode == EasyInputConstants.DIRECTION_MODE.FourDirectionsOnly)
             {
                 //only four directions (up/down/left/right
                 if (Mathf.Abs(touch.currentTouchPosition.x) >= Mathf.Abs(touch.currentTouchPosition.y))
                 {
                     //horizontal is greater than vertical it's either left or right
                     if (touch.currentTouchPosition.x > 0f)
                     {
                         //right
                         onRight.Invoke(touch);
                     }
                     else
                     {
                         //left
                         onLeft.Invoke(touch);
                     }
                 }
                 else
                 {
                     //vertical is greater than horizontal it's either up or down
                     if (touch.currentTouchPosition.y > 0f)
                     {
                         //up
                         onUp.Invoke(touch);
                     }
                     else
                     {
                         //down
                         onDown.Invoke(touch);
                     }
                 }
             }
             else
             {
                 //eight possible directions (up/upleft/upright/left/right/down/downleft/downright)
                 //only four directions (up/down/left/right
                 if (Mathf.Abs(touch.currentTouchPosition.x) >= Mathf.Abs(touch.currentTouchPosition.y))
                 {
                     //horizontal is greater than vertical
                     if (touch.currentTouchPosition.x > 0f)
                     {
                         //it's either right/rightup/rightdown
                         if (Mathf.Abs(touch.currentTouchPosition.x) >= (2f * Mathf.Abs(touch.currentTouchPosition.y)))
                         {
                             onRight.Invoke(touch);
                         }
                         else if (touch.currentTouchPosition.y > 0f)
                         {
                             onRight.Invoke(touch);
                             onUp.Invoke(touch);
                         }
                         else
                         {
                             onRight.Invoke(touch);
                             onDown.Invoke(touch);
                         }
                     }
                     else
                     {
                         //it's either left/leftup/leftdown
                         if (Mathf.Abs(touch.currentTouchPosition.x) >= (2f * Mathf.Abs(touch.currentTouchPosition.y)))
                         {
                             onLeft.Invoke(touch);
                         }
                         else if (touch.currentTouchPosition.y > 0f)
                         {
                             onLeft.Invoke(touch);
                             onUp.Invoke(touch);
                         }
                         else
                         {
                             onLeft.Invoke(touch);
                             onDown.Invoke(touch);
                         }
                     }
                 }
                 else
                 {
                     //vertical is greater than horizontal
                     if (touch.currentTouchPosition.y > 0f)
                     {
                         //it's either up/rightup/leftup
                         if (Mathf.Abs(touch.currentTouchPosition.y) >= (2f * Mathf.Abs(touch.currentTouchPosition.x)))
                         {
                             onUp.Invoke(touch);
                         }
                         else if (touch.currentTouchPosition.x > 0f)
                         {
                             onRight.Invoke(touch);
                             onUp.Invoke(touch);
                         }
                         else
                         {
                             onLeft.Invoke(touch);
                             onUp.Invoke(touch);
                         }
                     }
                     else
                     {
                         //it's either down/leftdown/rightdown
                         if (Mathf.Abs(touch.currentTouchPosition.y) >= (2f * Mathf.Abs(touch.currentTouchPosition.x)))
                         {
                             onDown.Invoke(touch);
                         }
                         else if (touch.currentTouchPosition.x > 0f)
                         {
                             onRight.Invoke(touch);
                             onDown.Invoke(touch);
                         }
                         else
                         {
                             onLeft.Invoke(touch);
                             onDown.Invoke(touch);
                         }
                     }
                 }
             }
         }
     }
 }
 void localButtonLongClick(InputTouch button)
 {
     onLongTouch.Invoke(button);
 }
 void localButtonLongClickStart(InputTouch button)
 {
     onLongTouchStart.Invoke(button);
 }
 void localButtonQuickClickEnd(InputTouch button)
 {
     onQuickTouchEnd.Invoke(button);
 }
 void localButtonDoubleClickEnd(InputTouch button)
 {
     onDoubleTouchEnd.Invoke(button);
 }
 void localButtonClick(InputTouch button)
 {
     onTouch.Invoke(button);
 }
 void localSwipe(InputTouch button)
 {
     onSwipe.Invoke(button);
 }
 void localButtonLongClickEnd(InputTouch button)
 {
     onLongTouchEnd.Invoke(button);
 }
 void localButtonClickEnd(InputTouch button)
 {
     onTouchEnd.Invoke();
 }
 void localButtonClickStart(InputTouch button)
 {
     onTouchStart.Invoke();
 }