public static LavaPool Create(Vector2 v0, Vector2 v1) { float left = Math.Min(v0.X, v1.X); float right = Math.Max(v0.X, v1.X); float bottom = Math.Min(v0.Y, v1.Y); float top = Math.Max(v0.Y, v1.Y); MeshObject meshObject = SceneGenUtils.MakeFloor(left, right, bottom, top, -3.9f, Assets.lavaTexture, true, 50f); return(new LavaPool(meshObject) { bounds = new RectangleF(left, bottom, right - left, top - bottom) }); }
protected override void GenerateLayout(out bool[,] accessible, out bool[,,] corridorLayout, out float[,,] corridorWidths) { corridorLayout = SceneGenUtils.GenerateCorridorLayout(size, size, out accessible); corridorWidths = new float[size, size, 4]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int t = 0; t < 4; t++) { if (corridorLayout[x, y, t]) { corridorWidths[x, y, t] = 20f; } } } } }
protected override void GenerateLayout(out bool[,] accessible, out bool[,,] corridorLayout, out float[,,] corridorWidths) { corridorLayout = SceneGenUtils.GenerateCorridorLayout(size, size, out accessible); corridorWidths = new float[size, size, 4]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int t = 0; t < 4; t++) { if (corridorLayout[x, y, t]) { corridorWidths[x, y, t] = 10f; } } } } // Select two rooms connected with a corridor to join (5 tries, max 1 joint pair) for (int t = 0; t < 5; t++) { int x = rand.Next(size); int y = rand.Next(size); int d = rand.Next(4); if (corridorLayout[x, y, d] && (x != size / 2 || y != size / 2)) { Point[] shift = new Point[4] { new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(0, -1) }; if (x + shift[d].X != size / 2 || y + shift[d].Y != size / 2) { corridorWidths[x, y, d] = 80f; corridorWidths[x + shift[d].X, y + shift[d].Y, d ^ 2] = 80f; break; } } } }
protected override PopulateRoomResults PopulateRoom(Scene scene, Zone zone, int x, int y, PopulateSchemeFlags flags) { PopulateRoomResults results = new PopulateRoomResults { GenerateFloor = true }; float left = x * tileSize - size * tileSize / 2; float right = left + tileSize; float bottom = y * tileSize - size * tileSize / 2; float top = bottom + tileSize; Vector3 roomCenter = new Vector3((left + right) / 2, 0f, (top + bottom) / 2); bool[] roomCorridors = Enumerable.Range(0, 4).Select(t => corridorLayout[x, y, t]).ToArray(); if ((x != exitRoom.X || y != exitRoom.Y) && (x != size / 2 || y != size / 2)) { int monsterCount = rand.Next(2, monstersPerRoom + 1); game.PlayerStats.totalMonsters += monsterCount; List <Vector3> spawnPoints = new List <Vector3>(); Vector2 shift = monsterCount == 1 ? Vector2.Zero : new Vector2(30f, 0f); float angleOffset = (float)(rand.NextDouble() * Math.PI * 2f); for (int i = 0; i < monsterCount; i++) { Vector2 position = new Vector2(roomCenter.X, roomCenter.Z); position += Vector2.Transform(shift, Mathg.RotationMatrix2D(angleOffset + i * (float)Math.PI * 2f / monsterCount)); Vector3 position3 = new Vector3(position.X, -1f, position.Y); Monster monster = Mathg.DiscreteChoiceFn(rand, new Func <Monster>[] { () => new BasicMonster(position3, monsterHP, monsterDamage), () => new BasicMonster(position3, monsterHP, monsterDamage), () => new ShotgunDude(position3, monsterHP, monsterDamage), () => new SpinnyBoi(position3, monsterHP * 2, monsterDamage), () => new Spooper(position3, monsterHP * 1.5f, monsterDamage) }, monsterChances); scene.AddGameObject(monster); } } if (rand.Next(7) == 0) { SceneStructures.PitWithBridges(FloorTexture, WallTexture, FloorTexture, roomCorridors).Invoke(scene, zone, roomCenter); SceneGenUtils.AddFloor(zone, -50f * Vector2.One, 50f * Vector2.One, -10f, Assets.lavaTexture, true, roomCenter, 75f); results.GenerateFloor = false; } else if (rand.Next(3) == 0) { if (x != size / 2 || y != size / 2) { SpawnPools(scene, x, y, roomCenter, flags); } List <Generator> generators = new List <Generator> { SceneStructures.Pillars4Inner(WallTexture), SceneStructures.Pillars4Outer(WallTexture) }; if (flags.ClearCenter) { generators.Add(SceneStructures.PillarBig(WallTexture)); generators.Add(SceneStructures.PillarSmall(WallTexture)); } Mathg.DiscreteChoice(rand, generators).Invoke(scene, zone, roomCenter); } return(results); }
protected override Collectible.Type?[,] DistributeCollectibles() { return(SceneGenUtils.DistributeCollectibles(rand, size, exitRoom, accessible)); }