Пример #1
0
        public bool CheckPosition(GLPoint position)
        {
            var nearestBonusItem = GetNearestBonusItem(position);

            if (nearestBonusItem != null)
            {
                var dist = position.DistanceToPoint(nearestBonusItem.Position);
                if (dist < TileWidth)
                {
                    PickUpBonusItem(nearestBonusItem);
                }
            }

            var finishPosition = LabPointToScenePoint(EndPos);
            var distToFinish   = position.DistanceToPoint(finishPosition);

            if (distToFinish < TileWidth)
            {
                if (!Locked)
                {
                    Level++;

                    Task.Run(() =>
                    {
                        var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                        player.Load("levelcomplete.mp3");
                        player.Play();
                    });

                    return(true);
                }
                else
                {
                    if (!_nearLockedDoors)
                    {
                        Task.Run(() =>
                        {
                            var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                            player.Load("doorclosed.mp3");
                            player.Play();
                        });

                        _nearLockedDoors = true;
                    }
                }
            }
            else
            {
                _nearLockedDoors = false;
            }

            return(false);
        }
Пример #2
0
        public GLObject GetNearestBonusItem(GLPoint p)
        {
            var      minDist = double.MaxValue;
            GLObject res     = null;

            foreach (var item in BonusItems)
            {
                var dist = p.DistanceToPoint(item.Value.Position);
                if (dist < minDist)
                {
                    minDist = dist;
                    res     = item.Value;
                }
            }

            return(res);
        }
Пример #3
0
        public override bool OnTouchEvent(MotionEvent e)
        {
            var x = e.GetX();
            var y = e.GetY();

            base.OnTouchEvent(e);

            if (e.Action == MotionEventActions.Down)
            {
                _fingerTapCoordinates.X = x;
                _fingerTapCoordinates.Y = y;

                Logger.Info($"Down: {x}:{y}");
            }
            else
            if (e.Action == MotionEventActions.Pointer2Down)
            {
                // second finger down

                Logger.Info($"Pointer2Down: {x}:{y}");
            }
            else
            if (e.Action == MotionEventActions.Move)
            {
                if (e.PointerCount > 1)
                {
                    if (!_zoom)
                    {
                        _zoom = true;

                        _fingerTapCoordinates  = new GLPoint(e.GetX(0), e.GetY(0), 0);
                        _finger2TapCoordinates = new GLPoint(e.GetX(1), e.GetY(1), 0);
                    }
                    else
                    {
                        Logger.Info($"Zoom:");

                        var originalDistance = _fingerTapCoordinates.DistanceToPoint(_finger2TapCoordinates);

                        var actualFinger1TapCoordinates = new GLPoint(e.GetX(0), e.GetY(0), 0);
                        var actualFinger2TapCoordinates = new GLPoint(e.GetX(1), e.GetY(1), 0);

                        var newDistance = actualFinger1TapCoordinates.DistanceToPoint(actualFinger2TapCoordinates);

                        if (originalDistance != 0)
                        {
                            var ratio = newDistance / originalDistance;

                            if (ratio < 0.9)
                            {
                                _scene.Magnify(0.9f);
                            }
                            else
                            if (ratio > 1.1)
                            {
                                _scene.Magnify(1.1f);
                            }

                            Logger.Info($"Move: PinchToZoom, originalDistance: {originalDistance:N2}, newDistance: {newDistance:N2}, ratio: {ratio}");
                        }
                    }
                }
                else if (!_zoom)
                {
                    Logger.Info($"Move:");

                    float xdiff = ((float)_fingerTapCoordinates.X - x);
                    float ydiff = ((float)_fingerTapCoordinates.Y - y);

                    _scene.Observer.Rotation.X += ydiff;
                    _scene.Observer.Rotation.Y += xdiff;

                    _fingerTapCoordinates.X = x;
                    _fingerTapCoordinates.Y = y;
                }
            }

            if (e.Action == MotionEventActions.Up)
            {
                _zoom = false;
            }

            return(true);
        }