boom
This commit is contained in:
1 parent
d6b75cc70d
commit
bda1980836
2 files changed
+50
-63
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -7,6 +8,12 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SupernovaBoom : ModProjectile
|
||||
{
|
||||
public int frameX = 0;
|
||||
public int frameY = 0;
|
||||
private const int horizontalFrames = 5;
|
||||
private const int verticalFrames = 4;
|
||||
private const int frameLength = 5;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Explosion");
|
||||
@@ -21,77 +28,57 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
projectile.tileCollide = false;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = 5;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 0;
|
||||
projectile.localNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 5;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f);
|
||||
bool flag15 = false;
|
||||
bool flag16 = false;
|
||||
if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0])
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter % frameLength == frameLength - 1)
|
||||
{
|
||||
flag15 = true;
|
||||
}
|
||||
if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0])
|
||||
{
|
||||
flag15 = true;
|
||||
}
|
||||
if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1])
|
||||
{
|
||||
flag16 = true;
|
||||
}
|
||||
if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1])
|
||||
{
|
||||
flag16 = true;
|
||||
}
|
||||
if (flag15 && flag16)
|
||||
{
|
||||
projectile.Kill();
|
||||
}
|
||||
float num461 = 25f;
|
||||
if (projectile.ai[0] > 180f)
|
||||
{
|
||||
num461 -= (projectile.ai[0] - 180f) / 2f;
|
||||
}
|
||||
if (num461 <= 0f)
|
||||
{
|
||||
num461 = 0f;
|
||||
projectile.Kill();
|
||||
}
|
||||
num461 *= 0.7f;
|
||||
projectile.ai[0] += 4f;
|
||||
int num462 = 0;
|
||||
while ((float)num462 < num461)
|
||||
{
|
||||
float num463 = (float)Main.rand.Next(-40, 41);
|
||||
float num464 = (float)Main.rand.Next(-40, 41);
|
||||
float num465 = (float)Main.rand.Next(12, 36);
|
||||
float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464));
|
||||
num466 = num465 / num466;
|
||||
num463 *= num466;
|
||||
num464 *= num466;
|
||||
int dustType = Utils.SelectRandom(Main.rand, new int[]
|
||||
frameY++;
|
||||
if (frameY >= verticalFrames)
|
||||
{
|
||||
107,
|
||||
234,
|
||||
269
|
||||
});
|
||||
int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height,
|
||||
dustType, 0f, 0f, 100, default, 2f);
|
||||
Dust dust = Main.dust[num467];
|
||||
dust.noGravity = true;
|
||||
dust.position.X = projectile.Center.X;
|
||||
dust.position.Y = projectile.Center.Y;
|
||||
dust.position.X += (float)Main.rand.Next(-10, 11);
|
||||
dust.position.Y += (float)Main.rand.Next(-10, 11);
|
||||
dust.velocity.X = num463;
|
||||
dust.velocity.Y = num464;
|
||||
num462++;
|
||||
frameX++;
|
||||
frameY = 0;
|
||||
}
|
||||
if (frameX >= horizontalFrames)
|
||||
{
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f);
|
||||
|
||||
/*float dustSpeed = (float)Main.rand.Next(12, 36);
|
||||
Vector2 dustVel = CalamityUtils.RandomVelocity(40f, dustSpeed, dustSpeed, 1f);
|
||||
int dustType = Utils.SelectRandom(Main.rand, new int[]
|
||||
{
|
||||
107,
|
||||
234,
|
||||
269
|
||||
});
|
||||
int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f);
|
||||
Dust dust = Main.dust[rainbow];
|
||||
dust.noGravity = true;
|
||||
dust.position.X = projectile.Center.X;
|
||||
dust.position.Y = projectile.Center.Y;
|
||||
dust.position.X += (float)Main.rand.Next(-10, 11);
|
||||
dust.position.Y += (float)Main.rand.Next(-10, 11);
|
||||
dust.velocity = dustVel;*/
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
int length = texture.Width / horizontalFrames;
|
||||
int height = texture.Height / verticalFrames;
|
||||
Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY);
|
||||
Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height);
|
||||
Vector2 origin = new Vector2(length / 2f, height / 2f);
|
||||
spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 98 KiB |
Reference in new issue
Block a user