Esempio n. 1
0
        public override void Kill(int timeLeft)
        {
            int dusts = 8;
            int rings = 1;

            for (int i = 0; i < rings; i++)
            {
                for (int j = 0; j < dusts; j++)
                {
                    Dust dust = Dust.NewDustPerfect(projectile.Center + new Vector2(0f, -projectile.height / rings * i * 0.5f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, -1f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 1f);
                    dust.noGravity = true;
                }
            }

            if (ai == BlueManUtils.AITypes.ExplodingBounceSquare)
            {
                Main.PlaySound(SoundLoader.customSoundType, (int)projectile.Center.X, (int)projectile.Center.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/CerumeteorExplosion"), 1f, 1f);
                dusts = 16;
                rings = 4;
                for (int i = 0; i < rings; i++)
                {
                    for (int j = 0; j < dusts; j++)
                    {
                        Dust dust = Dust.NewDustPerfect(projectile.Center + new Vector2(0f, -projectile.height / rings * i * 0.5f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, -4f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 2f);
                        dust.noGravity = true;
                    }
                }

                int projectiles = 4;
                for (int i = 0; i < projectiles; i++)
                {
                    Projectile square = BlueManUtils.NewProjectileDirect(BlueManUtils.AITypes.BounceSquare, projectile.Center, new Vector2(0f, -8f).RotatedBy(MathHelper.ToRadians(MathHelper.Lerp(-45f, 45f, (float)i / projectiles))), projectile.damage / projectiles, projectile.knockBack);
                }
            }
        }
Esempio n. 2
0
        public override void AI()
        {
            npc.TargetClosest();
            Player  target             = Main.player[npc.target];
            Vector2 targetDirection    = Vector2.Normalize(target.Center - npc.Center);
            float   targetDistance     = Vector2.Distance(target.Center, npc.Center);
            Vector2 dashVelocity       = targetDirection * 100f;
            Vector2 hoverPosition      = target.Center + new Vector2(0f, -512f).RotatedBy(MathHelper.ToRadians(-attackTimer * 4f));
            int     dashReleaseTimeMax = 360;
            int     dashReleaseTime    = dashReleaseTimeMax - 65;
            int     dashEndTime        = dashReleaseTime - 45;
            float   randomX            = Main.graphics.PreferredBackBufferWidth * Main.rand.NextFloat(-0.5f, 0.5f);
            float   killRange          = 320f;

            #region Phase Management
            if (npc.life <= npc.lifeMax / 2)
            {
                if (phaseTimer == phaseTimerMax)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.Center, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/BlueManPhase2"));
                }
                if (phaseTimer > 0)
                {
                    int dusts = 8;
                    int rings = 4;
                    for (int i = 0; i < rings; i++)
                    {
                        for (int j = 0; j < dusts; j++)
                        {
                            Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i - phaseTimer * 0.5f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, 8f).RotatedBy(MathHelper.ToRadians(360f / dusts * j + (phaseTimer * (360f / phaseTimerMax) * 0.5f))), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 1f);
                            dust.noGravity = true;
                        }
                    }
                    npc.scale += (48 / 88f) / phaseTimerMax;
                    phaseTimer--;
                }
            }

            if (phaseTimer == 0 && !phase2)
            {
                npc.noTileCollide = true;
                scale             = new Vector2(3f, 1.5f);
                attackTimer       = 0;
                Vector2 oldCenter = npc.Center;
                phase2     = true;
                npc.width  = 88;
                npc.height = 100;
                npc.Center = oldCenter;

                int dusts = 64;
                int rings = 4;
                for (int i = 0; i < rings; i++)
                {
                    for (int j = 0; j < dusts; j++)
                    {
                        Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i * 0.5f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, -8f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 1f);
                        dust.noGravity = true;
                    }
                }

                int projectiles = 16;
                rings = 8;
                for (int i = 0; i < rings; i++)
                {
                    for (int j = 0; j < projectiles; j++)
                    {
                        Vector2    spawnPosition = target.Center + new Vector2(0f, -192f).RotatedBy(MathHelper.ToRadians(360f / projectiles * j));
                        Vector2    velocity      = new Vector2(0f, (rings * (i + 1)) * -0.2f).RotatedBy(MathHelper.ToRadians(360f / projectiles * j));
                        Projectile projectile    = BlueManUtils.NewProjectileDirect(BlueManUtils.AITypes.LargeBullet, spawnPosition, velocity, npc.damage / rings, 10f);
                    }
                }
            }

            float targetScale = 1f;
            if (npc.scale != targetScale)
            {
                float direction = targetScale - npc.scale;
                float speed     = 1f;
                float inertia   = 20f;
                direction   *= speed;
                scalingSpeed = (scalingSpeed * (inertia - 1) + direction) / inertia;
                npc.scale   += scalingSpeed;
            }

            if (scale.X != targetScale)
            {
                float direction = targetScale - scale.X;
                float speed     = 1f;
                float inertia   = 30f;
                direction   *= speed;
                scaleSpeed.X = (scaleSpeed.X * (inertia - 1) + direction) / inertia;
                scale.X     += scaleSpeed.X;
            }

            if (scale.Y != targetScale)
            {
                float direction = targetScale - scale.Y;
                float speed     = 1f;
                float inertia   = 30f;
                direction   *= speed;
                scaleSpeed.Y = (scaleSpeed.Y * (inertia - 1) + direction) / inertia;
                scale.Y     += scaleSpeed.Y;
            }
            #endregion

            if (!dying)
            {
                if (phase2)
                {
                    if (chargeDashTimer <= dashReleaseTime)
                    {
                        if (charged)
                        {
                            if (targetDistance >= 512f)
                            {
                                float   inertia   = 140f;
                                float   speed     = targetDistance * 0.1f;
                                Vector2 direction = targetDirection * speed;
                                Vector2 velocity  = (npc.velocity * (inertia - 1) + direction) / inertia;
                                npc.velocity = velocity;
                            }
                            else
                            {
                                float   inertia   = 40f;
                                float   speed     = 40f;
                                Vector2 direction = Vector2.Normalize(hoverPosition - npc.Center) * speed;
                                Vector2 velocity  = (npc.velocity * (inertia - 1) + direction) / inertia;
                                npc.velocity  = velocity;
                                npc.rotation += velocity.ToRotation() * 0.1f;
                            }
                        }
                    }
                    else
                    {
                        npc.rotation += MathHelper.ToRadians(Math.Sign(dashVelocity.X) * 20f);
                        if (chargeDashTimer % 2 == 0)
                        {
                            int dusts = 8;
                            int rings = 4;
                            for (int i = 0; i < rings; i++)
                            {
                                for (int j = 0; j < dusts; j++)
                                {
                                    Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i - 64f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, 0f), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 1f);
                                    dust.noGravity = true;
                                }
                            }
                        }
                        Dust dust2 = Dust.NewDustPerfect(npc.Center, ModContent.DustType <PixelDust>(), dashVelocity, 0, Color.White, 2.5f);
                        dust2.noGravity = true;
                    }

                    npc.rotation += Math.Sign(npc.velocity.X) * 0.01f;

                    if (attackTimer % 120 == 0 && chargeDashTimer == 0 && phase2Timer == 0)
                    {
                        npc.velocity = new Vector2(0f, 0f);
                        Main.PlaySound(SoundLoader.customSoundType, (int)npc.Center.X, (int)npc.Center.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/BlueManPhase2"), 1f, 2f);
                        chargeDashTimer = dashReleaseTimeMax;
                    }

                    if (charged && chargeDashTimer <= dashEndTime && chargeDashTimer % 30 == 0)
                    {
                        Vector2    spawnPosition = new Vector2(npc.Center.X + randomX, target.Center.Y - Main.graphics.PreferredBackBufferHeight * 0.5f - 160f);
                        Projectile projectile    = BlueManUtils.NewProjectileDirect(BlueManUtils.AITypes.ExplodingBounceSquare, spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 15f, npc.damage, 10f);
                    }

                    if (chargeDashTimer == dashReleaseTime)
                    {
                        npc.velocity = dashVelocity;
                        charged      = true;
                    }

                    if (phase2Timer > 0)
                    {
                        phase2Timer--;
                    }
                }

                if (phaseTimer == phaseTimerMax)
                {
                    if (attackTimer % 60 == 0 && attackTimer != attackTimerMax)
                    {
                        Projectile projectile = BlueManUtils.NewProjectileDirect(BlueManUtils.AITypes.Bullet, npc.Center, targetDirection * 12f, npc.damage, 10f);
                    }

                    float inertia = 50f;
                    float speed   = 50f;
                    if (attackTimer <= attackTimerMax / 2)
                    {
                        speed = 10f;
                    }
                    Vector2 direction = Vector2.Normalize(hoverPosition - npc.Center) * speed;
                    Vector2 velocity  = (npc.velocity * (inertia - 1) + direction) / inertia;
                    npc.velocity  = velocity;
                    npc.rotation += velocity.ToRotation() * 0.1f;
                }
            }
            else
            {
                npc.rotation += MathHelper.ToRadians(deathTimer) * 0.1f;

                if (attackTimer % 10 == 0)
                {
                    int dusts = 8;
                    int rings = 4;
                    for (int i = 0; i < rings; i++)
                    {
                        for (int j = 0; j < dusts; j++)
                        {
                            Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i + attackTimer * 2f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, 8f).RotatedBy(MathHelper.ToRadians(360f / dusts * j + (phaseTimer * (360f / phaseTimerMax) * 0.5f))), 0, Color.Lerp(BlueManUtils.BlueManWhite, BlueManUtils.BlueManBlue, (float)i / rings), 1f);
                            dust.noGravity = true;
                        }
                    }

                    dusts = 16;
                    rings = 4;
                    for (int i = 0; i < rings; i++)
                    {
                        for (int j = 0; j < dusts; j++)
                        {
                            Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i * 2f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, -8f).RotatedBy(MathHelper.ToRadians(360f / dusts * j + deathTimer * 2f)), 0, Color.Lerp(BlueManUtils.BlueManBlue, Color.Black, (float)i / rings), 1f);
                            dust.noGravity = true;
                        }
                    }
                }

                for (int i = 0; i < Main.maxPlayers; i++)
                {
                    Player player = Main.player[i];

                    if (player.active)
                    {
                        float maxDistance = 1920f;
                        float distance    = Math.Abs(Vector2.Distance(npc.Center, player.MountedCenter) - maxDistance);
                        if (distance <= maxDistance)
                        {
                            float   inertia   = 50f;
                            float   speed     = distance * 0.03f;
                            Vector2 direction = Vector2.Normalize(npc.Center - player.Center) * speed;
                            Vector2 velocity  = (player.velocity * (inertia - 1) + direction) / inertia;
                            player.velocity = velocity;

                            if (distance >= maxDistance - killRange)
                            {
                                int rings = 16;
                                for (int j = 0; j < rings; j++)
                                {
                                    Vector2 position     = player.Center + new Vector2(0f, -32f).RotatedBy(MathHelper.ToRadians(360f / rings * j)) * new Vector2(0.5f, 1f);
                                    Vector2 dustVelocity = Vector2.Normalize(player.Center - position) * 1f;
                                    Dust    dust         = Dust.NewDustPerfect(position, ModContent.DustType <PixelDust>(), dustVelocity, 0, Color.Lerp(Color.Red, Color.Orange, (float)Math.Sin(deathTimer) + 1f), 1f);
                                    dust.noGravity = true;
                                }
                            }
                        }
                    }
                }

                if (deathTimer > 0)
                {
                    deathTimer--;
                }
            }

            if (chargeDashTimer <= dashReleaseTime && chargeDashTimer > dashEndTime)
            {
                chargeDashing = true;
            }
            else
            {
                chargeDashing = false;
            }

            if (chargeDashTimer > 0)
            {
                chargeDashTimer--;
            }
            else
            {
                chargeDashing = false;
            }

            if (attackTimer <= 0)
            {
                attackTimer = attackTimerMax;
            }
            else
            {
                attackTimer--;
            }

            if (deathTimer == 0)
            {
                for (int i = 0; i < Main.maxPlayers; i++)
                {
                    Player shakenPlayer = Main.player[i];

                    if (shakenPlayer.active)
                    {
                        float distance    = Vector2.Distance(npc.Center, shakenPlayer.MountedCenter);
                        float maxDistance = 1920f;
                        if (distance <= maxDistance)
                        {
                            shakenPlayer.GetModPlayer <ImpactScreenshake>().shake += shakenPlayer.GetModPlayer <ImpactScreenshake>().maxShake *Math.Abs(distance - maxDistance) / maxDistance * 1.1f;
                            if (distance <= killRange)
                            {
                                shakenPlayer.Hurt(PlayerDeathReason.ByCustomReason(shakenPlayer.name + " was sent to a blue wormhole for the rest of eternity."), int.MaxValue, 0);
                            }
                        }
                    }
                }

                int dusts = 64;
                int rings = 8;
                for (int i = 0; i < rings; i++)
                {
                    for (int j = 0; j < dusts; j++)
                    {
                        Dust dust = Dust.NewDustPerfect(npc.Center + new Vector2(0f, -npc.height / rings * i * 2f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), ModContent.DustType <PixelDust>(), new Vector2(0f, -8f).RotatedBy(MathHelper.ToRadians(360f / dusts * j)), 0, Color.Lerp(BlueManUtils.BlueManBlue, Color.Black, (float)i / rings), 5f);
                        dust.noGravity = true;
                    }
                }

                Main.PlaySound(SoundLoader.customSoundType, (int)npc.Center.X, (int)npc.Center.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/Custom/CerumeteorExplosion"), 2f, 0f);

                npc.StrikeNPC(0, 0f, 0);
                npc.life   = 0;
                npc.active = false;
                npc.NPCLoot();
            }

            npc.velocity *= 0.95f;
        }