Beispiel #1
0
        public override IActionProperty CheckCondition(ref LockBitmap lockBitmap)
        {
            ActionProperty actionModel = new ActionProperty();

            byte[] pixels       = lockBitmap.Pixels;
            var    castSettings = ((PixelClickerPrototype.Settings)Settings);
            int    width        = lockBitmap.Width;
            var    points       = new List <DbscanPoint>();

            for (var n = pixels.Length - 1; n >= 0; n--)
            {
                var nMultiplied = n * 4;
                if (nMultiplied >= pixels.Length)
                {
                    continue;
                }

                if (!(pixels[nMultiplied + 2] >= 250 && pixels[nMultiplied + 1] <= 5 && pixels[nMultiplied] <= 20))
                {
                    continue;
                }

                var x = GetXFromByte(n, width);
                var y = GetYFromByte(n, x, width);

                points.Add(new DbscanPoint(x, y));
            }

            if (points.Count == 0)
            {
                return(actionModel);
            }
            var           heightAdjusted = Settings.SearchMethod != SearchMethod.AnyWhere ? 1.75 : 1;
            HighestLowest target         = CalculateTarget(points, heightAdjusted);

            if (target == null)
            {
                return(actionModel);
            }


            int healthBarHeight = GetHealthBarHeight(target, castSettings.MaximumHealthBarHeight);

            int offset = (castSettings.MaximumHealthBarHeight - healthBarHeight) * 4;

            actionModel.RelativeToScreenPoint =
                new Point(Settings.SearchPosition.X + target.HighestPoint.X,
                          Settings.SearchPosition.Y + target.HighestPoint.Y);

            actionModel.AimPoint = new Point(target.HighestPoint.X + (castSettings.XOffset - offset),
                                             target.HighestPoint.Y + (castSettings.YOffset - offset));

            actionModel.Settings   = castSettings;
            actionModel.DoAction   = true;
            actionModel.Time       = DateTime.Now;
            actionModel.PointsInfo = target;


            return(actionModel);
        }
Beispiel #2
0
        private int GetHealthBarHeight(HighestLowest target, int maxHeight)
        {
            int healthBarHeight = Math.Abs(target.HighestPoint.Y - target.LowestPoint.Y);

            return(healthBarHeight >= maxHeight ? maxHeight : healthBarHeight);
        }
Beispiel #3
0
 private int GetHealthBarWidth(HighestLowest target)
 {
     return(Math.Abs(target.HighestPoint.X - target.LowestPoint.X));
 }