Пример #1
0
        private AppInterface.TouchData CreateTouchEventData(TouchInputEvent inputEvent)
        {
            var result = new AppInterface.TouchData();

            result.point.Set(inputEvent.pointerEvents[0].x, inputEvent.pointerEvents[0].y);
            return(result);
        }
Пример #2
0
 protected override void OnTouchStart(TouchInputEvent input)
 {
     if (_canMove)
     {
         _inputActive = true;
     }
 }
Пример #3
0
 protected override void OnTouchStart(TouchInputEvent input)
 {
     if (GameManager.Instance.CurrentState != GameState.Playing)
     {
         return;
     }
     _tapTime = Time.time;
 }
Пример #4
0
        protected override void OnTouchStay(TouchInputEvent input)
        {
            // The player can't move if an ability is currently being used
            if (GameManager.Instance.CurrentState != GameState.Playing || (_activeAbility != null && _activeAbility.enabled))
            {
                return;
            }

            CurrentAngle       += Mathf.Clamp(input.touchDelta.x, -45, 45) * MovementModifier;
            Pivot.localRotation = Quaternion.Euler(0, 0, CurrentAngle);
        }
Пример #5
0
        protected override void OnTouchRelease(TouchInputEvent input)
        {
            if (GameManager.Instance.CurrentState != GameState.Playing)
            {
                return;
            }

            if (_activeAbility != null)
            {
                _activeAbility.enabled = (Time.time - _tapTime < _tapMaxTime);
            }
        }
Пример #6
0
        bool HandleTouchInput()
        {
            var  touchPointerEvents = new List <TouchInputPointerEvent>(m_inputFrame.Touches.Length);
            bool anyTouchesDown     = false;
            bool anyTouchesUp       = false;

            foreach (var touch in m_inputFrame.Touches)
            {
                if (ShouldConsumeTouch(touch.fingerId))
                {
                    if (touch.phase == TouchPhase.Began)
                    {
                        anyTouchesDown = true;
                    }
                    else if (touch.phase == TouchPhase.Ended)
                    {
                        anyTouchesUp = true;
                    }

                    touchPointerEvents.Add(new TouchInputPointerEvent
                    {
                        x = TranslateGlobalXToLocalX(touch.position.x),
                        y = TranslateGlobalYToLocalY(touch.position.y),
                        pointerIdentity = touch.fingerId,
                        pointerIndex    = touchPointerEvents.Count
                    });
                }
            }

            int touchEventIndex = 0;

            foreach (var touchPointerEvent in touchPointerEvents)
            {
                var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, touchEventIndex, touchPointerEvent.pointerIdentity);
                touchEvent.pointerEvents = touchPointerEvents;
                m_touchInputProcessor.HandleInput(touchEvent);
                ++touchEventIndex;
            }

            bool hasProcessedTouches = touchEventIndex > 0;

            return(hasProcessedTouches);
        }
Пример #7
0
        void HandleTouchInput()
        {
            var touches        = m_inputFrame.Touches;
            var anyTouchesDown = touches.Any(_t => _t.phase == TouchPhase.Began);
            var anyTouchesUp   = touches.Any(_t => _t.phase == TouchPhase.Ended);
            int index          = 0;

            foreach (var provokingTouch in touches)
            {
                var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, index++, provokingTouch.fingerId);
                touchEvent.pointerEvents.AddRange(touches.Select((_t, _i) =>
                                                                 new TouchInputPointerEvent
                {
                    x = _t.position.x,
                    y = _t.position.y,
                    pointerIdentity = _t.fingerId,
                    pointerIndex    = _i
                }));
                m_inputProcessor.HandleInput(touchEvent);
            }
        }
Пример #8
0
        bool HandleTouchInput()
        {
            var touches = m_inputFrame.Touches;

            var anyTouchesDown = touches.Any(_t => _t.phase == TouchPhase.Began) && m_inputFrame.ShouldHandleEventsThisFrame;
            var anyTouchesUp   = touches.Any(_t => _t.phase == TouchPhase.Ended);
            int index          = 0;

            foreach (var provokingTouch in touches)
            {
                var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, index++, provokingTouch.fingerId);
                touchEvent.pointerEvents.AddRange(touches.Select((_t, _i) =>
                                                                 new TouchInputPointerEvent
                {
                    x = TranslateGlobalXToLocalX(_t.position.x),
                    y = TranslateGlobalYToLocalY(_t.position.y),
                    pointerIdentity = _t.fingerId,
                    pointerIndex    = _i
                }));
                m_touchInputProcessor.HandleInput(touchEvent);
            }

            return(touches.Length > 0);
        }
 public void HandleInput(TouchInputEvent inputEvent)
 {
 }
Пример #10
0
 public void PointerMove(TouchInputEvent inputEvent)
 {
     m_handler.Event_TouchMove(CreateTouchEventData(inputEvent));
 }
Пример #11
0
 public void PointerDown(TouchInputEvent inputEvent)
 {
     m_handler.Event_TouchDown(CreateTouchEventData(inputEvent));
 }
Пример #12
0
 protected override void OnTouchRelease(TouchInputEvent input)
 {
     _inputActive = false;
 }
Пример #13
0
 private void HandleTouchEvents(object sender, TouchInputEvent e)
 {
     // These cases are not handled
 }