示例#1
0
文件: Marx.cs 项目: DarthHA/HKBoss
        public override void AI()
        {
            if (Main.rand.Next(3) == 0)
            {
                SomeUtils.SummonParticle(npc.position + new Vector2(Main.rand.Next(npc.width), Main.rand.Next(npc.height)), Main.rand.Next(6) + 6);
            }

            npc.TargetClosest();
            Player target = Main.player[npc.target];

            if (npc.ai[0] < 3)
            {
                if (target.dead || !target.active)
                {
                    npc.active = false;
                }
            }
            target.thorns = 0;
            if (KBTimer > 0)
            {
                KBTimer--;
                if (KBTimer == 0)
                {
                    KBTimer--;
                    npc.velocity = Vector2.Zero;
                }
            }
            if (npc.ai[0] == 0)
            {
                npc.dontTakeDamage = true;
                npc.localAI[3]     = 1;
                if (npc.ai[2] == 0)
                {
                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/MarkothCastCalm").WithVolume(2f).WithPitchVariance(.5f), npc.Center);
                    Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <DreamShield>(), npc.damage / 4, 0, default, npc.whoAmI, 0);
示例#2
0
        public override void AI()
        {
            if (Main.rand.Next(4) == 0)
            {
                SomeUtils.SummonParticle(projectile.Center, 1);
            }
            if (projectile.alpha > 0)
            {
                projectile.alpha -= 20;
            }
            else
            {
                projectile.alpha = 0;
            }
            projectile.frameCounter++;
            if (projectile.frameCounter > 5)
            {
                projectile.frameCounter = 0;
                projectile.frame        = (projectile.frame + 1) % 3;
            }
            projectile.timeLeft = 9999;
            if (!Main.npc[(int)projectile.ai[0]].active)
            {
                projectile.Kill();
            }
            NPC owner = Main.npc[(int)projectile.ai[0]];

            if (owner.ai[0] == 0)
            {
                projectile.Center = owner.Center + new Vector2(1, 0) * R / 60f * owner.ai[2];
            }
            if (owner.ai[0] == 1)
            {
                if (owner.ai[1] == 0)
                {
                    projectile.Center     = owner.Center + (projectile.localAI[1] / 180 * MathHelper.TwoPi).ToRotationVector2() * R;
                    projectile.rotation   = (projectile.Center - owner.Center).ToRotation();
                    projectile.localAI[1] = (projectile.localAI[1] + owner.localAI[3]) % 180;
                }
                else if (owner.ai[1] == 1 || owner.ai[1] == 3)
                {
                    projectile.Center     = owner.Center + (projectile.localAI[1] / 180 * MathHelper.TwoPi).ToRotationVector2() * R;
                    projectile.rotation   = (projectile.Center - owner.Center).ToRotation();
                    projectile.localAI[1] = (projectile.localAI[1] + owner.localAI[3]) % 180;
                }
                else if (owner.ai[1] == 2)
                {
                    float r;
                    if (owner.ai[2] <= 300)
                    {
                        r = R + R2 / 300f * owner.ai[2];
                    }
                    else
                    {
                        r = R + R2 / 300f * (600 - owner.ai[2]);
                    }
                    if (projectile.ai[1] == 1)
                    {
                        r = R;
                    }
                    float v = 1;
                    if (owner.ai[2] > 100 && owner.ai[2] < 500)
                    {
                        v = 4;
                    }
                    else if (owner.ai[2] > 50 || owner.ai[2] < 550)
                    {
                        v = 3;
                    }
                    else if (owner.ai[2] > 25 || owner.ai[2] < 575)
                    {
                        v = 2;
                    }

                    projectile.Center     = owner.Center + (projectile.localAI[1] / 180 * MathHelper.TwoPi).ToRotationVector2() * r;
                    projectile.rotation   = (projectile.Center - owner.Center).ToRotation();
                    projectile.localAI[1] = (projectile.localAI[1] + owner.localAI[3] * v) % 180;
                }
            }

            if (owner.ai[0] == 2)
            {
                if (owner.ai[1] == 1 || owner.ai[1] == 3)
                {
                    projectile.Center   = owner.Center + (projectile.localAI[1] / 180 * MathHelper.TwoPi).ToRotationVector2() * 200;
                    projectile.rotation = (projectile.Center - owner.Center).ToRotation();
                }
                else if (owner.ai[1] == 2)
                {
                    if (projectile.ai[1] == 0)
                    {
                        projectile.Center   = owner.Center + (projectile.localAI[1] / 180 * MathHelper.TwoPi).ToRotationVector2() * 200;
                        projectile.rotation = (projectile.Center - owner.Center).ToRotation();
                    }
                    else
                    {
                        float r1 = MathHelper.Pi;
                        foreach (Projectile proj in Main.projectile)
                        {
                            if (proj.active && proj.type == projectile.type)
                            {
                                if (proj.ai[0] == projectile.ai[0] && proj.ai[1] == 0 && proj.whoAmI != projectile.whoAmI)
                                {
                                    r1 = proj.localAI[1] / 180 * MathHelper.TwoPi;
                                    projectile.localAI[1] = (proj.localAI[1] + 90) % 180;
                                }
                            }
                        }

                        projectile.Center   = owner.Center - r1.ToRotationVector2() * 200f / 60f * (owner.ai[2] - 30);
                        projectile.rotation = (projectile.Center - owner.Center).ToRotation();
                    }
                }
            }

            ReflectProj();
        }