Example #1
0
        /// <summary>
        /// Determines if a bank slot is occupied by an empty placeholder
        /// </summary>
        /// <param name="screen">image of the entire game screen</param>
        /// <returns></returns>
        public bool SlotIsEmpty(int x, int y, Color[,] screen)
        {
            Rectangle counterOffset = new Rectangle(-16, -17, 8, 11);
            Point     slotLocation  = ItemSlotLocation(x, y).Value;
            int       left          = slotLocation.X + counterOffset.X;
            int       right         = slotLocation.X + counterOffset.X + counterOffset.Width;
            int       top           = slotLocation.Y + counterOffset.Y;
            int       bottom        = slotLocation.Y + counterOffset.Y + counterOffset.Height;

            if (screen == null)
            {
                screen = ScreenScraper.GetRGB(ScreenScraper.CaptureWindow());
            }
            screen = ImageProcessing.ScreenPiece(screen, left, right, top, bottom);
            double slotCounterMatch = ImageProcessing.FractionalMatch(screen, RGBHSBRangeFactory.BankSlotPlaceholderZero());

            return(slotCounterMatch > 0.1);
        }