예제 #1
0
        public override void AI()
        {
            Player       player    = Main.player[projectile.owner];
            QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>();

            if (modPlayer.ShieldMinion)
            {
                projectile.timeLeft = 2;
            }
            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1])
                {
                    ShieldCount++;
                }
            }

            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1])
                {
                    if (p == projectile.whoAmI)
                    {
                        break;
                    }
                    else
                    {
                        identity++;
                    }
                }
            }
            projectile.friendly = (projectile.ai[1] == charging);
            if (projectile.ai[1] != charging)
            {
                if (player.velocity.Length() > .1f)
                {
                    LatestValidVelocity = player.velocity;
                }

                float myOffset = (((float)Math.PI / 2) * (float)(identity + 1)) / (ShieldCount + 1) - (float)Math.PI / 4;
                flyTo = player.Center + QwertyMethods.PolarVector(projectile.ai[1] == guarding ? 120 : -50, (QwertysRandomContent.LocalCursor[projectile.owner] - player.Center).ToRotation() + myOffset);

                if (flyTo != null && flyTo != Vector2.Zero)
                {
                    projectile.velocity = (flyTo - projectile.Center) * .1f;
                }
            }
            switch ((int)projectile.ai[1])
            {
            case guarding:
                projectile.frame = 0;
                foreach (Projectile OtherProjectile in Main.projectile)
                {
                    if (OtherProjectile.hostile && OtherProjectile.active && OtherProjectile.velocity != Vector2.Zero && OtherProjectile.damage > 0 && Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, OtherProjectile.position, OtherProjectile.Size))
                    {
                        if (OtherProjectile.damage * 2 * (Main.expertMode ? 2 : 1) < projectile.damage)
                        {
                            OtherProjectile.Kill();
                        }
                        projectile.ai[1] = cooling;
                        chargeTimer      = -300;
                        break;
                    }
                }
                if (QwertyMethods.ClosestNPC(ref target, 1000, player.Center, true, player.MinionAttackTargetNPC))
                {
                    eyeOffset    = (target.Center - projectile.Center).SafeNormalize(-Vector2.UnitY);
                    eyeOffset.X *= horizontalEyeMultiploer;
                    eyeOffset.Y *= verticalEyeMultiplier;
                    if ((target.Center - projectile.Center).Length() < 120)
                    {
                        projectile.velocity = QwertyMethods.PolarVector(24, (target.Center - projectile.Center).ToRotation());
                        projectile.ai[1]    = charging;
                        chargeTimer         = 10;
                        break;
                    }
                }
                else
                {
                    eyeOffset = Vector2.Zero;
                }

                break;

            case charging:
                projectile.frame = 0;
                chargeTimer--;
                if (chargeTimer <= 0)
                {
                    projectile.ai[1] = cooling;
                    chargeTimer      = -300;
                }
                break;

            case cooling:
                projectile.frame = 1;
                chargeTimer++;
                if (chargeTimer >= 0)
                {
                    projectile.ai[1] = guarding;
                }
                break;
            }


            identity    = 0;
            ShieldCount = 0;
        }