Esempio n. 1
0
 private static bool IsPopupPresent(Screenshot image)
 {
     var color = Color.FromArgb(171, 103, 45).ToArgb();
     if (image.GetPixelRgb(1, 1) == color)
     {
         return false;
     }
     return true;
 }
Esempio n. 2
0
 private static bool IsUnitWinPresent(Screenshot image, out Coordinate closeButton)
 {
     closeButton = null;
     var coords = FindCloseButton(image, 2427, 835, 60, 60);
     if (coords != null)
     {
         closeButton = coords;
         return true;
     }
     return false;
 }
Esempio n. 3
0
        private static bool IsMilitaryWinPresent(Screenshot image, out Coordinate closeButton)
        {
            closeButton = null;
            var coords = FindCloseButton(image, 2412, 835, 40, 0);
            //var coords = FindCloseButton(Image, 2412, 835, 0,0);
            //if (coords == null)
            //    coords = FindCloseButton(Image, 2427, 835, 0,0);
            //if (coords == null)
            //    coords = FindCloseButton(Image, 2411, 835, 0,0);

            if (coords != null)
            {
                closeButton = coords;
                return true;
            }
            return false;
        }
Esempio n. 4
0
 private static bool IsOngoingProductionWinPresent(Screenshot image, out Coordinate closeButton)
 {
     closeButton = null;
     var coords = FindCloseButton(image, 2204, 885, 60, 60);
     if (coords != null)
     {
         closeButton = coords;
         return true;
     }
     return false;
 }
Esempio n. 5
0
 private static bool IsCloseBtnPresent(Screenshot image, int x, int y)
 {
     var color = Color.FromArgb(105, 119, 142).ToArgb();
     if (image.GetPixelRgb(x, y) == color)
     {
         color = Color.FromArgb(90, 106, 131).ToArgb();
         if (image.GetPixelRgb(x + 17, y) == color)
         {
             color = Color.FromArgb(178, 188, 204).ToArgb();
             if (image.GetPixelRgb(x + 9, y + 8) == color)
             {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 6
0
 private static bool IsEventSmallPresent(Screenshot image, out Coordinate closeButton)
 {
     closeButton = null;
     if (IsCloseBtnPresent(image, 2205, 889))
     {
         closeButton = new Coordinate(2205, 889);
         return true;
     }
     return false;
 }
Esempio n. 7
0
 private void TryFindCloseButton(Screenshot image, out Coordinate closeButton)
 {
     closeButton = null;
     var coords = FindCloseButton(image, Settings.BotPictureWidth / 2, Settings.BotPictureHeight / 2,
                                  Settings.BotPictureWidth / 2, Settings.BotPictureHeight / 2);
     if (coords != null)
         closeButton = coords;
 }
Esempio n. 8
0
 private static Coordinate FindCloseButton(Screenshot image, int x, int y, int xPerimeter, int yPerimeter)
 {
     Coordinate coords = null;
     //Parallel.For(-xPerimeter / 2, xPerimeter / 2 + 1, (i, s) =>
     for (int i = -xPerimeter / 2; i <= xPerimeter / 2; i++)
     {
         for (int j = -yPerimeter / 2; j <= yPerimeter / 2; j++)
         {
             if (IsCloseBtnPresent(image, x + i, y + j))
             {
                 //updateStatus(LogType.JustMessage, string.Format("Close button @ {0},{1}",x+i,y+j));
                 coords = new Coordinate(x + i, y + j);
                 break;
             }
         }
     };
     return coords;
 }
Esempio n. 9
0
        private Coordinate ScanPicture4ZoomInButton(Screenshot image)
        {
            var colors = new List<int>();
            colors.Add(Color.FromArgb(42, 47, 54).ToArgb()); // @ (0,0)
            colors.Add(Color.FromArgb(25, 30, 37).ToArgb()); // @ (+17,0)
            colors.Add(Color.FromArgb(172, 183, 199).ToArgb()); // @ (+14,+15)
            colors.Add(Color.FromArgb(174, 185, 201).ToArgb()); // @ (+14,+15)
            colors.Add(Color.FromArgb(172, 181, 198).ToArgb()); // @ (+7,+5)
            colors.Add(Color.FromArgb(174, 183, 200).ToArgb()); // @ (+7,+5)
            colors.Add(Color.FromArgb(127, 136, 153).ToArgb()); // @ (+8,+10)
            colors.Add(Color.FromArgb(151, 162, 181).ToArgb()); // @ (+8,+10)

            Coordinate coordinate = null;

            //image.Image.Save("scanZoom.png",ImageFormat.Png);

            // searching in bottom left corner 4 magnifier glass
            //Parallel.For(0, 300, (x,s) =>
            for(int x=0;x<300;x++)
            {
                for (int y = Settings.BotPictureHeight-50; y < Settings.BotPictureHeight; y++)
                {
                    {
                        if (image.GetPixelRgb(x, y) == colors[0] &&
                            image.GetPixelRgb(x+17, y) == colors[1] &&
                            (image.GetPixelRgb(x + 14, y + 15) == colors[2] || image.GetPixelRgb(x + 14, y + 15) == colors[3] )&&
                            (image.GetPixelRgb(x + 7, y + 5) == colors[4] || image.GetPixelRgb(x + 7, y + 5) == colors[5]) &&
                            (image.GetPixelRgb(x + 8, y + 10) == colors[6] || image.GetPixelRgb(x + 8, y + 10) == colors[7])
                            )
                        {
                            coordinate = new Coordinate(x+7, y+7);
                            break;
                        }

                    }
                }
            };
            return coordinate;
        }
Esempio n. 10
0
        private void SaveScanResultToFile(Screenshot image, IEnumerable<Coordinate> crdResultList, int deltaX, int deltaY,
                                          string fileName)
        {
            var setPixelFunc = new CSetPixel(image.Image);
            UpdateStatus(LogType.JustMessage, string.Format(Resource.MainForm_saveScanResultToFile_Saving_scan_results_to_file,fileName));
            try
            {
                foreach (Coordinate coordinate2 in crdResultList)
                {
                    image.Image.SetPixel(coordinate2.X, coordinate2.Y, Color.Black);
                    image.Image.SetPixel(coordinate2.X - 1, coordinate2.Y - 1, Color.White);
                    image.Image.SetPixel(coordinate2.X, coordinate2.Y - 1, Color.White);
                    image.Image.SetPixel(coordinate2.X + 1, coordinate2.Y - 1, Color.White);
                    image.Image.SetPixel(coordinate2.X - 1, coordinate2.Y, Color.White);
                    image.Image.SetPixel(coordinate2.X + 1, coordinate2.Y, Color.White);
                    image.Image.SetPixel(coordinate2.X - 1, coordinate2.Y + 1, Color.White);
                    image.Image.SetPixel(coordinate2.X, coordinate2.Y + 1, Color.White);
                    image.Image.SetPixel(coordinate2.X + 1, coordinate2.Y + 1, Color.White);

                    var fromCoordinate = new Coordinate(coordinate2.X, coordinate2.Y);
                    var toCoordinate = new Coordinate(coordinate2.X + deltaX, coordinate2.Y + deltaY);
                    Algorithms2D.Line(fromCoordinate, toCoordinate, setPixelFunc);

                    image.Image.SetPixel(toCoordinate.X - 1, toCoordinate.Y - 1, Color.White);
                    image.Image.SetPixel(toCoordinate.X - 2, toCoordinate.Y - 2, Color.White);
                    image.Image.SetPixel(toCoordinate.X + 1, toCoordinate.Y - 1, Color.White);
                    image.Image.SetPixel(toCoordinate.X + 2, toCoordinate.Y - 2, Color.White);
                }
                image.Image.Save(fileName);
                UpdateStatus(LogType.JustMessage, string.Format(Resource.MainForm_SaveScanResultToFile_ScanResultsSaved,fileName));
            }
            catch (Exception exception)
            {
                UpdateStatus(LogType.JustMessage, string.Format("Save scan results exception. Error: {0}", exception.Message));
                Logger.LogError("Save scan results exception.", exception);
            }
        }
Esempio n. 11
0
        private bool IsEventWinPresent(Screenshot image, out Coordinate closeButton)
        {
            Coordinate btnClose = null;

            //Parallel.For(500, 1400 + 1, (i, s) =>
            for(int i=500;i<=Settings.BotPictureHeight-500;i++)
                                            {
                                                var coords = FindCloseButton(image, 2466, i, 10, 0);
                                                if (coords != null)
                                                {
                                                    btnClose = coords;
                                                    break;
                                                }
                                            };

            closeButton = btnClose;
            return false;
        }
Esempio n. 12
0
        private void ClickMilitaryItems(Screenshot image)
        {
            var closeButtonCoords = FindCloseButton(image, 2410, 835, 40, 40);
            var startingMilitaryItemButton = new Coordinate(closeButtonCoords.X - 864, 1142);
            const int distButtons = 178;
            var borderColor = Color.FromArgb(0, 0, 0).ToArgb();
            var activeBorderColor = Color.FromArgb(0, 0, 2).ToArgb();
            var readyColor = Color.FromArgb(177, 106, 49).ToArgb();
            var activeReadyColor = Color.FromArgb(219, 141, 63).ToArgb();
            var unlockColor = Color.FromArgb(117, 116, 115).ToArgb();
            var unlockWithDiamondColor = Color.FromArgb(112, 111, 110).ToArgb();
            for (int i = 0; i < 5; i++)
            {
                //updateStatus(LogType.JustMessage, string.Format("x={0},y={1}", startingMilitaryItemButton.X, startingMilitaryItemButton.Y));
                var pixel = image.GetPixelRgb(startingMilitaryItemButton.X, startingMilitaryItemButton.Y);

                if (pixel == borderColor || pixel == activeBorderColor)
                {
                    //updateStatus(LogType.JustMessage, string.Format("black color found.", i + 1));
                    var unlocked = false;
                    // unlock not working since there's no "moon sign" above the military barrack
                    if (false && Settings.DoMilitaryUnitsUnblock && pixel == unlockColor)
                    {
                        InjectClickAtInvokeForced(startingMilitaryItemButton.X + 50, startingMilitaryItemButton.Y);
                        unlocked = true;
                        UpdateStatus(LogType.JustMessage, string.Format("Unlocking military item #{0}", i + 1));
                        Sleeping(1000);
                    }

                    var pixelPlusOne = image.GetPixelRgb(startingMilitaryItemButton.X + 1, startingMilitaryItemButton.Y);
                    if (unlocked || pixelPlusOne == readyColor || pixelPlusOne == activeReadyColor)
                    {
                        InjectClickAtInvokeForced(startingMilitaryItemButton.X + 50, startingMilitaryItemButton.Y);
                        UpdateStatus(LogType.JustMessage, string.Format(Resource.MainForm_ClickMilitaryItems_MilitaryItemSelected, i + 1));
                        break;
                    }
                }

                startingMilitaryItemButton.X += distButtons;
            }
        }
Esempio n. 13
0
        private bool CheckForBlueScreen(Screenshot image)
        {
            var blueScreenColor = image.GetPixelRgb(25, 25);
            var surface = ((BitmapSurface)_aweWebView.Surface);
            int min = Math.Min(surface.Height, surface.Width);
            for (int i = 0; i < min;i++ )
                if(image.GetPixelRgb(i, i)!=blueScreenColor)
                    return false;

            return true;
        }