private void handleTouchAction(ITouch touch, TouchMotionAction action)
        {
            CanvasInfoProvider canvasInfoProvider = SkiaBehaviourEngine.CanvasInfoProvider as CanvasInfoProvider;
            SkiaTouch          skiaTouch          = null;

            if (action == TouchMotionAction.Down)
            {
                int heightLevel = 0;
                ISkiaInputComponent skiaInputComponent = getSkiaInputComponent(canvasInfoProvider.DeviceToCanvasPoint(touch.Position.ToSKPoint()));
                if (skiaInputComponent != null)
                {
                    heightLevel = skiaInputComponent.InputHeightLevel;
                }
                skiaTouch = new SkiaTouch(this, touch, heightLevel);
                _SkiaTouches.Add(skiaTouch);
            }
            else if (action == TouchMotionAction.Up)
            {
                for (int i = 0; i < _SkiaTouches.Count; i++)
                {
                    if (_SkiaTouches[i].Touch == touch)
                    {
                        skiaTouch = _SkiaTouches[i];
                        _SkiaTouches.RemoveAt(i);
                        break;
                    }
                }
            }
            else
            {
                for (int i = 0; i < _SkiaTouches.Count; i++)
                {
                    if (_SkiaTouches[i].Touch == touch)
                    {
                        skiaTouch = _SkiaTouches[i];
                    }
                }
            }
            if (skiaTouch == null)
            {
                return;
            }
            OnSkiaTouchAction?.Invoke(skiaTouch, action);
        }
Beispiel #2
0
        private void handleSkiaTouchAction(SkiaTouch skiaTouch, TouchMotionAction action)
        {
            if (skiaTouch.HeightLevel != InputHeightLevel)
            {
                return;
            }
            ITouch             touch = skiaTouch.Touch;
            CanvasInfoProvider canvasInfoProvider = SkiaBehaviourEngine.CanvasInfoProvider as CanvasInfoProvider;

            if (action == TouchMotionAction.Down)
            {
                if (OnSkiaTouch == null && StartRegion.IsOverlapPoint(canvasInfoProvider.DeviceToCanvasPoint(touch.Position.ToSKPoint())))
                {
                    OnSkiaTouch = skiaTouch;
                    Distance    = 0;
                    Direction   = 0;
                    startPos    = touch.Position.ToSKPoint();
                    OnJoystickPressed();
                }
            }
            else if (action == TouchMotionAction.Up)
            {
                if (OnSkiaTouch == skiaTouch)
                {
                    Distance    = 0;
                    Direction   = 0;
                    OnSkiaTouch = null;
                    OnJoystickUp();
                }
            }
            else if (action == TouchMotionAction.Move)
            {
                if (OnSkiaTouch == skiaTouch)
                {
                    SKPoint currentPos = touch.Position.ToSKPoint();
                    float   distance   = (currentPos - startPos).Magnitude();
                    float   degree     = (float)(Math.Atan2((currentPos - startPos).Y, (currentPos - startPos).X) * (180 / Math.PI));
                    this.Distance  = distance;
                    this.Direction = degree;
                    OnJoystickMove();
                }
            }
        }
Beispiel #3
0
        private void handleSkiaTouchAction(SkiaTouch skiaTouch, TouchMotionAction action)
        {
            ITouch touch = skiaTouch.Touch;

            //System.Diagnostics.Debug.WriteLine("F**K:" + touch.Position.ToSKPoint());

            if (skiaTouch.HeightLevel != InputHeightLevel)
            {
                return;
            }

            CanvasInfoProvider canvasInfoProvider = SkiaBehaviourEngine.CanvasInfoProvider as CanvasInfoProvider;

            if (action == TouchMotionAction.Down)
            {
                if (Area.IsOverlapPoint(canvasInfoProvider.DeviceToCanvasPoint(touch.Position.ToSKPoint())))
                {
                    bool firstTouch = false;
                    if (OnSkiaTouches.Count == 0)
                    {
                        firstTouch = true;
                    }
                    OnSkiaTouches.Add(skiaTouch);
                    if (firstTouch)
                    {
                        OnButtonPressed();
                    }
                }
            }
            else if (action == TouchMotionAction.Move)
            {
                if (!OnSkiaTouches.Contains(skiaTouch) && Area.IsOverlapPoint(touch.Position.ToSKPoint()))
                {
                    bool firstTouch = false;
                    if (OnSkiaTouches.Count == 0)
                    {
                        firstTouch = true;
                    }
                    OnSkiaTouches.Add(skiaTouch);
                    if (firstTouch)
                    {
                        OnButtonPressed();
                    }
                }
                else if (OnSkiaTouches.Contains(skiaTouch) && !Area.IsOverlapPoint(touch.Position.ToSKPoint()))
                {
                    OnSkiaTouches.Remove(skiaTouch);
                    if (OnSkiaTouches.Count == 0)
                    {
                        OnButtonUp();
                    }
                }
            }
            else if (action == TouchMotionAction.Up)
            {
                if (OnSkiaTouches.Contains(skiaTouch))
                {
                    OnSkiaTouches.Remove(skiaTouch);
                    if (OnSkiaTouches.Count == 0)
                    {
                        OnButtonUp();
                    }
                }
            }
        }