Exemplo n.º 1
0
        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++;
        }
Exemplo n.º 2
0
        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);
            }
        }