예제 #1
0
        /// <summary>
        /// Obtiene el poder de la batalla en la arena
        /// </summary>
        /// <returns></returns>
        public Tuple <int, int> GetDustPlayersPower()
        {
            Bitmap ScreenCapture = UtilsAdb.GetBitmapCapture();
            int    myPower       = -1;
            int    enemyPower    = -1;

            var text = OcrEngineResult(
                new Rectangle(200, 267, 134, 21),
                new EngineWhiteListConfig
            {
                Value = Config.GetCharWhitelistBattlePower()
            },
                ScreenCapture
                );

            int.TryParse(text, out myPower);

            text = OcrEngineResult(
                new Rectangle(440, 267, 134, 21),
                new EngineWhiteListConfig
            {
                Value = Config.GetCharWhitelistBattlePower()
            },
                ScreenCapture
                );

            int.TryParse(text, out enemyPower);

            string MyPower    = myPower.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de"));
            string EnemyPower = enemyPower.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de"));

            Writer.WriteWarning($"Mi poder: {MyPower}, poder enemigo: {EnemyPower}");

            return(new Tuple <int, int>(myPower, enemyPower));
        }
예제 #2
0
        /// <summary>
        /// Obtiene tu nivel de combate y el del enemigo
        /// </summary>
        /// <returns></returns>
        public Tuple <int, int> GetPlayersPower()
        {
            var ScreenCapture = UtilsAdb.GetBitmapCapture();
            int myPower       = -1;
            int enemyPower    = -1;

            var text = OcrEngineResult(
                new Rectangle(200, 272, 131, 20),
                new EngineWhiteListConfig
            {
                Value = Config.GetCharWhitelistBattlePower()
            },
                ScreenCapture
                );

            int.TryParse(text, out myPower);

            text = OcrEngineResult(
                new Rectangle(440, 272, 122, 20),
                new EngineWhiteListConfig
            {
                Value = Config.GetCharWhitelistBattlePower()
            },
                ScreenCapture
                );

            int.TryParse(text, out enemyPower);

            return(new Tuple <int, int>(myPower, enemyPower));
        }
예제 #3
0
 public HustleCastleBot()
 {
     navigation = new Navigation();
     ocr        = new UtilsOcr();
     config     = new ConfigurationFile();
     adb        = new UtilsAdb();
     writer     = new WriteHelper();
 }
예제 #4
0
        /// <summary>
        /// Obtiene las almas oscuras que tienes
        /// </summary>
        /// <returns></returns>
        public int GetDarkSouls()
        {
            int darkSouls = -1;

            var screenCapture = UtilsAdb.GetBitmapCapture();

            screenCapture = CropBitMap(screenCapture, new Rectangle(582, 296, 180, 26));

            //Borra la imagen de las almas para que no falle el ocr
            for (int i = 0; i < 180; i++)
            {
                if (!UtilsAdb.AreColorsSimilar(UtilsAdb.GetPixelColor(screenCapture, i, 25), Color.FromArgb(85, 66, 73)))
                {
                    for (int y = 0; y <= 25; y++)
                    {
                        int startPoint = i - 10;
                        for (int x = 0; x <= 24; x++)
                        {
                            try
                            {
                                screenCapture.SetPixel(startPoint, y, Color.FromArgb(0, 0, 0));
                            }
                            catch
                            {
                                //
                            }

                            startPoint++;
                        }
                    }
                    break;
                }
            }

            var text = OcrEngineResult(
                new Rectangle(),
                new EngineWhiteListConfig
            {
                Value = Config.GetCharWhitelistBattlePower()
            },
                screenCapture
                );

            int.TryParse(text, out darkSouls);

            return(darkSouls);
        }
예제 #5
0
        /// <summary>
        /// Instancia el ocr engine
        /// </summary>
        /// <param name="r"></param>
        /// <param name="config"></param>
        /// <param name="image"></param>
        /// <returns></returns>
        public string OcrEngineResult(Rectangle r, EngineWhiteListConfig config, Bitmap image = null)
        {
            using (var engine = CreateEngine())
            {
                engine.SetVariable(config.Variable, Config.GetCharWhitelistPortal());

                if (image == null)
                {
                    image = UtilsAdb.GetBitmapCapture();
                }

                var bitmapImage = GrayScaleFilter(CropBitMap(image, r));

                using (var img = PixConverter.ToPix(bitmapImage))
                {
                    using (var page = engine.Process(img, PageSegMode.SingleLine))
                    {
                        return(ToNumericOnly(page.GetText()));
                    }
                }
            }
        }
예제 #6
0
 public UtilsOcr()
 {
     UtilsAdb = new UtilsAdb();
     Config   = new ConfigurationFile();
     Writer   = new WriteHelper();
 }
예제 #7
0
 public Navigation()
 {
     WriteHelper = new WriteHelper();
     adb         = new UtilsAdb();
     ocr         = new UtilsOcr();
 }