Beispiel #1
0
 private async Task TurnScreen(CancellationToken cancellationToken)
 {
     for (var i = 0; i < 15; i++)
     {
         WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.Right);
         await Task.Delay(TimeSpan.FromSeconds(0.1), cancellationToken);
     }
 }
Beispiel #2
0
        internal MasterProcessor(IntPtr hWnd, [NotNull] SkSettings settings, IntPtr?_slaveIntPtr)
        {
            _hWnd             = hWnd;
            _settings         = settings ?? throw new ArgumentNullException(nameof(settings));
            this._slaveIntPtr = _slaveIntPtr;

            _timer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
            _timer.Elapsed += (sender, args) =>
            {
                _timer.Stop();

                WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F6);
            };
            _timer.AutoReset = false;
        }
Beispiel #3
0
        private async Task FightTarget(CancellationToken cancellationToken)
        {
            _timer.Stop();
            OnReport($"Target found!");
            while (!cancellationToken.IsCancellationRequested)
            {
                var screenshot          = ScreenshotHelper.GetScreenBitmap(_hWnd);
                var targetHealth        = ScreenshotHelper.GetSubPart(screenshot, _settings.RegionInfo.TargetHp);
                var targetHealthPercent = GetTargetHpPercent(targetHealth);

                var myHealth        = ScreenshotHelper.GetSubPart(screenshot, _settings.RegionInfo.MyHp);
                var myHealthPercent = GetMyHpPercent(myHealth);
                if (Math.Abs(myHealthPercent) < 100 && _slaveIntPtr.HasValue)
                {
                    OnReport("Request self heal");
                    WindowCommandHelper.PressKey(_slaveIntPtr.Value, WindowCommandHelper.KeyCodes.F7);
                    await Task.Delay(TimeSpan.FromSeconds(1));

                    WindowCommandHelper.PressKey(_slaveIntPtr.Value, WindowCommandHelper.KeyCodes.F3);
                }


                OnReport($"Target HP: {targetHealthPercent:###.##}% MY: {myHealthPercent:###.##}%");
                if (Math.Abs(targetHealthPercent) < 0.00001)
                {
                    break;
                }

                WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F1);

                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
            }

            OnReport($"Target is dead!");
            WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F4);
            await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);

            WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F4);
            await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);

            WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F4);
            await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);

            WindowCommandHelper.PressKey(_hWnd, WindowCommandHelper.KeyCodes.F4);
        }