Example #1
0
        public Room(int id, Map map, MapCoord topLeft, int width, int height) : base(id, map, SPACE_TYPE.ROOM)
        {
            border     = new List <Border> ();
            neighbours = new List <Space> ();
            doors      = new List <Border>();

            MapCoord pos = topLeft;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    Tile tile = map.tile(pos);
                    if ((tile.space != null) && (tile.space.space_id != this.space_id))
                    {
                        //merge overlaping rooms
                        assimilateRoom(tile.space);
                    }

                    tile.space      = this;
                    tile.occupation = Constants.TILE_TYPE.ROOM;
                    this.tiles.Add(tile);

                    //walk right
                    pos = pos.n_right;
                }
                //walk down and to the left
                pos   = pos.n_down;
                pos.x = topLeft.x;
            }
        }
Example #2
0
 public bool isInside(MapCoord coord)
 {
     if ((coord.x < 0) || (coord.x >= width) ||
         (coord.y < 0) || (coord.y >= height))
     {
         return(false);
     }
     return(true);
 }
Example #3
0
        public Tile(int x, int y, Map map)
        {
            this.map   = map;
            occupation = TILE_TYPE.EMPTY;
            this.coord = new MapCoord(x, y);

            setStartingPassages();
            this.doors = DIRECTION_NONE;
        }
Example #4
0
 public Tile tile(MapCoord coord)
 {
     if (!isInside(coord))
     {
         return(null);
     }
     try {
         return(mapGrid[coord.x, coord.y]);
     } catch (System.IndexOutOfRangeException e) {
         Debug.Log(e.StackTrace);
         Debug.Log(coord);
         return(null);
     }
 }
Example #5
0
        public static bool checkArea(MapCoord topLeft, int width, int height, Map map, Constants.TILE_TYPE[] allowed)
        {
            MapCoord pos = topLeft;
            List <Constants.TILE_TYPE> allowable = new List <Constants.TILE_TYPE>(allowed);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    Tile tile = map.tile(pos);
                    if ((tile == null) || (!allowable.Contains(tile.occupation)))
                    {
                        return(false);
                    }

                    //walk right
                    pos = pos.n_right;
                }
                //walk down and to the left
                pos   = pos.n_down;
                pos.x = topLeft.x;
            }
            return(true);
        }