public GridDungeon[,] LoadRandomDungeonRooms(Engine.Object parent, RandomDungeonGenerator generator) { var roomGrid = new GridDungeon[generator.Width / 20, generator.Height / 10]; char[,] charGrid = generator.Generate(); for (int x = 0; x < generator.Width / 20; x++) { char[,] tempCharGrid = new char[20, 10]; for (int y = 0; y < generator.Height / 10; y++) { for (int k = 0; k < 20; k++) { for (int j = 0; j < 10; j++) { tempCharGrid[k, j] = charGrid[x * 20 + k, y * 10 + j]; } } //create objectgrid and pass char[,], so it gets loaded into the grid var room = new GridDungeon("randomRoom", parent, tempCharGrid, 96, 96); //set the boundingBox room.BoundingBox = new Rectangle(0, 0, 20 * 96, 10 * 96); //add room to the correct place int the roomGrid roomGrid[x, y] = room; } } return(roomGrid); }
private void loadRandomDungeon(Engine.ObjectGrid parent, RandomDungeonGenerator generator) { var rooms = LoadRandomDungeonRooms(parent, generator); for (int x = 0; x < rooms.GetLength(0); x++) { for (int y = 0; y < rooms.GetLength(1); y++) { parent.setTile(x + (int)generator.Position.X, y + (int)generator.Position.Y, rooms[x, y]); } } }
private IEnumerator Start() { mDungeonGenerator = new RandomDungeonGenerator(); TextAsset roomSetData = Resources.Load <TextAsset>("RoomSets/" + CurrentDungeonFloorData().roomSet); mRoomset = new RoomSet(); mRoomset.LoadFromTextAsset(roomSetData); mDungeon = mDungeonGenerator.GenerateDungeon(mRoomset, DungeonGenerationData()); mKillableMap = GetComponent <KillableMap>(); mKillableMap.SetupWithDungeon(mDungeon); mCollisionMap = GetComponent <CollisionMap>(); mCollisionMap.SetupWithSize(mDungeon.width, mDungeon.height); GenerateEnvironmentFromDungeon(mDungeon); PlaceAvatar(); // Provide some time after the avatar is generated for any of its setup (ie: quirk setup) // to impact dungeon generation yield return(null); // Special handling for the 'difficulty boost' effect DifficultyBoost db = GameObject.FindObjectOfType <DifficultyBoost>(); if (db != null) { db.ApplyQuirks(); yield return(null); } yield return(null); if (!IsPresetRoom()) { PlaceDeadEndInterests(); } PlaceTraps(); PlaceEnemies(); if (!IsPresetRoom()) { PlaceHearts(); PlaceExit(); QuirkSpecificSpawns(); } if (Game.instance.currentDungeonFloor == 5) { Game.instance.soundManager.PlayRandomMusicInCategory("BossMusic"); } else if (Game.instance.quirkRegistry.IsQuirkActive <GothQuirk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("GothMusic"); } else if (Game.instance.quirkRegistry.IsQuirkActive <OldTimeyQuirk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("OldTimey"); } else if (Game.instance.quirkRegistry.IsQuirkActive <Cowfolk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("Cowboy"); } else { Game.instance.soundManager.PlayRandomMusicInCategory("DungeonMusic"); } Game.instance.playerData.MarkDirty(); yield break; }