Inheritance: Thing
Ejemplo n.º 1
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;
        }
        //UNTESTED -- doesn't work, need to create each tile separately - Harry
        public void CreateMap1()
        {
            Map1 = new Tile[4, 3];
            //[x,y] TheWalls.North | TheWalls.South |TheWalls.West | TheWalls.East |TheWalls.End
            Map1[0, 0] = new Tile(0, 0);
            Map1[0, 0].MyWalls.HasFlag(TheWalls.North | TheWalls.West);

            Map1[1, 0] = new Tile(1, 0);
            Map1[1, 0].MyWalls.HasFlag(TheWalls.North);

            Map1[2, 0] = new Tile(2, 0);
            Map1[2, 0].MyWalls.HasFlag(TheWalls.North | TheWalls.East);

            Map1[3, 0] = new Tile(3, 0);
            Map1[3, 0].MyWalls.HasFlag(TheWalls.None);

            Map1[0, 1] = new Tile(0, 1);
            Map1[0, 1].MyWalls.HasFlag(TheWalls.West);

            Map1[1, 1] = new Tile(1, 1);
            Map1[1, 1].MyWalls.HasFlag(TheWalls.North | TheWalls.South | TheWalls.East);

            Map1[2, 1] = new Tile(2, 1);
            Map1[2, 1].MyWalls.HasFlag(TheWalls.None);

            Map1[3, 1] = new Tile(3, 1);
            Map1[3, 1].MyWalls.HasFlag(TheWalls.North | TheWalls.South | TheWalls.East | TheWalls.End);

            Map1[0, 2] = new Tile(0, 2);
            Map1[0, 2].MyWalls.HasFlag(TheWalls.South | TheWalls.West);

            Map1[1, 2] = new Tile(1, 2);
            Map1[1, 2].MyWalls.HasFlag(TheWalls.South);

            Map1[2, 2] = new Tile(2, 2);
            Map1[2, 2].MyWalls.HasFlag(TheWalls.South | TheWalls.East);

            Map1[3, 2] = new Tile(3, 2);
            Map1[3, 2].MyWalls.HasFlag(TheWalls.None);
        }
Ejemplo n.º 3
0
 public void SelectTile(int theX, int theY)
 {
     theTile = theMap[theX, theY];
 }
Ejemplo n.º 4
0
        internal static String ObjectsToString(Tile[,] theMap, Theseus theTheseus, Minotaur theMinotaur)
        {
            string output = "";
            int width = theMap.GetLength(0);
            int height = theMap.GetLength(1);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    output += ".";
                    if (theMap[x, y].MyWalls.HasFlag(TheWalls.North))
                    {
                        output += "___";
                    }
                    else
                    {
                        output += "   ";
                    }

                }
                output += ".\n";

                for (int x = 0; x < width; x++)
                {
                    if (x != width - 1)
                    {
                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "|   ";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "    ";
                        }

                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "| X ";
                        }
                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "| X ";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "  X ";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "  X ";
                        }
                    }

                    if (x == width - 1)
                    {
                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "|    ";
                        }
                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "|   |";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "    |";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && !theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "     ";
                        }

                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "| X  ";
                        }
                        if (theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "| X  ";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "  X  ";
                        }
                        if (!theMap[x, y].MyWalls.HasFlag(TheWalls.West) && !theMap[x, y].MyWalls.HasFlag(TheWalls.East) && theMap[x, y].MyWalls.HasFlag(TheWalls.End))
                        {
                            output += "  X  ";
                        }
                    }

                    if (x == theMinotaur.Coordinate.X && y == theMinotaur.Coordinate.Y)
                    {
                        StringBuilder minoPosition = new StringBuilder(output);
                        minoPosition[output.Length - 2] = 'M';
                        output = minoPosition.ToString();
                    }
                    if (x == theTheseus.Coordinate.X && y == theTheseus.Coordinate.Y)
                    {
                        StringBuilder thesPosition = new StringBuilder(output);
                        thesPosition[output.Length - 2] = 'T';
                        output = thesPosition.ToString();
                    }
                }
                output += "\n";

            }

            // lowest row of map
            for (int x = 0; x < width; x++)
            {
                output += ".";
                if (theMap[x, height - 1].MyWalls.HasFlag(TheWalls.South))
                {
                    output += "___";
                }
                else
                {
                    output += "   ";
                }
            }
            output += ".";

            return output;
        }