private void SpawnWave(Entity entity) { var filter = CheckDistance(entity); MobRegistry.SetupForBiome(Run.Level.Biome.Id); var c = Rnd.Int(5, 11); for (var i = 0; i < c; i++) { Timer.Add(() => { var mob = MobRegistry.Generate(); entity.Area.Add(mob); var v = MobRegistry.FindFor(mob.GetType()); if (v?.NearWall ?? false) { mob.Center = Room.GetRandomFreeTileNearWall(filter) * 16; } else if (v?.AwayFromWall ?? false) { mob.Center = Room.GetRandomWallFreeTile(filter) * 16; } else { mob.Center = Room.GetRandomFreeTile(filter) * 16; } if (mob.TryGetComponent <ZAnimationComponent>(out var z)) { z.Animate(); } else if (mob.TryGetComponent <MobAnimationComponent>(out var m)) { m.Animate(); } var where = mob.Center; for (var j = 0; j < 8; j++) { var part = new ParticleEntity(Particles.Dust()); part.Position = where + Rnd.Vector(-8, 8); part.Particle.Scale = Rnd.Float(1f, 1.3f); part.Particle.Velocity = MathUtils.CreateVector(Rnd.AnglePI(), 40); Run.Level.Area.Add(part); part.Depth = 1; } Audio.PlaySfx("scroll"); }, (i) * 0.2f); } wave++; }
public override void Use(Entity entity, Item item) { if (!entity.TryGetComponent <RoomComponent>(out var r) || r.Room == null) { return; } var filter = CheckDistance(entity); MobRegistry.SetupForBiome(Run.Level.Biome.Id); for (var i = 0; i < Count; i++) { Timer.Add(() => { var mob = MobRegistry.Generate(); entity.Area.Add(mob); if (MobRegistry.FindFor(mob.GetType())?.NearWall ?? false) { mob.Center = r.Room.GetRandomFreeTileNearWall(filter) * 16; } else { mob.Center = r.Room.GetRandomFreeTile(filter) * 16; } var where = mob.Center; for (var j = 0; j < 8; j++) { var part = new ParticleEntity(Particles.Dust()); part.Position = where + Rnd.Vector(-8, 8); part.Particle.Scale = Rnd.Float(1f, 1.3f); part.Particle.Velocity = MathUtils.CreateVector(Rnd.AnglePI(), 40); Run.Level.Area.Add(part); part.Depth = 1; } Audio.PlaySfx("scroll"); }, (i - 1) * 0.2f); } }
public override void Paint(Level level, Room room) { var c = GetCenter(); Painter.Fill(level, new Rect().Setup(c.X - 2, c.Y - 2, 5, 5), Tile.WallA); Painter.Fill(level, new Rect().Setup(c.X - 1, c.Y - 1, 3, 3), Tiles.RandomFloor()); var placed = false; if (Rnd.Chance()) { placed = true; Painter.Set(level, new Dot(c.X, c.Y - 2), Tiles.RandomFloor()); } if (Rnd.Chance()) { placed = true; Painter.Set(level, new Dot(c.X, c.Y + 2), Tiles.RandomFloor()); } if (Rnd.Chance()) { placed = true; Painter.Set(level, new Dot(c.X - 2, c.Y), Tiles.RandomFloor()); } if (!placed || Rnd.Chance()) { Painter.Set(level, new Dot(c.X + 2, c.Y), Tiles.RandomFloor()); } Painter.Set(level, new Dot(c.X, c.Y), Tile.FloorD); // Tiles.RandomFloor()); MobRegistry.SetupForBiome(Biome.Tech); Painter.PlaceMobs(level, room); }