Esempio n. 1
0
        private async Task ExecuteMove(Move move)
        {
            WindowsVirtualKey virtualKey = WindowsVirtualKey.Up;

            switch (move.direction)
            {
            case Direction.Up:
                virtualKey = WindowsVirtualKey.Up;
                break;

            case Direction.Down:
                virtualKey = WindowsVirtualKey.Down;
                break;

            case Direction.Left:
                virtualKey = WindowsVirtualKey.Left;
                break;

            case Direction.Right:
                virtualKey = WindowsVirtualKey.Right;
                break;

            case Direction.None:
                return;
            }

            var distance   = Math.Max(Math.Abs(move.start.x - move.end.x), Math.Abs(move.start.y - move.end.y));
            var timeToHold = (30 * distance) + MainWindow.Delay;

            await PinvokeHelpers.SendKeyPress(virtualKey, timeToHold);
        }
Esempio n. 2
0
        private async void RightButtonPress(object sender, RoutedEventArgs e)
        {
            await PinvokeHelpers.SendKeyPress(WindowsVirtualKey.Right);

            await Task.Delay(500);

            this.UpdateBitmap(new Runner());
        }
Esempio n. 3
0
        public Bitmap AnalyseBitmap()
        {
            var bitmap = PinvokeHelpers.GetAdrenalineBitmap();

            this.tileGrid = GetTileGrid(bitmap);

            var solver = new LevelSolver(this.tileGrid);

            this.solution = solver.SolveLevel().ToList();

            DrawSolutionOnBitmap(bitmap);

            return(bitmap);
        }