Example #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);
            }
            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>();
                }
            }
Example #3
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>();
                }
            }