示例#1
0
        public bool HandleInteraction(int x, int y, int width, int height, MouseAction action)
        {
            if (action == MouseAction.Move)
            {
                return(false);
            }

            x -= 100;
            y -= height - _pixelMapper.Rows - 100;

            if (x <= 0 || x >= _pixelMapper.Columns ||
                y <= 0 || y >= _pixelMapper.Rows)
            {
                return(false);
            }

            // we're inside the minimap
            (x, y) = _pixelMapper.CoordsToWorldPixels(x, y);

            x -= _pixelMapper.ViewPortWidth / 2;
            y -= _pixelMapper.ViewPortHeight / 2;

            _pixelMapper.SetViewPort(x, y);

            return(true);
        }
示例#2
0
        public bool HandlePointerAction(int x, int y, int width, int height, PointerAction action)
        {
            if (!this.Enabled)
            {
                return(false);
            }

            if (action == Rendering.PointerAction.Move)
            {
                return(false);
            }

            x -= width - _pixelMapper.Columns - 50;
            y -= height - _pixelMapper.Rows - 50;

            if (x <= 0 || x >= _pixelMapper.Columns ||
                y <= 0 || y >= _pixelMapper.Rows)
            {
                return(false);
            }

            // we're inside the minimap
            (x, y) = _pixelMapper.CoordsToWorldPixels(x, y);

            x -= _pixelMapper.ViewPortWidth / 2;
            y -= _pixelMapper.ViewPortHeight / 2;

            _pixelMapper.SetViewPort(x, y);

            return(true);
        }
示例#3
0
        public override void DragInteraction(PointF[] points)
        {
            (int x, int y) = _pixelMapper.CoordsToWorldPixels((int)points[0].X, (int)points[0].Y);

            x -= _pixelMapper.ViewPortWidth / 2;
            y -= _pixelMapper.ViewPortHeight / 2;

            _pixelMapper.SetViewPort((int)x, (int)y);
        }
示例#4
0
        public override void DragInteraction(PointF[] points)
        {
            float x = points[0].X * (PixelMapper.MaxGridSize / 100);
            float y = points[0].Y * (PixelMapper.MaxGridSize / 100);

            x -= _pixelMapper.ViewPortWidth / 2;
            y -= _pixelMapper.ViewPortHeight / 2;

            _pixelMapper.SetViewPort((int)x, (int)y);
        }
示例#5
0
        public AdjustGameScaleTests(ITestOutputHelper output)
        {
            _pixelMapper = new PixelMapper();
            _pixelMapper.SetViewPortSize(ScreenSize, ScreenSize);
            int centerViewportOffsetX = _pixelMapper.MaxGridWidth / 2 - ScreenSize / 2;
            int centerViewportOffsetY = _pixelMapper.MaxGridHeight / 2 - ScreenSize / 2;

            _pixelMapper.SetViewPort(centerViewportOffsetX, centerViewportOffsetY);
            _output = output;
        }
示例#6
0
        public void ViewPortPixelsToCoords_ZoomedIn_ZeroPosition(int x, int y, int expectedCol, int expectedRow)
        {
            _pixelMapper.AdjustGameScale(2.0f);
            _pixelMapper.SetViewPort(0, 0);
            _pixelMapper.LogData(_output);

            (int actualCol, int actualRow) = _pixelMapper.ViewPortPixelsToCoords(x, y);

            Assert.Equal(expectedCol, actualCol);
            Assert.Equal(expectedRow, actualRow);
        }