Ejemplo n.º 1
0
        private void Update()
        {
            if (GameManager.Instance.IsGameProcessing == false)
            {
                _prevState = InputState.None;
                return;
            }

            List <Touch> touches = InputHelper.GetTouches();

            if (touches.Count == 0)
            {
                _state = InputState.None;
                return;
            }

            if (touches.Count == 0)
            {
                _state = InputState.None;
            }
            else if (touches.Count == 1)
            {
                if (touches[0].phase == TouchPhase.Began)
                {
                    _pressDownTime = Time.time;
                }

                OnTouchPosChange?.Invoke(touches[0].position);
                float deltaPositionLength = touches[0].deltaPosition.magnitude;
                float moveSpeed           = deltaPositionLength * Time.deltaTime;
                if (touches[0].phase == TouchPhase.Ended)
                {
                    if (Time.time - _pressDownTime < 0.4f)
                    {
                        OnClick?.Invoke(touches[0].position);
                    }
                    OnPressUp?.Invoke(touches[0].position);
                    _state = InputState.Up;
                }
                else if (moveSpeed > 0.1f)
                {
                    _state = InputState.Sliding;
                }
                else
                {
                    _state = InputState.Press;
                }
            }
            else if (touches.Count == 2)
            {
                _state = InputState.Pinch;
            }


            ProcessInput(touches, _state);
//			Debug.Log($"CurrentState : {_state}");
            _prevState   = _state;
            _prevTouches = touches;
        }
Ejemplo n.º 2
0
 public override void OnEndDrag(UnityEngine.EventSystems.PointerEventData eventData)
 {
     if (IsAllowedClickButton)
     {
         if (routeToParent)
         {
             DoForParents <IEndDragHandler>((parent) => { parent.OnEndDrag(eventData); });
         }
         else
         {
             OnPressUp?.Invoke(this, eventData.pointerId);
             base.OnEndDrag(eventData);
         }
         routeToParent = false;
     }
 }
 public void PressUp()
 {
     OnPressUp?.Invoke();
 }