Пример #1
0
        public bool AreInnerTilesBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);
            int top, right, left, bottom;
            top = theWallArray[0];
            right = theWallArray[1];
            bottom = theWallArray[2];
            left = theWallArray[3];

            for (int x = left + 1; x < right; x++)
            {
                for (int y = top + 1; y < bottom; y++)
                {
                    if (aMap[x, y].MyWalls.HasFlag(TheWalls.North) && !aMap[x, y - 1].MyWalls.HasFlag(TheWalls.South))
                    {
                        //Console.WriteLine("Broken tile (north south)");
                        return true;
                    }
                    if (aMap[x, y].MyWalls.HasFlag(TheWalls.South) && !aMap[x, y + 1].MyWalls.HasFlag(TheWalls.North))
                    {
                        //Console.WriteLine("Broken tile (south north)");
                        return true;
                    }
                    if (aMap[x, y].MyWalls.HasFlag(TheWalls.East) && !aMap[x + 1, y].MyWalls.HasFlag(TheWalls.West))
                    {
                        //Console.WriteLine("Broken tile (east west)");
                        return true;
                    }
                    if (aMap[x, y].MyWalls.HasFlag(TheWalls.West) && !aMap[x - 1, y].MyWalls.HasFlag(TheWalls.East))
                    {
                       //Console.WriteLine("broken tile (west east)");
                        return true;
                    }

                }

            }
            return false;
        }
Пример #2
0
        public bool AreCornersBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) || !aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.West))
            {
                return true;
            }
            if (!aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) || !aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.West))
            {
                return true;
            }

            if (!aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) || !aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.East))
            {
                return true;
            }

            if (!aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) || !aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.East))
            {
                return true;
            }
            return false;
        }
Пример #3
0
 public bool WestWallHasExit(Tile[,] aMap)
 {
     int width, height;
     width = aMap.GetLength(0);
     height = aMap.GetLength(1);
     for (int i = 0; i < height; i++)
     {
         if (aMap[0, i].MyWalls.HasFlag(TheWalls.End))
         {
             return true;
         }
     }
     return false;
 }
Пример #4
0
        public void TestOuterWalls(Tile[,] aMap)
        {
            int width, height, leftWall = 50, rightWall = 50, topWall = 50, bottomWall = 50;
            width = aMap.GetLength(0);
            height = aMap.GetLength(1);

            // determine where the exit is

            if (NorthWallHasExit(aMap))
            {
                topWall = 1;
            }
            else
            {
                topWall = 0;
            }

            if (SouthWallHasExit(aMap))
            {
                bottomWall = height - 2;
            }
            else
            {
                bottomWall = height - 1;
            }

            if (WestWallHasExit(aMap))
            {
                leftWall = 1;
            }
            else
            {
                leftWall = 0;
            }

            if (EastWallHasExit(aMap))
            {
                rightWall = width - 2;
            }
            else
            {
                rightWall = width - 1;
            }

            string corners = "";
            corners += "Top: " + topWall.ToString() + "\nBottom: " + bottomWall.ToString() + "\nLeft: " + leftWall.ToString() + "\nRight: " + rightWall.ToString();
            Console.WriteLine(corners);
        }
Пример #5
0
        public void TestCorners(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);
            if (aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) && aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.West))
            {
                Console.WriteLine("Top left corner fine");
            }
            else if (!aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) || !aMap[theWallArray[3], theWallArray[0]].MyWalls.HasFlag(TheWalls.West))
            {
                Console.WriteLine("Top left corner broken");
            }

            if (aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) && aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.West))
            {
                Console.WriteLine("Bottom left corner fine");
            }
            else if (!aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) || !aMap[theWallArray[3], theWallArray[2]].MyWalls.HasFlag(TheWalls.West))
            {
                Console.WriteLine("Bottom left corner broken");
            }

            if (aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) && aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.East))
            {
                Console.WriteLine("Top right corner fine");
            }
            else if (!aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.North) || !aMap[theWallArray[1], theWallArray[0]].MyWalls.HasFlag(TheWalls.East))
            {
                Console.WriteLine("Top Right corner broken");
            }

            if (aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) && aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.East))
            {
                Console.WriteLine("Bottom right corner fine");
            }
            else if (!aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.South) || !aMap[theWallArray[1], theWallArray[2]].MyWalls.HasFlag(TheWalls.East))
            {
                Console.WriteLine("Bottom right corner broken");
            }
        }
Пример #6
0
 public bool SouthWallHasExit(Tile[,] aMap)
 {
     int width, height;
     width = aMap.GetLength(0);
     height = aMap.GetLength(1);
     for (int i = 0; i < width; i++)
     {
         if (aMap[i, (height - 1)].MyWalls.HasFlag(TheWalls.End))
         {
             return true;
         }
     }
     return false;
 }
Пример #7
0
        public bool SouthWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!SouthWallHasExit(aMap))
            {
                if (!WestWallHasExit(aMap) && !EastWallHasExit(aMap))
                {
                    for (int i = 0; i <= theWallArray[1]; i++)
                    {
                        if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                        {
                            return true;
                        }
                    }
                }

                if (WestWallHasExit(aMap))
                {
                    for (int i = 1; i <= theWallArray[1]; i++)
                    {
                        if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                        {
                            return true;
                        }
                    }
                }

                if (EastWallHasExit(aMap))
                {
                    for (int i = 0; i <= theWallArray[1] - 1; i++)
                    {
                        if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                        {
                            return true;
                        }
                    }
                }

            }
            if (SouthWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[1]; i++)
                {
                    if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                    {
                        if (!aMap[i, theWallArray[2] + 1].MyWalls.HasFlag(TheWalls.End))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
Пример #8
0
        public int[] GetOuterWallArray(Tile[,] aMap)
        {
            int width, height, leftWall = 50, rightWall = 50, topWall = 50, bottomWall = 50;
            width = aMap.GetLength(0);
            height = aMap.GetLength(1);
            int[] theWallArray = new int[4];

            // determine where the exit is

            if (NorthWallHasExit(aMap))
            {
                topWall = 1;
            }
            else
            {
                topWall = 0;
            }

            if (SouthWallHasExit(aMap))
            {
                bottomWall = height - 2;
            }
            else
            {
                bottomWall = height - 1;
            }

            if (WestWallHasExit(aMap))
            {
                leftWall = 1;
            }
            else
            {
                leftWall = 0;
            }

            if (EastWallHasExit(aMap))
            {
                rightWall = width - 2;
            }
            else
            {
                rightWall = width - 1;
            }

            string corners = "";
            corners += "Top: " + topWall.ToString() + "\nBottom: " + bottomWall.ToString() + "\nLeft: " + leftWall.ToString() + "\nRight: " + rightWall.ToString();
            Console.WriteLine(corners);

            theWallArray[0] = topWall;
            theWallArray[1] = rightWall;
            theWallArray[2] = bottomWall;
            theWallArray[3] = leftWall;

            return theWallArray;
        }
Пример #9
0
        /*
        public void EastWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!EastWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[2]; i++)
                {
                    if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                    {
                        Console.WriteLine("East wall broken");
                    }
                }
            }
            if (EastWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[2]; i++)
                {
                    if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                    {
                        if (!aMap[theWallArray[1] + 1, i].MyWalls.HasFlag(TheWalls.End))
                        {
                            Console.WriteLine("East wall broken");

                        }
                    }
                }
            }
            //return false;
        }

        public void SouthWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);
            int width, height;
            width = aMap.GetLength(0);
            height = aMap.GetLength(1);

            if (!SouthWallHasExit(aMap))
            {
                for (int i = 0; i < theWallArray[1]; i++)
                {
                    if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                    {
                        //return true;
                        Console.WriteLine("South wall broken");
                    }
                }
            }
            if (SouthWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[1]; i++)
                {
                    if (!aMap[i, theWallArray[2]].MyWalls.HasFlag(TheWalls.South))
                    {
                        if (!aMap[i, theWallArray[2] + 1].MyWalls.HasFlag(TheWalls.End))
                        {
                            //return true;
                            Console.WriteLine("South wall broken");

                        }
                    }
                }
            }
           // return false;
        }
        public void NorthWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!NorthWallHasExit(aMap))
            {
                for (int i = 0; i < theWallArray[1]; i++)
                {
                    if (!aMap[i,theWallArray[0]].MyWalls.HasFlag(TheWalls.North))
                    {
                        //return true;
                        Console.WriteLine("North wall broken");
                    }
                }
            }
            if (NorthWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[1]; i++)
                {
                    if (!aMap[i, theWallArray[0]].MyWalls.HasFlag(TheWalls.North))
                    {
                        if (!aMap[i, theWallArray[0] - 1].MyWalls.HasFlag(TheWalls.End))
                        {
                            // return true;
                            Console.WriteLine("North wall broken");
                        }
                    }
                }
            }
            //return false;
        }

        public void WestWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!WestWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[2]; i++)
                {
                    if (!aMap[theWallArray[3], i].MyWalls.HasFlag(TheWalls.West))
                    {
                        Console.WriteLine("West wall broken");
                    }
                }
            }
            if (WestWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[2]; i++)
                {
                    if (!aMap[theWallArray[3], i].MyWalls.HasFlag(TheWalls.West))
                    {
                        if (!aMap[theWallArray[3] - 1, i].MyWalls.HasFlag(TheWalls.End))
                        {
                            Console.WriteLine("West wall broken");

                        }
                    }
                }
            }
            //return false;
        }
        */
        public bool EastWallBroken(Tile[,] aMap)
        {
            int[] theWallArray = GetOuterWallArray(aMap);

            if (!EastWallHasExit(aMap))
            {
                if (!NorthWallHasExit(aMap) && !SouthWallHasExit(aMap))
                {
                    for (int i = 0; i <= theWallArray[2]; i++)
                    {
                        if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                        {
                            return true;
                        }
                    }
                }

                if (NorthWallHasExit(aMap))
                {
                    for (int i = 1; i <= theWallArray[2]; i++)
                    {
                        if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                        {
                            return true;
                        }
                    }
                }
                if (SouthWallHasExit(aMap))
                {
                    for (int i = 0; i <= theWallArray[2] - 1; i++)
                    {
                        if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                        {
                            return true;
                        }
                    }
                }

            }
            if (EastWallHasExit(aMap))
            {
                for (int i = 0; i <= theWallArray[2]; i++)
                {
                    if (!aMap[theWallArray[1], i].MyWalls.HasFlag(TheWalls.East))
                    {
                        if (!aMap[theWallArray[1] + 1, i].MyWalls.HasFlag(TheWalls.End))
                        {
                            return true;

                        }
                    }
                }
            }
            return false;
        }
Пример #10
0
 /**** Test functions */
 public String TestMap(Tile[,] aMap)
 {
     string output = "";
     foreach (Tile tile in aMap)
     {
         output += tile.Coordinate + " " + tile.MyWalls + "\n";
     }
     output += "minotaur " + minotaur.Coordinate + "\n" + "theseus " + theseus.Coordinate;
     return output;
 }
Пример #11
0
 public bool HasExitTile(Tile[,] aMap)
 {
     for (int x = 0; x < aMap.GetLength(0); x++)
     {
         for (int y = 0; y < aMap.GetLength(1); y++)
         {
             if (aMap[x, y].MyWalls.HasFlag(TheWalls.End))
             {
                 return true;
             }
         }
     }
     return false;
 }
Пример #12
0
        protected Tile[,] CreateMap(int newWidth, int newHeight)
        {
            Tile[,] Map;
            int width = newWidth, height = newHeight;
            Map = new Tile[width, height];

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Map[x, y] = new Tile(x, y);
                }
            }
            return Map;
        }