Example #1
0
        //private SearchParameters searchParameters;

        private void btnGenerateMap_Click(object sender, EventArgs e)
        {
            txtMap.Text = "";
            int height = 5;
            int width  = 7;

            // Start with a clear map (don't add any obstacles)
            InitializeMap(width, height);
            List <Point> path = new List <Point>();// pathFinder.FindPath();

            // Now add an obstacle
            Point startingLocation = new Point(0, 0);

            map[3, 2] = "X";

            CoverState cover = Cover.CalculateCover(startingLocation, map, null);

            txtMap.Text += ShowRoute("The algorithm should find a possible tiles, ignoring the obstacle:", startingLocation, path);
            txtMap.Text += Environment.NewLine;
            if (cover.IsInCover == true)
            {
                txtMap.Text += "The player is in cover. ";
                if (cover.InNorthCover == true)
                {
                    txtMap.Text += "North cover detected. ";
                }
                else if (cover.InEastCover == true)
                {
                    txtMap.Text += "East cover detected. ";
                }
                else if (cover.InSouthCover == true)
                {
                    txtMap.Text += "South cover detected. ";
                }
                else if (cover.InWestCover == true)
                {
                    txtMap.Text += "West cover detected. ";
                }
            }
            else
            {
                txtMap.Text += "The player is NOT in cover. ";
            }

            //// Create a barrier between the start and end points
            //InitializeMap(7, 5, Point.Empty, Point.Empty);
            //AddWallWithoutGap();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should not be able to find a route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            //// Create a maze with custom start and end points
            //InitializeMap(7, 5, new Point(0, 4), new Point(6, 4));
            //AddWallWithMaze();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            //// Create a maze with custom start and end points
            //InitializeMap(7, 5, new Point(0, 4), new Point(4, 2));
            //AddWallWithSpinningMaze();
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the barrier:", path);
            //txtMap.Text += Environment.NewLine;


            // Create a larger maze with custom start and end points
            //InitializeMap(70, 40, new Point(0, 0), new Point(69, 39), false);
            //AddRandomItems(70, 40, 40);
            //pathFinder = new PathFinding(searchParameters);
            //path = pathFinder.FindPath();
            //txtMap.Text += ShowRoute("The algorithm should be able to find a long route around the random blocks:", path);
            //txtMap.Text += Environment.NewLine;

            //Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();
        }