コード例 #1
0
        public async Task ScanMini(bool autoClose = true)
        {
            while (ai.isIdle == false)
            {
                Console.WriteLine("Press the Enter key to exit the program at any time... ");
                Console.ReadLine();

                Log.Info("Scanning for Mini Boss... Please wait...");
                await this.Action.OpenMVP();

                Point MonsterImage;
                //await Task.Delay(2000);

                Bitmap bmp = ImageSearch.PrintWindow((IntPtr)screenHandle);
                MonsterImage = ImageSearch.SearchFromImage(bmp, "resources/smokie.png");
                Timer_Mini   = new List <int>();

                Bitmap crop;
                if (MonsterImage.X == -1 && MonsterImage.Y == -1)
                {
                    Log.Error("Cannot find a reference point.");
                }
                //TODO export loop to aync function
                for (int i = 0; i < 5; i++)
                {
                    try
                    {
                        Point TempPoint;
                        bmp       = ImageSearch.PrintWindow((IntPtr)screenHandle);
                        TempPoint = new Point(MonsterImage.X + 360, MonsterImage.Y + 110 * i);
                        crop      = ImageSearch.CropImage(bmp, TempPoint, 180, 50);
                        crop.Save($"mob{i}.bmp");
                        Timer_Mini.Add(OCR.ExtractTime(OCR.RawOCR(crop)));
                        Log.Info($"{MobName_Mini[i]}: {Timer_Mini[i].ToString()} minutes");
                        await Task.Delay(400);
                    }
                    catch (Exception e)
                    {
                        Log.Info($"Error {e}");
                    }
                }

                //TODO
                //var loop = asyncFunctionCall()
                //check timer: while loop is not resolved?
                // if timer > 10 seconds: continue to line 123
                // await loop

                Log.Success("Successfully scanned!");
                if (autoClose)
                {
                    this.ClickImage("resources/close-button.png");
                }
                await Scheduler.ScheduleHunt(Timer_Mini);
            }
        }
コード例 #2
0
 private void ScanImage(List <Monster> monsterList)
 {
     foreach (var monster in monsterList)
     {
         Bitmap bmp      = ImageSearch.PrintWindow((IntPtr)_ai.screenHandle);
         var    leftBmp  = ImageSearch.CropImage(bmp, new Point(0, 0), 720, 670);
         Point  location = Scan(leftBmp, monster.GetImagePath());
         if (location.X == -1 && location.Y == -1)
         {
             continue;
         }
         location.Y += monster.GetMonsterImagePositionOffsetY();
         location.X += 360;
         Bitmap crop = ImageSearch.CropImage(bmp, location, 185, 60);
         monster.MinutesToSpawn = OCR.ExtractTime(_OCR.RawOCR(crop));
         //_log.Info($"{monster.GetName()}: {monster.MinutesToSpawn} minutes");
     }
 }