void CreateDebugImages()
        {
            List <InfernoTower>  infernos       = InfernoTower.Find(CacheBehavior.Default).ToList();
            List <WizardTower>   wizTowers      = WizardTower.Find(CacheBehavior.Default).ToList();
            List <ArcherTower>   archerTowers   = ArcherTower.Find(CacheBehavior.Default).ToList();
            List <ElixirStorage> elixirStorages = ElixirStorage.Find(CacheBehavior.Default).ToList();
            EagleArtillery       eagle          = EagleArtillery.Find(CacheBehavior.Default);

            var d             = DateTime.UtcNow;
            var debugFileName = $"Dragon Deploy {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}";

            using (Bitmap canvas = Screenshot.Capture())
            {
                Screenshot.Save(canvas, $"{debugFileName}_1");

                //Draw some stuff on it.
                Visualize.Axes(canvas);
                Visualize.Grid(canvas, redZone: true);
                Visualize.Target(canvas, mainTarget.Center, 40, Color.Red);
                Visualize.Target(canvas, deFunnelPoints[0], 40, Color.White);
                Visualize.Target(canvas, deFunnelPoints[1], 40, Color.White);
                Visualize.Target(canvas, balloonFunnelPoints[0], 40, Color.Pink);
                Visualize.Target(canvas, balloonFunnelPoints[1], 40, Color.Pink);

                for (int i = 0; i < infernos.Count(); i++)
                {
                    Visualize.Target(canvas, infernos.ElementAt(i).Location.GetCenter(), 30, Color.Orange);
                }

                for (int i = 0; i < airDefenses.Count(); i++)
                {
                    Visualize.Target(canvas, airDefenses.ElementAt(i).Location.GetCenter(), 30, Color.Cyan);
                }

                for (int i = 0; i < wizTowers.Count(); i++)
                {
                    Visualize.Target(canvas, wizTowers.ElementAt(i).Location.GetCenter(), 30, Color.Purple);
                }

                for (int i = 0; i < archerTowers.Count(); i++)
                {
                    Visualize.Target(canvas, archerTowers.ElementAt(i).Location.GetCenter(), 30, Color.RosyBrown);
                }

                if (eagle != null)
                {
                    Visualize.Target(canvas, eagle.Location.GetCenter(), 30, Color.YellowGreen);
                }

                Visualize.Target(canvas, mainTarget.DeployGrunts, 40, Color.Beige);

                Screenshot.Save(canvas, $"{debugFileName}_2");
            }

            //Write a text file that goes with all images that shows what is in the image.
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < airDefenses.Count(); i++)
            {
                sb.AppendLine($"Air Defense {i + 1} - Level:{airDefenses.ElementAt(i).Level}");
            }

            for (int i = 0; i < infernos.Count(); i++)
            {
                sb.AppendLine($"Inferno Tower {i + 1} - Level:{infernos.ElementAt(i).Level}");
            }

            for (int i = 0; i < wizTowers.Count(); i++)
            {
                sb.AppendLine($"Wizard Tower {i + 1} - Level:{wizTowers.ElementAt(i).Level}");
            }

            for (int i = 0; i < archerTowers.Count(); i++)
            {
                sb.AppendLine($"Archer Tower {i + 1} - Level:{archerTowers.ElementAt(i).Level}");
            }

            if (eagle != null)
            {
                sb.AppendLine($"Eagle Artillery 1 - Level:{eagle.Level}");
            }

            //System.IO.File.WriteAllText($@"C:\RaccoonBot\Debug Screenshots\{debugFileName}_3.txt", sb.ToString());

            Log.Info($"{Tag} Deploy Debug Image Saved!");
        }
Пример #2
0
        private static void OutputDebugImage(string algorithmName, List <Building> buildings, List <Target> targetList, string AttackId)
        {
            var d             = DateTime.UtcNow;
            var debugFileName = $"{algorithmName} {d.Year}-{d.Month}-{d.Day} {d.Hour}-{d.Minute}-{d.Second}-{d.Millisecond}[{AttackId}]".GetSafeFilename();

            //Get a screen Capture of all targets we found...
            using (Bitmap canvas = Screenshot.Capture())
            {
                Screenshot.Save(canvas, $"{debugFileName}_1");

                Visualize.Axes(canvas);
                Visualize.Grid(canvas, redZone: true);

                //Draw the Max Outside Boundry For Deployment...
                for (int i = -35; i <= 35; i++)
                {
                    var color = Color.Magenta;
                    if (i % 2 == 0)
                    {
                        color = Color.LightPink;
                    }

                    float max = 30f;
                    DrawLine(canvas, color, SafePoint(max, i), SafePoint(max, i + 1));   //Top Left Side
                    DrawLine(canvas, color, SafePoint(i, max), SafePoint(i + 1, max));   //Top Right Side
                    DrawLine(canvas, color, SafePoint(i + 1, -max), SafePoint(i, -max)); //Bottom Left Side
                    DrawLine(canvas, color, SafePoint(-max, i + 1), SafePoint(-max, i)); //Bottom Right Side
                }

                //Temporary Draw all the Redpoints.
                foreach (var point in GameGrid.RedPoints)
                {
                    DrawPoint(canvas, Color.Red, point);
                }

                //Temporary Draw all the Greenpoints.
                foreach (var point in GreenPoints)
                {
                    DrawPoint(canvas, Color.Green, point);
                }

                foreach (var building in buildings)
                {
                    var color = Color.White;
                    if (building.GetType() == typeof(ElixirCollector) || building.GetType() == typeof(ElixirStorage))
                    {
                        color = Color.Violet;
                    }
                    if (building.GetType() == typeof(GoldMine) || building.GetType() == typeof(GoldStorage))
                    {
                        color = Color.Gold;
                    }
                    if (building.GetType() == typeof(DarkElixirDrill) || building.GetType() == typeof(DarkElixirStorage))
                    {
                        color = Color.Brown;
                    }

                    //Draw a target on each building.
                    Visualize.Target(canvas, building.Location.GetCenter(), 40, color);
                }
                //Save the Image to the Debug Folder...
                Screenshot.Save(canvas, $"{debugFileName}_2");
            }

            //Get a screen Capture of all targets we found...
            using (Bitmap canvas = Screenshot.Capture())
            {
                foreach (var target in targetList)
                {
                    var color = Color.White;
                    if (target.TargetBuilding.GetType() == typeof(ElixirCollector) || target.TargetBuilding.GetType() == typeof(ElixirStorage))
                    {
                        color = Color.Violet;
                    }
                    if (target.TargetBuilding.GetType() == typeof(GoldMine) || target.TargetBuilding.GetType() == typeof(GoldStorage))
                    {
                        color = Color.Gold;
                    }
                    if (target.TargetBuilding.GetType() == typeof(DarkElixirDrill) || target.TargetBuilding.GetType() == typeof(DarkElixirStorage))
                    {
                        color = Color.Brown;
                    }

                    //Draw a target on each building.
                    Visualize.Target(canvas, target.TargetBuilding.Location.GetCenter(), 40, color);
                    Visualize.Target(canvas, target.DeployGrunts, 20, color);
                    Visualize.Target(canvas, target.DeployRanged, 20, color);
                }
                //Save the Image to the Debug Folder...
                Screenshot.Save(canvas, $"{debugFileName}_3");
            }

            Log.Debug("[Berts Algorithms] Collector/Storage & Target Debug Images Saved!");
        }