using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class SkyFlare : ModProjectile { public int blowTimer = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Sky Flare"); Main.projFrames[projectile.type] = 5; } public override void SetDefaults() { projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.penetrate = 1; cooldownSlot = 1; } public override void AI() { projectile.velocity.X *= 0.9995f; projectile.velocity.Y *= 0.9995f; int addStuff = Main.rand.Next(5); blowTimer += addStuff; if (blowTimer >= 900) { projectile.Kill(); } projectile.frameCounter++; if (projectile.frameCounter > 5) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame > 4) { projectile.frame = 0; } } public override Color? GetAlpha(Color lightColor) { return new Color(255, Main.DiscoG, 53, projectile.alpha); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { 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.None, 0f); return false; } public override void Kill(int timeLeft) { bool revenge = CalamityWorld.revenge; Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 20); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; Vector2 vector7 = vector6 - projectile.Center; int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); Main.dust[num228].noGravity = true; Main.dust[num228].noLight = true; Main.dust[num228].velocity = vector7; } if (projectile.owner == Main.myPlayer) { int num231 = (int)(projectile.Center.Y / 16f); int num232 = (int)(projectile.Center.X / 16f); int num233 = 100; if (num232 < 10) { num232 = 10; } if (num232 > Main.maxTilesX - 10) { num232 = Main.maxTilesX - 10; } if (num231 < 10) { num231 = 10; } if (num231 > Main.maxTilesY - num233 - 10) { num231 = Main.maxTilesY - num233 - 10; } for (int num234 = num231; num234 < num231 + num233; num234++) { Tile tile = Main.tile[num232, num234]; if (tile.active() && (Main.tileSolid[(int)tile.type] || tile.liquid != 0)) { num231 = num234; break; } } int tornadoType = Main.rand.Next(6); if (tornadoType < 5) { int num235 = Main.expertMode ? 180 : 300; //720 int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), num235, 4f, Main.myPlayer, 16f, 15f + (revenge ? 4f : 0f)); Main.projectile[num236].netUpdate = true; } else { int num235 = Main.expertMode ? 230 : 400; //920 int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), num235, 4f, Main.myPlayer, 16f, 16f + (revenge ? 4f : 0f)); Main.projectile[num236].netUpdate = true; } } } } }