/// <summary> /// Waits for the right-click popup to appear /// </summary> /// <param name="timeout"></param> /// <returns></returns> public virtual bool WaitForPopup(int timeout = 3000, CheckHeight checkHeight = CheckHeight.None) { Color[,] screen = null; Stopwatch watch = new Stopwatch(); watch.Start(); while (watch.ElapsedMilliseconds < timeout) { if (BotProgram.SafeWait(200)) { return(false); } screen = ScreenScraper.GetRGB(ScreenScraper.CaptureWindow()); if (PopupExists(screen) && PopupIsCorrectHeight(screen, checkHeight)) { return(true); } } return(false); }
/// <summary> /// Checks the area where the center of the bottom row of the popup is expected to be /// </summary> /// <param name="screen">the full game screen</param> /// <returns>true if the expected bottom row is found</returns> protected bool PopupIsCorrectHeight(Color[,] screen, CheckHeight checkHeight) { if (checkHeight == CheckHeight.None) { return(true); //No height checking needed } int left = XClick - MIN_WIDTH / 2; int right = XClick + MIN_WIDTH / 2; int top = Bottom - ROW_HEIGHT; double lastRow = ImageProcessing.FractionalMatchPiece(screen, RGBHSBRangeFactory.RightClickPopup(), left, right, top, Bottom); switch (checkHeight) { case CheckHeight.Half: return(lastRow > 0.5); case CheckHeight.Full: double belowPopup = ImageProcessing.FractionalMatchPiece(screen, RGBHSBRangeFactory.RightClickPopup(), left, right, top + ROW_HEIGHT, Bottom + ROW_HEIGHT); return(lastRow > 0.5 && belowPopup < 0.25); } return(false); //Should never reach here. }
void Start() { timer = winCondition; playerController = GameObject.Find("Player").GetComponent <PlayerController>(); checkHeight = GameObject.Find("CheckHeight").GetComponent <CheckHeight>(); }