Пример #1
0
		public void FillAreaWithTile(Point origin, int tilesWide, int tilesTall, MapTile tileTemplate)
		{
			Rectangle area = new Rectangle(origin.X, origin.Y, origin.X + tilesWide, origin.Y + tilesTall);
			for (int y = area.Y; y < area.Height; y++)
			{
				for (int x = area.X; x < area.Width; x++)
				{
					MapTileList mapTiles = GetMapTilesForLocation(x, y);
					MapTile tileToAdd = (MapTile)tileTemplate.Clone();
					mapTiles.Add(tileToAdd);
					_mapTileLocations[tileToAdd] = new Point(x, y);
				}
			}
		}
Пример #2
0
		public void WallInArea(int originX, int originY, int tilesWide, int tilesTall)
		{
			Rectangle area = new Rectangle(originX, originY, originX + tilesWide, originY + tilesTall);
			for (int y = area.Y; y < area.Height; y++)
			{
				for (int x = area.X; x < area.Width; x++)
				{
					if (x == area.X) // If we're on the left edge, add left wall
					{
						AddTileIfMatchNotAlreadyThere(x, y, new WallVerticalLeftTile());
						if (x > 0)
						{ AddTileIfMatchNotAlreadyThere(x-1, y, new WallVerticalRightTile()); }
					}
					if (x == area.Width-1)
					{
						AddTileIfMatchNotAlreadyThere(x, y, new WallVerticalRightTile());
						if (x < MAP_WIDTH_IN_TILES-1)
						{ AddTileIfMatchNotAlreadyThere(x+1, y, new WallVerticalLeftTile()); }
					}
					if (y == area.Y)
					{
						AddTileIfMatchNotAlreadyThere(x, y, new WallHorizontalTopTile());
						if (y > 0)
						{ AddTileIfMatchNotAlreadyThere(x, y-1, new WallHorizontalBottomTile()); }
					}
					if (y == area.Height-1)
					{
						AddTileIfMatchNotAlreadyThere(x, y, new WallHorizontalBottomTile()); 
						if (y < MAP_HEIGHT_IN_TILES-1)
						{ AddTileIfMatchNotAlreadyThere(x, y+1, new WallHorizontalTopTile()); }
					}
				}
			}
		}
Пример #3
0
		public void SetBaseAreaWithTile(Point origin, int tilesWide, int tilesTall, MapTile tileTemplate)
		{
			Rectangle area = new Rectangle(origin.X, origin.Y, origin.X + tilesWide, origin.Y + tilesTall);
			for (int y = area.Y; y < area.Height; y++)
			{
				for (int x = area.X; x < area.Width; x++)
				{
					MapTileList mapTiles = GetMapTilesForLocation(x, y);
					MapTile tileToAdd = (MapTile)tileTemplate.Clone();
					if (mapTiles.Count > 0)
					{
						_mapTileLocations.Remove(mapTiles[0]);
						mapTiles[0] = tileToAdd;
					}
					else
					{ mapTiles.Add(tileToAdd); }
					
					_mapTileLocations[tileToAdd] = new Point(x, y);
				}
			}
		}