Example #1
0
        protected void ScanSP(FastBitmapHSV bitmap, ScreenDataBase screenData)
        {
            int  numMatchFull  = 0;
            int  numMatchEmpty = 0;
            int  numChanges    = 0;
            bool wasFull       = false;
            bool wasEmpty      = false;

            int lastPosFull = 0;

            for (int idx = 0; idx <= rectSPBar.Width; idx++)
            {
                var testPx = bitmap.GetPixel(rectSPBar.X + idx, rectSPBar.Y);

                var isFull  = matchSPFull.IsMatching(testPx);
                var isEmpty = matchSPEmpty.IsMatching(testPx);

                if (isFull)
                {
                    lastPosFull = idx;
                }

                numChanges    += (idx > 0 && isFull != wasFull) ? 1 : 0;
                numChanges    += (idx > 0 && isEmpty != wasEmpty) ? 1 : 0;
                numMatchFull  += isFull ? 1 : 0;
                numMatchEmpty += isEmpty ? 1 : 0;

                wasFull  = isFull;
                wasEmpty = isEmpty;
            }

            float matchedPct = (numMatchEmpty + numMatchFull) / (float)rectSPBar.Width;

            screenData.SPIsValid      = (matchedPct > 0.75);
            screenData.SPFillPct      = lastPosFull / (float)rectSPBar.Width;
            screenData.SPIsObstructed = (matchedPct < 0.95);

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} HasSP: {1}, isObstructed:{2}, fillPct:{3}", ScannerName, screenData.SPIsValid, screenData.SPIsObstructed, screenData.SPFillPct);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                for (int idx = 0; idx < rectSPBar.Width; idx++)
                {
                    var testPx = bitmap.GetPixel(rectSPBar.X + idx, rectSPBar.Y);
                    Console.WriteLine("  X:{0},Y:{1} = {2} => Full:{3}, Empty:{4}",
                                      rectSPBar.X + idx, rectSPBar.Y,
                                      testPx,
                                      matchSPFull.IsMatching(testPx),
                                      matchSPEmpty.IsMatching(testPx));
                }

                Console.WriteLine("  filterFull({0}), filterEmpty({1})", matchSPFull, matchSPEmpty);
                Console.WriteLine("  numMatchFull: {0}, numMatchEmpty: {1}, matchedPct: {2}, numChanges:{3}",
                                  numMatchFull, numMatchEmpty, matchedPct, numChanges);
            }
        }
Example #2
0
        protected void ScanSummonSelector(FastBitmapHSV bitmap, ScreenDataBase screenData)
        {
            var avgPx          = ScreenshotUtilities.GetAverageColor(bitmap, rectSummonSelectorA);
            var iconFillPct    = ScreenshotUtilities.CountFillPct(bitmap, rectSummonSelectorB, matchSummonIcon);
            var isAvgMatching  = matchSummonBack.IsMatching(avgPx);
            var isIconMatching = (iconFillPct > 0.10f) && (iconFillPct < 0.35f);

            screenData.hasSummonSelection = isAvgMatching && isIconMatching;

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} ScanSummonSelector: {1}", ScannerName, screenData.hasSummonSelection);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                Console.WriteLine("  avgPx: ({0}) vs ({1}) => {2}, fillIcon: {3} => {4}",
                                  avgPx, matchSummonBack, isAvgMatching,
                                  iconFillPct, isIconMatching);
            }
        }
Example #3
0
 public CollectablesController(ScreenDataBase _screenData)
 {
     screenData = _screenData;
 }