public void DoScreenshot(NpcNameFinder npcNameFinder) { try { var npcs = npcNameFinder.RefreshNpcPositions(); var bitmap = npcNameFinder.Screenshot.Bitmap; using (var gr = Graphics.FromImage(bitmap)) { if (npcs.Count > 0) { var margin = 10; using (var whitePen = new Pen(Color.White, 3)) { npcs.ForEach(n => gr.DrawEllipse(whitePen, new Rectangle(n.ClickPoint.X - (margin / 2), n.ClickPoint.Y - (margin / 2), margin, margin))); } } using (var blackPen = new SolidBrush(Color.Black)) { gr.FillRectangle(blackPen, new Rectangle(new Point(bitmap.Width / 15, bitmap.Height / 40), new Size(bitmap.Width / 15, bitmap.Height / 40))); } } this.OnScreenChanged?.Invoke(this, new ScreenChangeEventArgs(npcNameFinder.Screenshot.ToBase64(Size))); } catch (Exception ex) { logger.LogError(ex.Message); } Thread.Sleep(1); }
public BotController(ILogger logger) { wowProcess = new WowProcess(logger); this.WowScreen = new WowScreen(logger); this.logger = logger; var frames = DataFrameConfiguration.ConfigurationExists() ? DataFrameConfiguration.LoadConfiguration() : new List <DataFrame>(); //config.CreateConfiguration(WowScreen.GetAddonBitmap()); AddonReader = new AddonReader(WowScreen, frames, logger); addonThread = new Thread(AddonRefreshThread); addonThread.Start(); // wait for addon to read the wow state while (AddonReader.PlayerReader.Sequence == 0 || !Enum.GetValues(typeof(PlayerClassEnum)).Cast <PlayerClassEnum>().Contains(AddonReader.PlayerReader.PlayerClass)) { logger.LogWarning("There is a problem with the addon, I have been unable to read the player class. Is it running ?"); Thread.Sleep(100); } npcNameFinder = new NpcNameFinder(wowProcess, AddonReader.PlayerReader, logger); ActionFactory = new ActionFactory(AddonReader, logger, wowProcess, npcNameFinder); screenshotThread = new Thread(ScreenshotRefreshThread); screenshotThread.Start(); }
public BotController(ILogger logger, IPPather pather) { wowProcess = new WowProcess(logger); wowProcess.KeyPress(ConsoleKey.F3, 400).Wait(); // clear target this.WowScreen = new WowScreen(logger); this.logger = logger; this.pather = pather; var frames = DataFrameConfiguration.ConfigurationExists() ? DataFrameConfiguration.LoadConfiguration() : new List <DataFrame>(); //config.CreateConfiguration(WowScreen.GetAddonBitmap()); AddonReader = new AddonReader(WowScreen, frames, logger); minimapNodeFinder = new MinimapNodeFinder(new PixelClassifier()); MinimapImageFinder = minimapNodeFinder as IImageProvider; addonThread = new Thread(AddonRefreshThread); addonThread.Start(); // wait for addon to read the wow state var sw = new Stopwatch(); sw.Start(); while (AddonReader.PlayerReader.Sequence == 0 || !Enum.GetValues(typeof(PlayerClassEnum)).Cast <PlayerClassEnum>().Contains(AddonReader.PlayerReader.PlayerClass)) { if (sw.ElapsedMilliseconds > 5000) { logger.LogWarning("There is a problem with the addon, I have been unable to read the player class. Is it running ?"); sw.Restart(); } Thread.Sleep(100); } logger.LogDebug($"Woohoo, I have read the player class. You are a {AddonReader.PlayerReader.PlayerClass}."); npcNameFinder = new NpcNameFinder(wowProcess, AddonReader.PlayerReader, logger); //ActionFactory = new GoalFactory(AddonReader, logger, wowProcess, npcNameFinder); screenshotThread = new Thread(ScreenshotRefreshThread); screenshotThread.Start(); }
public GoalFactory(AddonReader addonReader, ILogger logger, WowProcess wowProcess, NpcNameFinder npcNameFinder) { this.logger = logger; this.addonReader = addonReader; this.NpcNameFinder = npcNameFinder; this.wowProcess = wowProcess; }