Exemplo n.º 1
0
        public static void Make(Vector2 where, Area area, float r = Radius)
        {
            foreach (var p in area.Tagged[Tags.Projectile])
            {
                if (p.DistanceTo(where) <= r)
                {
                    ((Projectile)p).Break();
                }
            }

            foreach (var e in area.Tagged[Tags.MustBeKilled])
            {
                if (e.DistanceTo(where) <= r)
                {
                    e.GetAnyComponent <BodyComponent>()?.KnockbackFrom(where, 10f);
                }
            }

            for (var i = 0; i < 10; i++)
            {
                var a = i * 0.1f * Math.PI * 2 + Rnd.Float(-0.1f, 0.1f);
                AnimationUtil.PoofFrom(where + MathUtils.CreateVector(a, r - 8), where);
            }

            for (var i = 0; i < 10; i++)
            {
                var a = Rnd.AnglePI();
                var d = Rnd.Float(r);

                AnimationUtil.PoofFrom(where + MathUtils.CreateVector(a, d), where);
            }

            Camera.Instance.Shake(6);
        }
Exemplo n.º 2
0
            public override void Init()
            {
                base.Init();
                Self.counter++;

                if (Self.counter > 2)
                {
                    Self.counter = 0;

                    for (var i = 0; i < 10; i++)
                    {
                        Timer.Add(() => {
                            var projectile = Projectile.Make(Self, "small", Rnd.AnglePI(), Rnd.Float(1, 9));

                            projectile.Color           = ProjectileColor.Green;
                            projectile.Center          = Self.Center;
                            projectile.Spectral        = true;
                            projectile.BreaksFromWalls = false;
                            projectile.Depth           = Layers.Wall + 1;
                            projectile.Controller     += SlowdownProjectileController.Make(Rnd.Float(1f, 2f));
                            projectile.AddLight(32f, Projectile.GreenLight);
                        }, i * 0.1f);
                    }
                }
            }
Exemplo n.º 3
0
        private void Reset()
        {
            delay      = Rnd.Float(0, 5f);
            speed      = Rnd.Float(1f, 3f) * 20;
            angle      = Rnd.AnglePI();
            angleSpeed = Rnd.Float(1f, 8f);
            scale      = new Vector2(Rnd.Float(0.05f, 0.3f));
            t          = 0;

            float v = Rnd.Float(0.5f, 1f);

            color = new Color(v, v, v, Rnd.Float(0.4f, 0.9f));

            var wind = CalculateWind();
            var a    = wind.ToAngle() - Math.PI / 2;
            var w    = Display.Width * -0.75f;
            var d    = Rnd.Float(-w / 2, w / 2);

            Position = Camera.Instance.Position + wind * w;
            X       += (float)Math.Cos(a) * d;
            Y       += (float)Math.Sin(a) * d;

            overlapped = false;
            velocity   = wind;
        }
Exemplo n.º 4
0
        public override void AddComponents()
        {
            base.AddComponents();

            AlwaysActive = true;

            Width  = 5;
            Height = 5;

            AddComponent(new RandomFrameComponent("splash_particle")
            {
                Tint = new Color(Color.R, Color.G, Color.B, 0.8f)
            });

            AddComponent(new ShadowComponent(RenderShadow));
            AddComponent(new ZComponent());

            var body = new CircleBodyComponent(0, 0, 4);

            AddComponent(body);

            var f = Rnd.Float(60, 90);
            var a = Rnd.AnglePI();

            body.Body.LinearVelocity = new Vector2((float)Math.Cos(a) * f, (float)Math.Sin(a) * f);
            zv = Rnd.Float(1, 3);
        }
Exemplo n.º 5
0
 private void Teleport()
 {
     GetComponent <AnimationComponent>().Animate(() => {
         AnimationUtil.Poof(Center, Depth + 1);
         Center = Owner.Center + MathUtils.CreateVector(Rnd.AnglePI(), Rnd.Float(12, 18));
         AnimationUtil.Poof(Center, Depth + 1);
     });
 }
        public override void Init(Particle particle, Entity owner)
        {
            base.Init(particle, owner);

            var a = Rnd.AnglePI();
            var d = Rnd.Float(60, 90);

            particle.Velocity = new Vector2((float)Math.Cos(a) * d, (float)Math.Sin(a) * d);
        }
Exemplo n.º 7
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.º 8
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if (Self.Target != null)
                {
                    Self.GraphicsComponent.Flipped = Self.Target.CenterX < Self.CenterX;
                }

                if (!tweened && T >= delay - 0.4f)
                {
                    tweened = true;
                    Self.GetComponent <MobAnimationComponent>().Animate();
                }

                if (T >= delay && Self.CanSeeTarget())
                {
                    var p = new ProjectilePattern(KeepShapePattern.Make(Rnd.Chance() ? -4 : 4))
                    {
                        Position = Self.Center
                    };

                    Self.Area.Add(p);
                    var sa    = Rnd.AnglePI();
                    var count = 5;

                    for (var i = 0; i < count; i++)
                    {
                        var i1 = i;

                        Timer.Add(() => {
                            var a  = (float)Math.PI * i1 / (count * 0.5f) + sa;
                            var pr = Projectile.Make(Self, "small");

                            pr.CanBeReflected = false;
                            pr.Color          = Self.color;
                            pr.AddLight(32, Self.color);

                            pr.CanBeReflected      = false;
                            pr.BodyComponent.Angle = a;

                            pr.Center = Self.Center + MathUtils.CreateVector(a, 12);

                            p.Add(pr);
                            Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_fire");

                            if (i1 == count - 1)
                            {
                                p.Launch(Self.Target == null ? Rnd.AnglePI() : Self.AngleTo(Self.Target), 80);
                            }
                        }, i * 0.1f);
                    }

                    Become <TeleportState>();
                }
            }
Exemplo n.º 9
0
        public override void Init(Particle particle, Entity owner)
        {
            base.Init(particle, owner);

            particle.AngleVelocity = Rnd.Float(0.6f, 1) * 16 * (Rnd.Chance() ? -1 : 1);

            var a = Rnd.AnglePI();
            var f = Rnd.Float(0.6f, 1f) * 40f;

            particle.Velocity = new Vector2((float)Math.Cos(a) * f, (float)Math.Sin(a) * f);
        }
Exemplo n.º 10
0
            public override void Init()
            {
                base.Init();

                var a     = Self.Target == null || (!Self.Raging && Rnd.Chance()) ? Rnd.AnglePI() : Self.AngleTo(Self.Target) + Rnd.Float(-0.1f, 0.1f);
                var force = Rnd.Float(20f) + (Self.Raging ? 240 : 120);

                Self.GetComponent <RectBodyComponent>().Velocity = new Vector2((float)Math.Cos(a) * force, (float)Math.Sin(a) * force);
                Self.GetComponent <ZComponent>().ZVelocity       = 10;

                Self.TouchDamage = 0;
                Self.Depth       = Layers.FlyingMob;
            }
Exemplo n.º 11
0
            public override void Init()
            {
                base.Init();

                angle = Rnd.AnglePI();
                timer = Rnd.Float(0.8f, 2f);

                var force = Rnd.Float(40f, 60f);

                velocity.X = (float)Math.Cos(angle) * force;
                velocity.Y = (float)Math.Sin(angle) * force;

                Self.GetComponent <RectBodyComponent>().Velocity          = velocity;
                Self.GetComponent <MobAnimationComponent>().Animation.Tag = "run";
            }
Exemplo n.º 12
0
        public override void AddComponents()
        {
            base.AddComponents();

            AlwaysActive = true;

            scale  = Rnd.Float(5, 8);
            angle  = Rnd.AnglePI();
            region = CommonAse.Particles.GetSlice("fire");

            Width  = scale;
            Height = scale;

            Depth = 0;
        }
Exemplo n.º 13
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if (did)
                {
                    return;
                }

                did = true;

                Self.GetComponent <DialogComponent>().Close();
                var graphics = Self.GetComponent <BkGraphicsComponent>();

                Tween.To(0, graphics.Alpha, x => graphics.Alpha = x, 0.3f, Ease.QuadIn).OnEnd = () => {
                    if (Self.Target != null)
                    {
                        Self.Center = Self.Target.Center + MathUtils.CreateVector(Rnd.AnglePI(), 64f);
                    }

                    Tween.To(1, graphics.Alpha, x => graphics.Alpha = x, 0.3f).OnEnd = () => {
                        if (Run.Depth == 1 && GlobalSave.IsFalse("bk_who"))
                        {
                            Self.Become <CutsceneState>();
                            return;
                        }

                        if (Self.sayNoRage)
                        {
                            Self.sayNoRage = false;
                            Self.GetComponent <DialogComponent>().StartAndClose("bk_11", 5);
                        }

                        if (Self.Target != null)
                        {
                            Self.Become <FollowState>();
                        }
                        else
                        {
                            Self.Become <IdleState>();
                        }
                    };
                };
            }
Exemplo n.º 14
0
            public override void Init()
            {
                base.Init();

                fire  = Self.Target != null && Self.moveId % 2 == 0;
                angle = !fire?Rnd.AnglePI() : Self.AngleTo(Self.Target);

                timer = fire ? 0.9f : Rnd.Float(0.8f, 2f);
                start = Rnd.Float(0f, 10f);

                var a     = angle + Rnd.Float(-Accuracy, Accuracy);
                var force = fire ? 60 : 120;

                velocity.X = (float)Math.Cos(a) * force;
                velocity.Y = (float)Math.Sin(a) * force;

                Self.GetComponent <RectBodyComponent>().Velocity = velocity;
                Self.moveId++;
            }
Exemplo n.º 15
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);
            }
        }
Exemplo n.º 16
0
            public override void Init()
            {
                base.Init();

                if (Self.GetComponent <RectBodyComponent>().Body.LinearVelocity.LengthSquared() < 15f)
                {
                    angle = Rnd.Chance() || Self.Target == null?Rnd.AnglePI() : Self.AngleTo(Self.Target);

                    var a     = angle + Rnd.Float(-Accuracy, Accuracy);
                    var force = 200;

                    Vector2 velocity;

                    velocity.X = (float)Math.Cos(a) * force;
                    velocity.Y = (float)Math.Sin(a) * force;

                    Self.GetComponent <RectBodyComponent>().Velocity = velocity;
                    Self.GetComponent <MobAnimationComponent>().Animation.Reverse = velocity.Y < 0;
                }
            }
Exemplo n.º 17
0
            public override void Init()
            {
                base.Init();

                timer = Rnd.Float(0.4f, 1f);

                var angle = Rnd.AnglePI();
                var force = 120f + Rnd.Float(50f);

                if (Rnd.Chance() && Self.Target != null)
                {
                    var ac = 0.1f;
                    angle = Self.AngleTo(Self.Target) + Rnd.Float(-ac, ac);
                }

                velocity.X = (float)Math.Cos(angle) * force;
                velocity.Y = (float)Math.Sin(angle) * force;

                Self.GetComponent <RectBodyComponent>().Velocity = velocity;
            }
Exemplo n.º 18
0
            public override void Init()
            {
                base.Init();

                if (Self.fire = (Self.sawTime >= FindTime))
                {
                    Self.sawTime = 0;
                }

                angle = !Self.fire ? Rnd.AnglePI() : Self.AngleTo(Self.Target);
                timer = Self.fire ? 0.9f * 5 : Rnd.Float(0.8f, 2f);
                start = Rnd.Float(0f, 10f);

                var a     = angle + Rnd.Float(-Accuracy, Accuracy);
                var force = Self.fire ? 30 : 60;

                velocity.X = (float)Math.Cos(a) * force;
                velocity.Y = (float)Math.Sin(a) * force;

                Self.GetComponent <RectBodyComponent>().Velocity = velocity;
            }
Exemplo n.º 19
0
            public override void Update(float dt)
            {
                base.Update(dt);
                delay -= dt;

                if (delay <= 0)
                {
                    delay = 0.3f;
                    Self.GetComponent <BkGraphicsComponent>().Animate();

                    var angle      = Rnd.AnglePI() * 0.5f + count * (float)Math.PI;
                    var projectile = Projectile.Make(Self, "big", angle, 15f);

                    projectile.Color = ProjectileColor.Orange;
                    projectile.AddLight(32f, projectile.Color);
                    projectile.Center += MathUtils.CreateVector(angle, 8);

                    projectile.CanBeBroken    = false;
                    projectile.CanBeReflected = false;

                    projectile.OnDeath += (p, en, t) => {
                        var x = (int)Math.Floor(p.CenterX / 16);
                        var y = (int)Math.Floor(p.CenterY / 16);

                        var mob = new WallCrawler();
                        Self.Area.Add(mob);
                        mob.X = x * 16;
                        mob.Y = y * 16 - 8;
                        mob.GeneratePrefix();
                        AnimationUtil.Poof(mob.Center, 1);
                    };

                    count--;

                    if (count <= 0)
                    {
                        Become <FightState>();
                    }
                }
            }
Exemplo n.º 20
0
        public override void Update(float dt)
        {
            base.Update(dt);

            lastRay -= dt;

            if (lastRay <= 0)
            {
                lastRay = Math.Max(0.1f, (5f - t) / 20f);
                rays.Add(new Ray {
                    Angle = Rnd.AnglePI()
                });
            }

            GetComponent <LightComponent>().Light.Radius = scale * 2f;

            t  += dt;
            tt += dt;

            if (t > 0.5f)
            {
                angle += (t - 0.5f) * 300 * dt;
                scale += dt * scale;
            }

            if (scale >= 12)
            {
                Done = true;
                OnEnd?.Invoke();
            }

            foreach (var r in rays)
            {
                r.Scale.Y = r.Scale.X = Math.Min(1, r.Scale.X + dt);
            }
        }
Exemplo n.º 21
0
 protected override float GetJumpAngle()
 {
     return(Target == null || Rnd.Chance(80) ? Rnd.AnglePI() : AngleTo(Target) + Rnd.Float(-0.1f, 0.1f));
 }
Exemplo n.º 22
0
        public static void Make(Entity whoHurts, float hurtRadius = 32f, bool leave = true, Vec2 where = null, float damage = 16, float scale = 1, bool damageOwner = true)
        {
            Camera.Instance.Shake(10 * scale);
            Audio.SfxVolumeBuffer           = 0.5f;
            Audio.SfxVolumeBufferResetTimer = 1f;

            var w = where == null ? whoHurts.Center : new Vector2(where.X, where.Y);

            AnimationUtil.Explosion(w, scale);

            for (var i = 0; i < 4; i++)
            {
                var explosion = new ParticleEntity(Particles.Animated("explosion", "smoke"));
                explosion.Position = w;
                whoHurts.Area.Add(explosion);
                explosion.Depth                  = 31;
                explosion.Particle.Scale         = scale;
                explosion.Particle.AngleVelocity = 0;
                explosion.AddShadow();

                var a = explosion.Particle.Angle - Math.PI / 2;
                var d = 16;

                explosion.Particle.Position += new Vector2((float)Math.Cos(a) * d, (float)Math.Sin(a) * d);

                if (i == 0)
                {
                    explosion.AddComponent(new AudioEmitterComponent {
                        DestroySounds = false
                    });

                    explosion.GetComponent <AudioEmitterComponent>().EmitRandomizedPrefixed("level_explosion", 3);
                }
            }

            for (var i = 0; i < 6; i++)
            {
                var part = new ParticleEntity(Particles.Dust());

                part.Position = w + new Vector2(Rnd.Int(-4, 4), Rnd.Int(-4, 4));
                whoHurts.Area.Add(part);
                part.Depth             = 30;
                part.Particle.Velocity = MathUtils.CreateVector(Rnd.AnglePI(), 80);
            }

            Engine.Instance.Split  = 1f;
            Engine.Instance.Flash  = 1f;
            Engine.Instance.Freeze = 1f;

            var damager = whoHurts;

            if (whoHurts is Bomb b && b.Owner != null)
            {
                damager = b.Owner;
            }

            foreach (var e in whoHurts.Area.GetEntitesInRadius(w, hurtRadius, typeof(ExplodableComponent)))
            {
                if (e == whoHurts && !damageOwner)
                {
                    continue;
                }

                e.GetAnyComponent <BodyComponent>()?.KnockbackFrom(whoHurts, 4f);
                e.GetComponent <ExplodableComponent>().HandleExplosion(damager, whoHurts, damage);
            }

            if (Settings.Flashes)
            {
                Camera.Instance.TextureZoom -= 0.05f;
                Tween.To(1f, Camera.Instance.TextureZoom, x => Camera.Instance.TextureZoom = x, 0.2f);
            }

            if (leave)
            {
                whoHurts.Area.Add(new ExplosionLeftOver {
                    Center = w
                });
            }

            var xx    = (int)Math.Floor(w.X / 16f);
            var yy    = (int)Math.Floor(w.Y / 16f);
            var r     = (int)Math.Floor(hurtRadius / 16f);
            var level = Run.Level;
            var ice   = level.Biome is IceBiome;

            for (int x = -r; x <= r; x++)
            {
                for (int y = -r; y <= r; y++)
                {
                    var xm = x * 16;
                    var ym = y * 16;

                    if (Math.Sqrt(xm * xm + ym * ym) <= hurtRadius)
                    {
                        var index = level.ToIndex(x + xx, y + yy);
                        var l     = level.Get(index, true);
                        var ww    = new Dot((x + xx) * 16 + 8, (y + yy) * 16 + 8);

                        if (l.IsRock())
                        {
                            BreakRock(level, ww, x + xx, y + yy, l);
                            continue;
                        }

                        var tile = level.Get(index);

                        if (tile == Tile.Crack)
                        {
                            DiscoverCrack(whoHurts, level, x + xx, y + yy);
                        }
                        else if (tile == Tile.Planks || (ice && tile == Tile.WallA))
                        {
                            level.Break((x + xx) * 16, (y + yy) * 16);
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
 protected virtual float GetJumpAngle()
 {
     return(Target == null?Rnd.AnglePI() : AngleTo(Target) + Rnd.Float(-0.1f, 0.1f));
 }
Exemplo n.º 24
0
        protected override void OnItemSet(Item previous)
        {
            base.OnItemSet(previous);

            if (pet != null)
            {
                if (pet.TryGetComponent <FollowerComponent>(out var f))
                {
                    f.Remove();
                }
                else
                {
                    pet.GetComponent <OrbitalComponent>().Orbiting.GetComponent <OrbitGiverComponent>().RemoveOrbiter(pet);
                }

                pet.Done = true;
                pet      = null;
            }

            if (prev != null && prev.Id != "bk:no_lamp")
            {
                Entity.RemoveComponent <HealthComponent>();
                Entity.RemoveComponent <HeartsComponent>();
                Entity.RemoveComponent <InventoryComponent>();

                Entity.AddComponent(new HealthComponent());

                var hp = Entity.GetComponent <HealthComponent>();

                hp.InitMaxHealth         = 6;
                hp.SaveMaxHp             = true;
                hp.MaxHealthCap          = 32;
                hp.InvincibilityTimerMax = 1f;

                if (CheatWindow.AutoGodMode)
                {
                    Log.Info("Entering god mode for the player");
                    hp.Unhittable = true;
                }

                Entity.AddComponent(new HeartsComponent());
                Entity.AddComponent(new InventoryComponent());

                if (Entity.TryGetComponent <WeaponComponent>(out var w))
                {
                    w.Disabled = false;
                }

                if (Entity.TryGetComponent <ActiveWeaponComponent>(out var aw))
                {
                    aw.Disabled = false;
                }
            }

            prev = Item;

            if (loaded)
            {
                Item?.Use(Entity);
                hadLamp = true;
            }

            if (Item == null || Item.Id == "bk:no_lamp")
            {
                return;
            }

            pet = new LampPet(Item.Id)
            {
                Owner = Entity
            };

            Entity.Area.Add(pet);
            pet.Center = Entity.Center + MathUtils.CreateVector(Rnd.AnglePI(), Rnd.Float(16f, 48f));
            AnimationUtil.Poof(pet.Center);
        }
Exemplo n.º 25
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if (T >= 1f)
                {
                    T = 0;
                    count++;

                    var a          = Self.AngleTo(Self.Target) + Rnd.Float(-0.1f, 0.1f) + (count == 1 ? 0 : Math.PI);
                    var projectile = Projectile.Make(Self, "square", a, 15f);
                    Self.Animate();

                    projectile.Color = ProjectileColor.Red;
                    projectile.AddLight(32f, projectile.Color);
                    projectile.Center        += MathUtils.CreateVector(a, 8);
                    projectile.CanBeBroken    = false;
                    projectile.CanBeReflected = false;

                    var tt = 0f;

                    projectile.Controller += (p, dtt) => {
                        tt += dtt;

                        if (tt >= 0.3f)
                        {
                            tt = 0;

                            var s = projectile.BodyComponent.Velocity.Length();

                            if (s < 3f)
                            {
                                return;
                            }

                            var z = Projectile.Make(Self, "small", a - Math.PI + Rnd.Float(-0.1f, 0.1f), s, scale: Rnd.Float(0.8f, 1.2f));
                            z.Center = projectile.Center;
                        }
                    };

                    projectile.Controller   += SlowdownProjectileController.Make();
                    projectile.Range         = 5f;
                    projectile.IndicateDeath = true;

                    projectile.OnDeath += (p, e, t) => {
                        for (var i = 0; i < SmallCount; i++)
                        {
                            var an = (float)(((float)i) / SmallCount * Math.PI * 2);

                            var pp = new ProjectilePattern(CircleProjectilePattern.Make(4.5f, 10 * (i % 2 == 0 ? 1 : -1)))
                            {
                                Position = p.Center
                            };

                            for (var j = 0; j < 4; j++)
                            {
                                var b = Projectile.Make(Self, "small");
                                pp.Add(b);
                                b.Color = ProjectileColor.Red;
                                b.AddLight(32f, b.Color);
                                b.CanBeReflected = false;
                            }

                            pp.Launch(an, 40);
                            Self.Area.Add(pp);
                        }

                        for (var i = 0; i < InnerCount; i++)
                        {
                            var b = Projectile.Make(Self, "snowflake", Rnd.AnglePI(), Rnd.Float(10, 40), true, 1, null, Rnd.Float(0.5f, 1f));

                            b.Color          = ProjectileColor.Cyan;
                            b.Center         = p.Center;
                            b.CanBeReflected = false;
                            b.Controller    += SlowdownProjectileController.Make(Rnd.Float(0.5f, 4f));
                        }
                    };

                    if (count == 2)
                    {
                        Become <IdleState>();
                    }
                }
            }
Exemplo n.º 26
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if ((count + 1) * (Self.Raging ? 0.7f : 1f) <= T)
                {
                    count++;

                    if (Self.Target == null || Self.Died)
                    {
                        return;
                    }

                    var a = Self.GetComponent <BkGraphicsComponent>();
                    Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_oldking_shoot");

                    Tween.To(1.8f, a.Scale.X, x => a.Scale.X = x, 0.2f);
                    Tween.To(0.2f, a.Scale.Y, x => a.Scale.Y = x, 0.2f).OnEnd = () => {
                        Tween.To(1, a.Scale.X, x => a.Scale.X = x, 0.3f);
                        Tween.To(1, a.Scale.Y, x => a.Scale.Y = x, 0.3f);

                        if (Self.Target == null || Self.Died)
                        {
                            return;
                        }

                        var skull = Projectile.Make(Self, explode ? "skull" : "skup", Rnd.AnglePI(), explode ? Rnd.Float(5, 12) : 14);

                        skull.CanBeReflected = false;
                        skull.CanBeBroken    = false;

                        if (explode)
                        {
                            skull.NearDeath += p => {
                                var c = new AudioEmitterComponent {
                                    DestroySounds = false
                                };

                                p.AddComponent(c);
                                c.Emit("mob_oldking_explode");
                            };

                            skull.OnDeath += (p, e, t) => {
                                if (!t)
                                {
                                    return;
                                }

                                for (var i = 0; i < 16; i++)
                                {
                                    var bullet = Projectile.Make(Self, "small",
                                                                 ((float)i) / 8 * (float)Math.PI, (i % 2 == 0 ? 2 : 1) * 4 + 3);

                                    bullet.CanBeReflected = false;
                                    bullet.CanBeBroken    = false;
                                    bullet.Center         = p.Center;
                                }
                            };
                        }

                        skull.Controller    += TargetProjectileController.Make(Self.Target, 0.5f);
                        skull.Range          = 5f;
                        skull.IndicateDeath  = true;
                        skull.CanBeReflected = false;
                        skull.GetComponent <ProjectileGraphicsComponent>().IgnoreRotation = true;

                        if (count == (Self.Raging ? 6 : 4))
                        {
                            Self.Become <FightState>();
                        }
                    };
                }
            }