Beispiel #1
0
        public override bool OnTouchEvent(MotionEvent e)
        {
            var crossSize  = Convert.ToInt32(PxFromDp(135));
            var marginSize = Convert.ToInt32(PxFromDp(20));

            // 1 finger for every half of screen

            if (
                (e.Action == MotionEventActions.Down ||
                 e.Action == MotionEventActions.Move ||
                 e.Action == MotionEventActions.Pointer1Down ||
                 e.Action == MotionEventActions.Pointer2Down)
                )
            {
                if (e.GetX() > Width / 2f)
                {
                    // right half => cross tap event

                    _lastTapCrossMove = TapCrossMoveEvent.GetTapMoveEvent(
                        crossSize,
                        crossSize,
                        e.GetX() - (Width - crossSize - marginSize),
                        e.GetY() - (Height - crossSize));
                }
                else
                {
                    // left half => rotation
                    _lastTapRotateMove = TapCrossMoveEvent.GetTapMoveEvent(
                        crossSize,
                        crossSize,
                        e.GetX() - marginSize,
                        e.GetY() - (Height - crossSize));
                }

                return(true);
            }
            else
            if (e.Action == MotionEventActions.Up ||
                e.Action == MotionEventActions.Pointer1Up ||
                e.Action == MotionEventActions.Pointer2Up)
            {
                if (e.GetX() > Width / 2f)
                {
                    // right half => cross tap event

                    _lastTapCrossMove = null;
                }
                else
                {
                    // left half => no rotation
                    _lastTapRotateMove = null;
                }

                return(true);
            }
            else
            {
                return(base.OnTouchEvent(e));
            }
        }
Beispiel #2
0
        public static TapCrossMoveEvent GetTapMoveEvent(int width, int height, float x, float y)
        {
            var res = new TapCrossMoveEvent();

            if ((x < 0) || (x > width) ||
                (y < 0) || (y > height))
            {
                return(null);
            }

            var cx = (float)width / 2.0;
            var cy = (float)height / 2.0;

            if (x < cx)
            {
                res.Left = 100.0 - x / cx * 100;
            }
            else
            if (x > cx)
            {
                res.Right = (x - cx) / cx * 100;
            }

            if (y < cy)
            {
                res.Top = 100.0 - y / cy * 100;
            }
            else
            if (y > cy)
            {
                res.Bottom = (y - cy) / cy * 100;
            }

            if (res.Left < 0 ||
                res.Right > 100 ||
                res.Top < 0 ||
                res.Bottom > 100)
            {
                return(null);
            }
            else
            {
                return(res);
            }
        }
Beispiel #3
0
        public void NewLevel()
        {
            GLTextureAdmin.UnLoadGLTextures();

            GLTextureAdmin.AddTexturesFromResource(Context, new string[]
            {
                "blue0", "blue1", "labBottomF", "labBottomL", "labBottomS",
                "labTop", "labTopF", "labTopL", "labTopS",
                "labWall0", "labWall1", "labWall2", "labWall3",
                "labWallF", "labWallL", "labWallS",
                "money", "moneySmall", "blue0", "labBottom"
            });

            var labyrinth = (_scene.GetObjectByName("labyrinth") as GLLabyrinthObj);

            int moves;
            int items;

            if (labyrinth.Level <= 5) // 1 .. 5 level => 5 * 2 .. 25 * 10
            {
                moves = labyrinth.Level * 5;
                items = labyrinth.Level * 2;
            }
            else
            if (labyrinth.Level <= 20) // 6 .. 20 level =>  26 * 11 .. 40 * 25
            {
                moves = 20 + labyrinth.Level;
                items = 5 + labyrinth.Level;
            }
            else
            {
                moves = 40;
                items = 25;
            }

            labyrinth.Generate(Context, moves, items);

            _scene.Observer.Position = labyrinth.LabPointToScenePoint(labyrinth.StartPos);
            _scene.Observer.Rotation = new GLVector(0, 180, 0);

            _lastTapCrossMove  = null;
            _lastTapRotateMove = null;

            UpdateDisplays();
        }