1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader;
namespace PolWorldMounts.Content.Projectiles { public class DragonMeteorProjectile : ModProjectile { private bool hasAccelerated = false; private int hoverTime = 60;
public override void SetDefaults() { Projectile.width = 32; Projectile.height = 32; Projectile.friendly = true; Projectile.hostile = false; Projectile.tileCollide = true; Projectile.penetrate = -1; Projectile.timeLeft = 300; Projectile.light = 0.8f; Projectile.ignoreWater = true; Projectile.extraUpdates = 1; Main.projFrames[Projectile.type] = 4; }
public override void AI() { if (hoverTime > 0) { hoverTime--; Projectile.velocity = Vector2.Zero;
if (hoverTime % 10 == 0) { int dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Pink, 0f, 0f, 100, default(Color), 1.0f); Main.dust[dustIndex].velocity *= 0.5f; Main.dust[dustIndex].scale *= 1.2f; Main.dust[dustIndex].noGravity = true; } } else if (!hasAccelerated) { Vector2 targetPosition = Main.MouseWorld; Vector2 direction = targetPosition - Projectile.Center; direction.Normalize(); Projectile.velocity = direction * 2f; hasAccelerated = true; } else { Projectile.velocity *= 1.05f; }
if (hoverTime <= 0) { int dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Red, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 100, default(Color), 1.0f); Main.dust[dustIndex].velocity *= 0.5f; Main.dust[dustIndex].scale *= 1.2f; Main.dust[dustIndex].noGravity = true; } } public override void Kill(int timeLeft) { float explosionRadius = 150f; int damage = 300;
for (int i = 0; i < Main.maxNPCs; i++) { NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(this) && Vector2.Distance(npc.Center, Projectile.Center) < explosionRadius) { npc.SimpleStrikeNPC(damage, 0, false, 0, null, false, 0, false); } }
for (int i = 0; i < 20; i++) { int dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } for (int i = 0; i < 10; i++) { int dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Blue, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Red, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } }
public override bool PreDraw(ref Color lightColor) { Rectangle sourceRectangle = new Rectangle(0, Projectile.frame * Projectile.height, Projectile.width, Projectile.height);
Main.spriteBatch.Draw( Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value, Projectile.Center - Main.screenPosition, sourceRectangle, lightColor, Projectile.rotation, new Vector2(Projectile.width / 2, Projectile.height / 2), Projectile.scale, SpriteEffects.None, 0f );
return false; } } }
|