Example #1
0
        private void GenerateLevel()
        {
            Tilemap.FillWithTile(Bounds, Tile.TileType.wall);
            ChamberTree = new ChamberTree(Bounds.Size, dungeon.MinRooms, dungeon.MaxRooms, dungeon.MinRoomWidth, dungeon.MaxRoomWidth,
                                          dungeon.MinRoomHeight, dungeon.MaxRoomHeight, dungeon.ForceRegularRooms);
            ChamberTree.FillChambersWithTile(Tile.TileType.floor, Tilemap);
            ChamberTree.FillPassagesWithTile(Tile.TileType.floor, Tilemap);

            Entrance = new Point(ChamberTree.StartingChamber.Center.X, ChamberTree.StartingChamber.Center.Y);

            if (Utilities.PassPercentileRoll(dungeon.CaveChance))
            {
                CellularAutomata.ErodeTiles(Tilemap);
            }

            PlaceObject(TryPlaceStairsDown, 1);

            int monsters = (int)(dungeon.MonstersPerRoom * ChamberTree.Chambers.Count);

            PlaceObject(TryPlaceMonster, monsters);

            int weapons = (int)(dungeon.WeaponsPerRoom * ChamberTree.Chambers.Count);

            PlaceObject(TryPlaceItem, weapons);

            int plants = (int)(dungeon.PlantsPerRoom * ChamberTree.Chambers.Count);

            PlaceObject(TryPlacePlant, plants);
        }
Example #2
0
        private bool TryPlacePlant()
        {
            Point pos = Tilemap.RandomPosition(ChamberTree.GetRandomChamber());

            if (CanPlaceCreature(pos))
            {
                new HealingPlant(this, pos);
                return(true);
            }
            return(false);
        }
Example #3
0
        private bool TryPlaceItem()
        {
            Point pos = Tilemap.RandomPosition(ChamberTree.GetRandomChamber());

            if (CanPlaceItem(pos))
            {
                dungeon.Generator.NewWeapon(this, pos, LevelIndex);
                return(true);
            }
            return(false);
        }
Example #4
0
        private bool TryPlaceMonster()
        {
            Point pos = Tilemap.RandomPosition(ChamberTree.GetRandomChamber());

            if (CanPlaceCreature(pos))
            {
                Generator.NewRandomMonster(this, pos, LevelIndex);
                return(true);
            }
            return(false);
        }
Example #5
0
        private bool TryPlaceStairsDown()
        {
            Point pos  = ChamberTree.GetRandomChamber().Center;
            Tile  tile = Tilemap.GetTile(pos);

            if (tile.Type != Tile.TileType.wall)
            {
                Tilemap.SetTile(pos, Tile.TileType.exit);
                Exit = new Point(pos.X, pos.Y);
                return(true);
            }
            return(false);
        }