Esempio n. 1
0
    //Currently this cannot handle the alcoves whose adjacent tile through the opening has 2 or less
    //Also this currently identifies alcoves by setting their rendering to none, this was just for testing purposes
    void find_alcoves()
    {
        Direction d = Direction.none;

        for (int y = 0; y < size; y++)
        {
            for (int x = 0; x < size; x++)
            {
                tile t = maze [y, x];

                byte count = 0;

                if (t.get_northwall() == tile.Wall.wall)
                {
                    count++;
                }
                else
                {
                    d = Direction.north;
                }

                if (t.get_westwall() == tile.Wall.wall)
                {
                    count++;
                }
                else
                {
                    d = Direction.west;
                }

                if (t.get_eastwall() == tile.Wall.wall)
                {
                    count++;
                }
                else
                {
                    d = Direction.east;
                }
                if (t.get_southwall() == tile.Wall.wall)
                {
                    count++;
                }
                else
                {
                    d = Direction.south;
                }

                //It should max be 3.
                if (count == 3)
                {
                    if (d == Direction.north && get_num_walls(maze [y - 1, x]) == 2)
                    {
                        continue;
                    }
                    else if (d == Direction.west && get_num_walls(maze [y, x - 1]) == 2)
                    {
                        continue;
                    }
                    else if (d == Direction.east && get_num_walls(maze [y, x + 1]) == 2)
                    {
                        continue;
                    }
                    else if (d == Direction.south && get_num_walls(maze [y + 1, x]) == 2)
                    {
                        continue;
                    }

                    t.set_type(tile.Type.alcove);
                    //t.set_contains("hedge");
                }
            }
        }
    }