Beispiel #1
0
        public Map(World world, string name, int width, int height, Random random)
        {
            Height = height;
            Name = name;
            Width = width;

            _random = random;
            _connections = new List<MapConnection>(256);
            _items = new List<Item>();
            _mobiles = new List<Mobile>();
            _tiles = new Tile[width * height];
            _world = world;

            for (var i = 0; i < TileCount; ++i)
            {
                _tiles[i] = new Tile();
                _tiles[i].Position = IndexToPoint(i);
            }
        }
Beispiel #2
0
 public MainGame()
 {
     _world = new World(this);
 }
Beispiel #3
0
 public static Map FromDungeonGenerator2(World world, string name, int width, int height, uint seed, Random random)
 {
     var map = new Map(world, name, width, height, random);
     var dungeon = new DungeonGenerator2.Dungeon(new Random(), (foo) => { Console.WriteLine(foo); });
     dungeon.CreateDungeon(width, height, 100);
     for (var x = 0; x < width; ++x)
     {
         for (var y = 0; y < height; ++y)
         {
             var dungeonIndex = y * width + x;
             var dungeonTile = dungeon[dungeonIndex];
             if (dungeonTile == DungeonGenerator2.Tile.DirtWall || dungeonTile == DungeonGenerator2.Tile.StoneWall)
             {
                 map.AddTile(Tile.GetRandomTile("DungeonWall"), new Point(x, y));
             }
             else if (dungeonTile == DungeonGenerator2.Tile.Door)
             {
                 map.AddTile(Tile.GetRandomTile("Door_01"), new Point(x, y));
             }
             else if (dungeonTile == DungeonGenerator2.Tile.DirtFloor || dungeonTile == DungeonGenerator2.Tile.StoneFloor || dungeonTile == DungeonGenerator2.Tile.Corridor)
             {
                 map.AddTile(Tile.GetRandomTile("DungeonFloor"), new Point(x, y));
             }
         }
     }
     return map;
 }
Beispiel #4
0
        public static Map FromDungeonGenerator3(World world, string name, int width, int height, uint seed, Random random)
        {
            var map = new Map(world, name, width, height, random);
            var dungeon = new DungeonGenerator3.MapBuilder(width, height);
            dungeon.Build_OneStartRoom();

            for (var x = 0; x < width; ++x)
            {
                for (var y = 0; y < height; ++y)
                {
                    var dungeonIndex = y * width + x;
                    var dungeonTile = dungeon._map[x, y];
                    if (dungeonTile == 1)
                    {
                        map.AddTile(Tile.GetRandomTile("DungeonWall"), new Point(x, y));
                    }
                    else
                    {
                        map.AddTile(Tile.GetRandomTile("DungeonFloor"), new Point(x, y));
                    }
                }
            }
            return map;
        }
Beispiel #5
0
        public static Map FromDungeonGenerator(World world, string name, int width, int height, uint seed, Random random)
        {
            var map = new Map(world, name, width, height, random);
            var dungeonSettings = Dungeon.Generator.GeneratorParams.Default;
            dungeonSettings.RoomChance = 0.9f;

            //TODO(philipp): either find a better dungeon generator, or fix this shit here, that it works with our map sizes (142,32)
            var dungeon = Dungeon.Generator.Generator.Generate(width, height, seed);
            for (var x = 0; x < width; ++x)
            {
                for (var y = 0; y < height; ++y)
                {
                    if (x >= dungeon.Width || y >= dungeon.Height)
                    {
                        continue;
                    }

                    var dungeonTile = dungeon[x, y];
                    if (dungeonTile.MaterialType == Dungeon.Generator.MaterialType.Wall)
                    {
                        map.AddTile(Tile.GetRandomTile("DungeonWall"), new Point(x, y));
                    }
                    else if (dungeonTile.MaterialType == Dungeon.Generator.MaterialType.Floor)
                    {
                        map.AddTile(Tile.GetRandomTile("DungeonFloor"), new Point(x, y));
                    }
                }
            }
            return map;
        }