80 lines
3.2 KiB
C#
80 lines
3.2 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class SandyWaifuShark : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Shark");
|
|
Main.projFrames[projectile.type] = 8;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 60;
|
|
projectile.height = 60;
|
|
projectile.scale = 0.75f;
|
|
projectile.friendly = true;
|
|
projectile.ranged = true;
|
|
projectile.tileCollide = false;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 240;
|
|
}
|
|
|
|
public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile);
|
|
|
|
public override void AI()
|
|
{
|
|
int num192 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 32, 0f, 0f, 0, default, 0.5f);
|
|
Main.dust[num192].noGravity = true;
|
|
Main.dust[num192].velocity *= 0.2f;
|
|
Main.dust[num192].position = (Main.dust[num192].position + projectile.Center) / 2f;
|
|
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 6)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame > 7)
|
|
projectile.frame = 0;
|
|
|
|
if (projectile.velocity.X < 0f)
|
|
{
|
|
projectile.spriteDirection = -1;
|
|
projectile.rotation = (float)Math.Atan2(-projectile.velocity.Y, -projectile.velocity.X);
|
|
}
|
|
else
|
|
{
|
|
projectile.spriteDirection = 1;
|
|
projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X);
|
|
}
|
|
|
|
if (projectile.timeLeft < 210)
|
|
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
|
Texture2D texture2D13 = Main.projectileTexture[projectile.type];
|
|
int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
|
|
int y6 = num214 * projectile.frame;
|
|
Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f);
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 159, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
}
|
|
}
|