102 lines
4.0 KiB
C#
102 lines
4.0 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class Waterfall : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Beam");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 8;
|
|
Projectile.height = 8;
|
|
Projectile.friendly = true;
|
|
Projectile.alpha = 255;
|
|
Projectile.extraUpdates = 2;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 8;
|
|
Projectile.penetrate = 3;
|
|
Projectile.timeLeft /= 2;
|
|
Projectile.DamageType = DamageClass.MeleeNoSpeed;
|
|
Projectile.tileCollide = false;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
for (int num92 = 0; num92 < 2; num92++)
|
|
{
|
|
float num93 = Projectile.velocity.X / 3f * (float)num92;
|
|
float num94 = Projectile.velocity.Y / 3f * (float)num92;
|
|
int num95 = 4;
|
|
int num96 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 56, 0f, 0f, 100, default, 1.2f);
|
|
Main.dust[num96].noGravity = true;
|
|
Main.dust[num96].velocity *= 0.25f;
|
|
Main.dust[num96].velocity += Projectile.velocity * 0.1f;
|
|
Dust expr_47FA_cp_0 = Main.dust[num96];
|
|
expr_47FA_cp_0.position.X -= num93;
|
|
Dust expr_4815_cp_0 = Main.dust[num96];
|
|
expr_4815_cp_0.position.Y -= num94;
|
|
}
|
|
for (int num105 = 0; num105 < 2; num105++)
|
|
{
|
|
float num99 = Projectile.velocity.X / 3f * (float)num105;
|
|
float num100 = Projectile.velocity.Y / 3f * (float)num105;
|
|
int num101 = 4;
|
|
int num102 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 245, 0f, 0f, 100, default, 1.2f);
|
|
Main.dust[num102].noGravity = true;
|
|
Main.dust[num102].velocity *= 0.1f;
|
|
Main.dust[num102].velocity += Projectile.velocity * 0.25f;
|
|
Dust expr_47FA_cp_0 = Main.dust[num102];
|
|
expr_47FA_cp_0.position.X -= num99;
|
|
Dust expr_4815_cp_0 = Main.dust[num102];
|
|
expr_4815_cp_0.position.Y -= num100;
|
|
}
|
|
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] >= 60f)
|
|
Projectile.tileCollide = true;
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Projectile.penetrate--;
|
|
if (Projectile.penetrate <= 0)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
else
|
|
{
|
|
if (Projectile.velocity.X != oldVelocity.X)
|
|
{
|
|
Projectile.velocity.X = -oldVelocity.X;
|
|
}
|
|
if (Projectile.velocity.Y != oldVelocity.Y)
|
|
{
|
|
Projectile.velocity.Y = -oldVelocity.Y;
|
|
}
|
|
SoundEngine.PlaySound(SoundID.Item10, Projectile.Center);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.Center);
|
|
for (int k = 0; k < 3; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 56, Projectile.oldVelocity.X * 0.25f, Projectile.oldVelocity.Y * 0.25f);
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 245, Projectile.oldVelocity.X * 0.25f, Projectile.oldVelocity.Y * 0.25f);
|
|
}
|
|
}
|
|
}
|
|
}
|