Ejemplo n.º 1
0
            public override void Init()
            {
                base.Init();

                Timer.Add(() => {
                    Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_fire_static");

                    var a = Self.AngleTo(Self.Target);

                    var p = new ProjectilePattern(KeepShapePattern.Make(0))
                    {
                        Position = Self.Center
                    };

                    Self.Area.Add(p);

                    ProjectileTemplate.MakeFast(Self, "small", Self.Center, a, (pr) => {
                        pr.CanBeReflected = false;
                        pr.CanBeBroken    = false;

                        p.Add(pr);
                        pr.Color = ProjectileColor.Red;
                        pr.AddLight(32, pr.Color);
                    }, swordData, () => {
                        Timer.Add(() => {
                            p.Launch(a, 30);
                            Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_fire_static");

                            Become <FightState>();
                        }, 0.2f);
                    });
                }, 1f);
            }
Ejemplo n.º 2
0
        public override void Update(float dt)
        {
            base.Update(dt);

            if (Target == null)
            {
                return;
            }

            t += dt;

            if (t >= FireRate)
            {
                t = 0;

                var pp = new ProjectilePattern(CircleProjectilePattern.Make(8f, 5))
                {
                    Position = Center
                };

                for (var j = 0; j < 5; j++)
                {
                    var b = Projectile.Make(this, "small");
                    pp.Add(b);
                    b.AddLight(32f, Projectile.RedLight);
                }

                pp.Launch(AngleTo(Target), 30);
                Area.Add(pp);
            }
        }
Ejemplo n.º 3
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>();
                }
            }
Ejemplo n.º 4
0
            public override void Init()
            {
                base.Init();

                var a = Self.GetComponent <ZAnimationComponent>();

                a.SetAutoStop(true);


                Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_oldking_land");

                Tween.To(1.8f, a.Scale.X, x => a.Scale.X = x, 0.1f);
                Tween.To(0.2f, a.Scale.Y, x => a.Scale.Y = x, 0.1f).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);
                };

                Self.GetComponent <RectBodyComponent>().Velocity = Vector2.Zero;

                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 = Self.BottomCenter
                    };

                    for (var j = 0; j < 2; j++)
                    {
                        var b = Projectile.Make(Self, "small");
                        pp.Add(b);
                        b.AddLight(32f, Projectile.RedLight);
                        b.CanBeReflected = false;
                        b.CanBeBroken    = false;
                    }

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

                var aa = Self.AngleTo(Self.Target);

                for (var i = 0; i < InnerCount; i++)
                {
                    var s = Rnd.Chance(40);
                    var b = Projectile.Make(Self, "small", aa + Rnd.Float(-0.3f, 0.3f), Rnd.Float(2, 12), true, 1, null, Rnd.Float(0.5f, 1f));

                    b.Color          = ProjectileColor.Green;
                    b.Center         = Self.BottomCenter;
                    b.CanBeReflected = false;
                    b.CanBeBroken    = false;
                    b.AddLight(s ? 16f : 32f, Projectile.GreenLight);
                }
            }
Ejemplo n.º 5
0
        public override void Init()
        {
            base.Init();

            var p = new ProjectilePattern(CircleWithCenterProjectilePattern.Make(14f, 3))
            {
                Position = Self.Center
            };

            var bullet = Projectile.Make(Self, "huge", Self.AngleTo(Self.Target), 7);

            bullet.OnDeath = (pr, e, t) => {
                p.Kill();
                ExplosionMaker.Make(pr.Owner, 16, false, new Vec2(pr.Center));

                for (var i = 0; i < SmallCount; i++)
                {
                    var b = Projectile.Make(Self, "green_small", (float)(((float)i) / SmallCount * Math.PI * 2), 6, true, 1, pr);
                    b.Center = pr.Center;
                    b.AddLight(32f, Projectile.GreenLight);
                }
            };

            bullet.CanBeReflected = false;
            bullet.CanBeBroken    = false;

            p.Add(bullet);

            for (var j = 0; j < OrbiterCount; j++)
            {
                var b = Projectile.Make(Self, "green_small");

                b.CanBeBroken    = false;
                b.CanBeReflected = false;

                b.AddLight(32f, Projectile.GreenLight);
                p.Add(b);
            }

            p.Launch(Self.AngleTo(Self.Target), 20);
            Self.Area.Add(p);
        }
Ejemplo n.º 6
0
        public override void Update(float dt)
        {
            base.Update(dt);

            if ((count + 1) * Delay <= T)
            {
                count++;

                if (count == 4)
                {
                    Self.SelectAttack();
                    return;
                }

                var m = new Missile(Self, Self.Target);
                m.AddLight(32f, Projectile.RedLight);

                m.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 < 2; j++)
                        {
                            var b = Projectile.Make(Self, "small");
                            pp.Add(b);
                            b.Range = 2f;
                            b.AddLight(32f, Projectile.RedLight);
                        }

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

                    var a = p.AngleTo(Self.Target);

                    for (var i = 0; i < InnerCount; i++)
                    {
                        var s = Rnd.Chance(40);
                        var b = Projectile.Make(Self, s ? "green_tiny" : "green_small", a + Rnd.Float(-0.3f, 0.3f), Rnd.Float(2, 12), true, 1, p);

                        b.Center = p.Center;
                        b.AddLight(s ? 16f : 32f, Projectile.GreenLight);
                    }
                };
            }
        }
Ejemplo n.º 7
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if (T >= 0.2f && !fired)
                {
                    fired = true;

                    if (Self.Target != null)
                    {
                        var h      = Self.Target.GetComponent <HealthComponent>();
                        var c      = h.Health <= 1 ? 'f' : Chars[Rnd.Int(Chars.Length)];
                        var a      = Self.AngleTo(Self.Target);
                        var color  = ProjectileColor.Rainbow[Rnd.Int(ProjectileColor.Rainbow.Length)];
                        var sprite = Rnd.Chance(60) ? "circle" : "square";

                        if (LetterTemplateData.Data.TryGetValue(c, out var data))
                        {
                            var p = new ProjectilePattern(KeepShapePattern.Make(0))
                            {
                                Position = Self.Center
                            };

                            Self.Area.Add(p);

                            ProjectileTemplate.MakeFast(Self, sprite, Self.Center, a, (pr) => {
                                p.Add(pr);
                                pr.Color = color;
                                pr.AddLight(32, color);

                                pr.CanBeReflected      = false;
                                pr.BodyComponent.Angle = a;
                            }, data, () => {
                                Timer.Add(() => {
                                    p.Launch(a, Rnd.Float(30, 80));
                                    Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_fire_static");
                                }, 0.2f);
                            });
                        }
                    }
                }

                if (T >= delay || Self.Target == null)
                {
                    Become <ToIdleState>();
                }
            }
Ejemplo n.º 8
0
        public override void Update(float dt)
        {
            base.Update(dt);

            if (spawnedBullets < totalBullets)
            {
                if (T >= (spawnedBullets + 1) * SpawnDelay)
                {
                    spawnedBullets++;

                    var b = Projectile.Make(Self, "small");

                    b.Center = Self.Center;

                    b.CanBeBroken    = false;
                    b.CanBeReflected = false;
                    b.AddLight(32f, Projectile.RedLight);

                    if (pattern == null)
                    {
                        pattern = new ProjectilePattern(ExpandingCirclePattern.Make(totalBullets, 32f, 2f, ShotDelay, 10f, 1f))
                        {
                            Position = Self.Center
                        };

                        Self.Area.Add(pattern);
                    }

                    pattern.Add(b);

                    if (spawnedBullets == totalBullets)
                    {
                        T = 0;
                    }
                }

                return;
            }

            if (T < ShotDelay)
            {
                return;
            }

            Self.SelectAttack();
        }
Ejemplo n.º 9
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>();
                    }
                }
            }
Ejemplo n.º 10
0
            public override void Update(float dt)
            {
                base.Update(dt);

                sinceLast += dt;

                if (sinceLast >= 0.5f)
                {
                    sinceLast = 0;
                    var a      = Self.AngleTo(Self.Target);
                    var second = Self.InThirdPhase;

                    for (var i = 0; i < (second ? 1 : 3); i++)
                    {
                        var i1 = i;

                        Timer.Add(() => {
                            if (second)
                            {
                                var pp = new ProjectilePattern(CircleProjectilePattern.Make(9f, i1 % 2 == 0 ? -10 : 10))
                                {
                                    Position = Self.Center
                                };

                                for (var j = 0; j < 4; j++)
                                {
                                    var b = Projectile.Make(Self, j % 2 == 0 ? "circle" : "small");
                                    pp.Add(b);
                                    b.Color = j % 2 == 0 ? ProjectileColor.Orange : ProjectileColor.Red;
                                    b.AddLight(32f, b.Color);
                                }

                                pp.Launch(a, 80);
                                Self.Area.Add(pp);
                            }
                            else
                            {
                                var p   = Projectile.Make(Self, "circle", a + Rnd.Float(-0.1f, 0.1f), 30f, scale: Rnd.Float(0.8f, 1f));
                                p.Color = Rnd.Chance() ? ProjectileColor.Yellow : ProjectileColor.Orange;
                                p.AddLight(64f, p.Color);
                            }

                            Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_bee_shot");
                        }, i * 0.15f);
                    }
                }

                var t = T + Math.PI * 0.5f;
                var r = Self.GetComponent <RoomComponent>().Room;

                var x = r.CenterX + (float)Math.Cos(t) * (r.Width * 0.4f);
                var y = r.CenterY - r.Height * 0.2f + (float)Math.Sin(t * 2) * (r.Height * 0.2f);


                var dx = x - Self.CenterX;
                var dy = y - Self.CenterY;

                var s = (dt * 10);

                Self.CenterX += dx * s;
                Self.CenterY += dy * s;
                Self.GraphicsComponent.Flipped = dx < 0;


                if (t >= Math.PI * 4.5f)
                {
                    Become <IdleState>();
                }
            }
Ejemplo n.º 11
0
            public override void Update(float dt)
            {
                base.Update(dt);
                delay -= dt;

                if (delay <= 0)
                {
                    if (count >= 5f)
                    {
                        Become <IdleState>();
                        return;
                    }

                    delay = 3f;
                    count++;

                    Self.GetComponent <BkGraphicsComponent>().Animate();

                    var m = new Missile(Self, Self.Target);
                    Self.Area.Add(m);
                    m.AddLight(64f, Projectile.RedLight);

                    m.HurtOwner = false;
                    m.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(6.5f, 10 * (i % 2 == 0 ? 1 : -1)))
                            {
                                Position = p.Center
                            };

                            for (var j = 0; j < 5; j++)
                            {
                                var b = Projectile.Make(Self, "small");
                                pp.Add(b);
                                b.AddLight(32f, Projectile.RedLight);
                                b.CanBeReflected = false;
                                b.CanBeReflected = false;
                                b.CanBeBroken    = false;
                            }

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

                        var aa = Self.AngleTo(Self.Target);

                        for (var i = 0; i < InnerCount; i++)
                        {
                            var b = Projectile.Make(Self, "circle", aa + Rnd.Float(-0.3f, 0.3f), Rnd.Float(2, 12), true, 0, null, Rnd.Float(0.5f, 1f));

                            b.Color          = ProjectileColor.Orange;
                            b.Center         = p.Center;
                            b.CanBeReflected = false;
                            b.CanBeBroken    = false;
                        }
                    };
                }
            }