Files
CalamityModPublic/Projectiles/Summon/GhostlyMine.cs
T
2024-04-04 04:22:36 +07:00

109 lines
4.5 KiB
C#

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class GhostlyMine : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/Boss/PhantomMine";
public bool start = true;
public bool spawnDust = true;
public override void SetDefaults()
{
Projectile.width = Projectile.height = 30;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 0f;
Projectile.timeLeft = 900;
Projectile.penetrate = 1;
Projectile.tileCollide = false;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (start)
{
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
Projectile.ai[1] = Projectile.ai[0];
start = false;
}
double deg = (double)Projectile.ai[1];
double rad = deg * (Math.PI / 180);
double dist = 550;
Projectile.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - Projectile.width / 2;
Projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - Projectile.height / 2;
Projectile.ai[1] += 1f;
if (spawnDust)
{
for (int i = 0; i < 10; i++)
{
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 2f);
Main.dust[dust].velocity *= 3f;
if (Main.rand.NextBool())
{
Main.dust[dust].scale = 0.5f;
Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int j = 0; j < 15; j++)
{
int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 3f);
Main.dust[dust2].noGravity = true;
Main.dust[dust2].velocity *= 5f;
dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 2f);
Main.dust[dust2].velocity *= 2f;
}
spawnDust = false;
}
}
public override Color? GetAlpha(Color lightColor)
{
if (Projectile.timeLeft < 85)
{
byte b2 = (byte)(Projectile.timeLeft * 3);
byte a2 = (byte)(100f * ((float)b2 / 255f));
return new Color((int)b2, (int)b2, (int)b2, (int)a2);
}
return new Color(255, 255, 255, 100);
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = 160;
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
SoundEngine.PlaySound(SoundID.Item14, Projectile.position);
for (int i = 0; i < 30; i++)
{
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 1.2f);
Main.dust[dust].velocity *= 3f;
if (Main.rand.NextBool())
{
Main.dust[dust].scale = 0.5f;
Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int j = 0; j < 60; j++)
{
int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 1.7f);
Main.dust[dust2].noGravity = true;
Main.dust[dust2].velocity *= 5f;
dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 100, default, 1f);
Main.dust[dust2].velocity *= 2f;
}
}
}
}