Files
CalamityModPublic/Projectiles/Melee/ShortTerraBeam.cs
T

72 lines
2.7 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class ShortTerraBeam : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Beam");
}
public override void SetDefaults()
{
projectile.width = 20;
projectile.height = 20;
projectile.aiStyle = 27;
projectile.friendly = true;
projectile.melee = true;
projectile.penetrate = 4;
projectile.timeLeft = 120;
aiType = ProjectileID.TerraBeam;
}
public override void AI()
{
Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.75f / 255f, 0f);
if (Main.rand.NextBool(5))
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.timeLeft > 115)
return false;
Texture2D tex = Main.projectileTexture[projectile.type];
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.immune[projectile.owner] = 7;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item10, projectile.position);
int num3;
for (int num795 = 4; num795 < 31; num795 = num3 + 1)
{
float num796 = projectile.oldVelocity.X * (30f / (float)num795);
float num797 = projectile.oldVelocity.Y * (30f / (float)num795);
int num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f);
Main.dust[num798].noGravity = true;
Dust dust = Main.dust[num798];
dust.velocity *= 0.5f;
num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f);
dust = Main.dust[num798];
dust.velocity *= 0.05f;
num3 = num795;
}
}
}
}