private void VisualizeDeployPoints()
        {
            var clockwisePoints = GameGrid.RedPoints.OrderBy(point => Math.Atan2(point.X, point.Y)).ToList();
            var inflatedPoints  =
                clockwisePoints.Select(
                    point =>
                    new PointFT((float)(point.X + (point.X / Math.Sqrt(point.DistanceSq(new PointFT(0, 0)))) * 4),
                                (float)(point.Y + (point.Y / Math.Sqrt(point.DistanceSq(new PointFT(0, 0)))) * 4)))
                .ToList();

            using (Bitmap bmp = Screenshot.Capture())
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    foreach (PointFT redPoint in clockwisePoints)
                    {
                        Visualize.RectangleT(bmp, new RectangleT((int)redPoint.X, (int)redPoint.Y, 1, 1), new Pen(Color.FromArgb(128, Color.DarkRed)));
                    }

                    foreach (PointFT redPoint in inflatedPoints)
                    {
                        Visualize.RectangleT(bmp, new RectangleT((int)redPoint.X, (int)redPoint.Y, 1, 1), new Pen(Color.FromArgb(128, Color.DarkBlue)));
                    }
                }
                var d = DateTime.UtcNow;
                Screenshot.Save(bmp,
                                $"RedLineDeploy {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
            }
        }
        private void VisualizeDeployment()
        {
            using (var bmp = Screenshot.Capture())
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    // find the radius of 5 tiles
                    var p1       = new PointFT(0f, 0f).ToScreenAbsolute();
                    var p2       = new PointFT(0f, 5f).ToScreenAbsolute();
                    var distance = Math.Sqrt(Math.Pow(p2.X - p1.X, 2) + Math.Pow(p2.Y - p1.Y, 2));

                    Visualize.RectangleT(bmp, _border, new Pen(Color.FromArgb(128, Color.Red)));

                    g.DrawLine(new Pen(Color.FromArgb(192, Color.Red)), _attackLine.Item1.ToScreenAbsolute(), _attackLine.Item2.ToScreenAbsolute());

                    //foreach (PointFT point in _tankPoints)
                    //    Visualize.RectangleT(bmp, new RectangleT((int)point.X, (int)point.Y, 1, 1), new Pen(Color.Orange));

                    Visualize.RectangleT(bmp, new RectangleT((int)_qwPoint.X, (int)_qwPoint.Y, 1, 1), new Pen(Color.Blue));

                    Visualize.RectangleT(bmp, new RectangleT((int)_core.X, (int)_core.Y, 1, 1), new Pen(Color.Purple));

                    g.FillEllipse(new SolidBrush(Color.FromArgb(128, Color.Gold)),
                                  _healPoint.ToScreenAbsolute().ToRectangle((int)distance, (int)distance));

                    g.FillEllipse(new SolidBrush(Color.FromArgb(128, Color.Magenta)),
                                  _ragePoint.ToScreenAbsolute().ToRectangle((int)distance, (int)distance));

                    g.FillEllipse(new SolidBrush(Color.FromArgb(128, Color.Magenta)),
                                  _queenRagePoint.ToScreenAbsolute().ToRectangle((int)distance, (int)distance));
                }
                var d = DateTime.UtcNow;
                Screenshot.Save(bmp, $"Breakthrough Deploy {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
            }
        }
Пример #3
0
        public override IEnumerable <int> AttackRoutine()
        {
            // Bottom right side
            var rightBottom = new PointFT((float)GameGrid.MaxX - 2, (float)GameGrid.DeployExtents.MinY);
            var bottomRight = new PointFT((float)GameGrid.MinX + 8, (float)GameGrid.DeployExtents.MinY);

            var center = new PointFT(bottomRight.X + 0.5f * (rightBottom.X - bottomRight.X),
                                     bottomRight.Y + 0.5f * (rightBottom.Y - bottomRight.Y));

            // Screenshot for 3 points for the deployment line
            using (var bmp = Screenshot.Capture())
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    Visualize.RectangleT(bmp, new RectangleT((int)rightBottom.X, (int)rightBottom.Y, 1, 1), new Pen(Color.Blue));
                    Visualize.RectangleT(bmp, new RectangleT((int)bottomRight.X, (int)bottomRight.Y, 1, 1), new Pen(Color.Blue));

                    Visualize.RectangleT(bmp, new RectangleT((int)center.X, (int)center.Y, 1, 1), new Pen(Color.White));
                }
                var d = DateTime.UtcNow;
                Screenshot.Save(bmp, "Bottom Right {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
            }

            // Deploy troops
            var units = Deploy.GetTroops();

            units.OrderForDeploy();
            for (var i = 3; i >= 1; i--)
            {
                switch (i)
                {
                case 3:
                    point = rightBottom;
                    break;

                case 2:
                    point = bottomRight;
                    break;

                case 1:
                    point = center;
                    break;
                }

                foreach (var unit in units)
                {
                    if (unit?.Count > 0)
                    {
                        foreach (var t in Deploy.AtPoint(unit, point, unit.Count / i))
                        {
                            yield return(t);
                        }
                    }
                }
            }
        }
        private static void VisualizeTownhall()
        {
            var th = TownHall.Find();

            using (var bmp = Screenshot.Capture())
            {
                Visualize.Grid(bmp);
                Visualize.Axes(bmp);
                Visualize.RectangleT(bmp, th.Location);
                Screenshot.Show(bmp);
            }
        }
Пример #5
0
 public static void DebugBottomRightSidePoints()
 {
     using (var bmp = Screenshot.Capture())
     {
         using (var g = Graphics.FromImage(bmp))
         {
             var y = GameGrid.DeployExtents.MinY;
             var x = 18;
             while (x >= -15)
             {
                 Visualize.RectangleT(bmp, new RectangleT(x, y, 1, 1), new Pen(Color.Blue));
                 x--;
             }
         }
         var d = DateTime.UtcNow;
         Screenshot.Save(bmp, $"BottomRightPoints {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
     }
 }
Пример #6
0
        public static void DebugEQpells()
        {
            using (var bmp = Screenshot.Capture())
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    Visualize.RectangleT(bmp, new RectangleT((int)AllInOnePushDeploy.FirstFunnellingPoint.X, (int)AllInOnePushDeploy.FirstFunnellingPoint.Y, 1, 1), new Pen(Color.Blue));
                    Visualize.RectangleT(bmp, new RectangleT((int)AllInOnePushDeploy.SecondFunnellingPoint.X, (int)AllInOnePushDeploy.SecondFunnellingPoint.Y, 1, 1), new Pen(Color.Blue));

                    Visualize.RectangleT(bmp, new RectangleT((int)AllInOnePushDeploy.Origin.X, (int)AllInOnePushDeploy.Origin.Y, 1, 1), new Pen(Color.Red));


                    //draw rectangle around the target
                    Visualize.RectangleT(bmp, new RectangleT((int)AllInOnePushDeploy.Target.X, (int)AllInOnePushDeploy.Target.Y, 3, 3), new Pen(Color.Blue));

                    Visualize.CircleT(bmp, AllInOnePushDeploy.FirstJumpPoint, 3.5f, Color.DarkGreen, 100, 0);


                    Visualize.CircleT(bmp, AllInOnePushDeploy.EqPoint, 4, Color.SandyBrown, 100, 0);
                }
                var d = DateTime.UtcNow;
                Screenshot.Save(bmp, $"{AllInOnePushDeploy.AttackName} EQ Spells {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
            }
        }
        public override IEnumerable <int> AttackRoutine()
        {
            Log.Debug("[Snipe Deploy] Getting the best townhall deploy point.");
            var snipePoint = new Container <PointFT> {
                Item = GetTownHallDeployPoint()
            };

            Log.Debug($"[Snipe Deploy] Deploy point is ({snipePoint.Item})");

            var troops = Deploy.GetTroops();

            var hero = troops.GetQueen() ?? troops.GetKing() ?? troops.GetWarden();

            if (hero != null)
            {
                Log.Info("[Snipe Deploy] Deploying the " + hero.PrettyName + " to snipe.");
                foreach (var t in Deploy.AtPoint(hero, snipePoint))
                {
                    yield return(t);
                }

                hero.Recount();

                if (hero.Count > 0)
                {
                    var th = TownHall.Find();

                    using (var bmp = Screenshot.Capture(true))
                    {
                        Visualize.RectangleT(bmp, th.Location);
                        Visualize.RectangleT(bmp, new RectangleT((int)snipePoint.Item.X, (int)snipePoint.Item.Y, 1, 1));
                        var d = DateTime.UtcNow;
                        Screenshot.Save(bmp, $"Snipe Deploy_{d.Year}-{d.Month}-{d.Day}_{d.Hour}-{d.Minute}-{d.Second}");
                    }
                }

                yield return(5000);

                Deploy.WatchHeroes(new List <DeployElement> {
                    hero
                });

                var countdown = new Countdown(15.0);

                if (hero.Count < 1)
                {
                    while (countdown.IsRunning)
                    {
                        if (Attack.SurrenderIfWeHaveAStar())
                        {
                            yield break;
                        }
                        else
                        {
                            yield return(200);
                        }
                    }
                }
                else
                {
                    Log.Info("[Snipe Deploy] Hero failed to deploy; trying to use troops");
                }
            }

            var snipeTroops =
                troops.GetByAttackType(AttackType.Damage)
                .GetByType(DeployElementType.NormalUnit)
                .Where(u => u.UnitData?.TargetType == TargetType.Loot || u.UnitData?.TargetType == TargetType.None)
                .ToArray();

            if (snipeTroops.Length > 0)
            {
                Log.Info("[Snipe Deploy] Deploying troops to snipe.");

                var countdown = new Countdown(15.0, true);
                var pt        = new Container <PointFT> {
                    Item = GetTownHallDeployPoint()
                };
                while (true)
                {
                    if (countdown.IsFinished)
                    {
                        foreach (var t in Deploy.AtPoint(snipeTroops, snipePoint))
                        {
                            yield return(t);
                        }

                        snipeTroops.Recount();

                        if (snipeTroops.All(u => u.Count < 1))
                        {
                            yield break;
                        }

                        countdown.Restart();
                    }

                    if (Attack.SurrenderIfWeHaveAStar())
                    {
                        yield break;
                    }
                }
            }
        }
        /// <summary>
        /// Check to see how many collector and mine near to the redline by user defined distance
        /// </summary>
        /// <param name="userDistance">Minimum distance for exposed colloctors and mines</param>
        /// <param name="minCollectors">minimum exposed collectors</param>
        /// <param name="minMines">minimum exposed mines</param>
        /// <param name="AttackName">Attack name for logs and debugging</param>
        /// <param name="debug">debug mode in advanced settings</param>
        /// <returns>true if matches user defined min collectores and mines</returns>
        public static bool IsBaseMinCollectorsAndMinesOutside(int userDistance, int minCollectors, int minMines, string AttackName, int debug)
        {
            var distance = userDistance * userDistance;

            var redPoints = GameGrid.RedPoints.Where(
                point =>
                !(point.X > 18 && point.Y > 18 || point.X > 18 && point.Y < -18 || point.X < -18 && point.Y > 18 ||
                  point.X < -18 && point.Y < -18));

            var collectors = ElixirCollector.Find().Where(c => c.Location.GetCenter()
                                                          .DistanceSq(redPoints.OrderBy(p => p.DistanceSq(c.Location.GetCenter()))
                                                                      .FirstOrDefault()) <= distance);

            var mines = GoldMine.Find().Where(c => c.Location.GetCenter()
                                              .DistanceSq(redPoints.OrderBy(p => p.DistanceSq(c.Location.GetCenter()))
                                                          .FirstOrDefault()) <= distance);

            int collectorsCount = collectors != null?collectors.Count() : 0;

            int minesCount = mines != null?mines.Count() : 0;

            Log.Info($"{AttackName} NO. of Colloctors & mines near from red line:");
            Log.Info($"elixir colloctors is {collectorsCount}");
            Log.Info($"gold mines is {minesCount}");
            Log.Info($"----------------------------");
            Log.Info($"sum of all is {collectorsCount + minesCount}");

            if (debug == 1)
            {
                using (Bitmap bmp = Screenshot.Capture())
                {
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        foreach (var c in collectors)
                        {
                            var point = c.Location.GetCenter();
                            Visualize.RectangleT(bmp, new RectangleT((int)point.X, (int)point.Y, 2, 2), new Pen(Color.Blue));
                        }


                        foreach (var c in mines)
                        {
                            var point = c.Location.GetCenter();
                            Visualize.RectangleT(bmp, new RectangleT((int)point.X, (int)point.Y, 2, 2), new Pen(Color.White));
                        }
                    }
                    var d = DateTime.UtcNow;
                    Screenshot.Save(bmp, "Collectors and Mines {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}");
                }
            }

            if (collectorsCount >= minCollectors && minesCount >= minMines)
            {
                return(true);
            }
            else
            {
                Log.Warning($"{AttackName} this base doesn't meets Collocetors & Mines requirements");
                return(false);
            }
        }