Ejemplo n.º 1
0
		public static Level Generate(int width, int height)
		{
			DungeonGenerator.Instance.GenerateHauberkDungeon(width, height, 195000, 5, 5, 50, false, true);

			var tileData = DungeonGenerator._dungeon;
			var map = new Map (width, height);
			var tiles = new Tile[width, height];

			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					switch (tileData[x, y])
					{
						case TileType.Floor: 
							map.SetCellProperties (x, y, true, true); 
							break;
						case TileType.RoomFloor: 
							map.SetCellProperties(x, y, true, true); 
							break;
						case TileType.Wall: 
							map.SetCellProperties(x, y, false, false); 
							break;
						case TileType.Door: 
							map.SetCellProperties (x, y, false, false); 
							break;
					}
					tiles [x, y] = new Tile (tileData [x, y]);
				}
			}

			return new Level (map, tiles);
		}
Ejemplo n.º 2
0
        public T CreateMap()
        {
            var cave      = CellularAutomata.GenerateCaves(_width, _height, _density);
            var regionMap = MapFeatureDetector.GetRegions(cave);

            // Pick a random room to start and dig a tunnel to a random other room.
            // Go from there to another random room until all are connected.
            var roomCenters = GetRoomCenters(regionMap).ToList();
            var startPoint  = roomCenters[random.Next(roomCenters.Count)];

            roomCenters.Remove(startPoint);

            while (roomCenters.Count > 0)
            {
                var nextPoint = roomCenters[random.Next(roomCenters.Count)];
                roomCenters.Remove(nextPoint);
                cave       = CreatePath(cave, startPoint.X, startPoint.Y, nextPoint.X, nextPoint.Y);
                startPoint = nextPoint;
            }
            var map = new RogueSharp.Map(_width, _height);

            foreach (var cell in map.GetAllCells())
            {
                var open = cave[cell.X, cell.Y] == 0;
                map.SetCellProperties(cell.X, cell.Y, isTransparent: open, isWalkable: open, false);
            }

            return((T)(object)map);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create and return a deep copy of an existing Map
        /// </summary>
        /// <returns>IMap deep copy of the original Map</returns>
        public IMap Clone()
        {
            var map = new Map(Width, Height);

            foreach (ICell cell in GetAllCells())
            {
                map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, cell.IsExplored);
            }
            return(map);
        }
Ejemplo n.º 4
0
        public static Level Generate(GameWorld world, int width, int height, TextureAtlas atlas, int cellSize)
        {
            DungeonGenerator.Instance.GenerateHauberkDungeon(width, height, 195000, 5, 5, 50, false, true);

            var tileData = DungeonGenerator._dungeon;
            var map = new Map(width, height);
            var tiles = new Tile[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    Color color = Color.White;

                    switch (tileData[x, y])
                    {
                        case TileType.Floor:
                            map.SetCellProperties(x, y, true, true);
                            color = new Color(194, 194, 194);
                            break;
                        case TileType.RoomFloor:
                            map.SetCellProperties(x, y, true, true);
                            color = new Color(35, 255, 255);
                            break;
                        case TileType.Wall:
                            map.SetCellProperties(x, y, false, false);
                            color = new Color(163, 163, 163);
                            break;
                        case TileType.Door:
                            map.SetCellProperties(x, y, false, true);
                            color = new Color(132, 81, 0);
                            break;
                    }

                    tiles[x, y] = new Tile(tileData[x, y], color);
                    tiles[x, y].Cell = map.GetCell(x, y);
                }
            }

            var tilemap = new Tilemap(atlas, width, height, atlas.SpriteSize, cellSize, tiles);

            return new Level(world, map, tilemap);
        }
Ejemplo n.º 5
0
        public static Dungeon Generate(int width, int height)
        {
            DungeonGenerator.Instance.GenerateHauberkDungeon(width, height, 195000, 5, 5, 50, false, true);
            var tiles = DungeonGenerator._dungeon;
            var map = new RogueSharp.Map(width, height);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    switch (tiles[x, y])
                    {
                        case TileType.Floor: map.SetCellProperties(x, y, true, true); break;
                        case TileType.RoomFloor: map.SetCellProperties(x, y, true, true); break;
                        case TileType.Wall: map.SetCellProperties(x, y, false, false); break;
                        case TileType.Door: map.SetCellProperties(x, y, false, false); break;
                    }
                }
            }
            return new Map(tiles, map);
        }
Ejemplo n.º 6
0
 static void Main(string[] args)
 {
     DungeonGenerator.Instance.GenerateHauberkDungeon(101, 101, 195000, 5, 5, 50, false, true);
     _map = DungeonGenerator._dungeon;
     map = new Map(101, 101);
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             switch (_map[x, y])
             {
                 case Tile.Floor: map.SetCellProperties(x, y, true, true); break;
                 case Tile.RoomFloor: map.SetCellProperties(x, y, true, true); break;
                 case Tile.Wall: map.SetCellProperties(x, y, false, false); break;
                 case Tile.Door: map.SetCellProperties(x, y, false, false); break;
             }
         }
     }
     rootConsole.Update += rootConsole_Update;
     rootConsole.Render += rootConsole_Render;
     rootConsole.Run();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create and return a deep copy of an existing Map
 /// </summary>
 /// <returns>IMap deep copy of the original Map</returns>
 public IMap Clone()
 {
     var map = new Map( Width, Height );
      foreach ( Cell cell in GetAllCells() )
      {
     map.SetCellProperties( cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, cell.IsExplored );
      }
      return map;
 }