public override void AI() { projectile.frame = (int)projectile.ai[0] % 4; projectile.ai[1]++; if (Main.rand.Next(10) == 0) { Glass.CreateDust(this, projectile.Center); } if (projectile.velocity.Y <= 18) { projectile.velocity.Y += 0.1f + projectile.frame * 0.02f; } if (projectile.velocity.X > 0.04f) { projectile.velocity.X -= 0.03f; } else if (projectile.velocity.X < -0.04) { projectile.velocity.X += 0.03f; } else { projectile.velocity.X = 0f; } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; }
public override void AI() { if (Main.rand.Next(5) == 0) { Glass.CreateDust(this, projectile.Center); } if (projectile.velocity.Y <= 24) { projectile.velocity.Y += 0.2f; } if (projectile.velocity.X > 0.04f) { projectile.velocity.X -= 0.03f; } else if (projectile.velocity.X < -0.04) { projectile.velocity.X += 0.03f; } else { projectile.velocity.X = 0f; } projectile.rotation += 0.1f; }
public override void Kill(int timeLeft) { int rnd = Main.rand.Next(1, 4); for (int i = 0; i < rnd; i++) { Glass.CreateDust(this, projectile.Center); } Terraria.Audio.LegacySoundStyle glass = SoundID.Item27; glass.WithVolume(0.4f); Main.PlaySound(glass, projectile.position); }
/// <param name="kill">Whether the projectile is "shattered" because it hit a wall or an enemy.</param> private void Shatter(Vector2 oldVelocity, bool kill) { int rnd = Main.rand.Next(3, 6); if (this is PearlglassProjectile) { if (kill) { rnd *= 2; } else { rnd /= 2; } } float speed = oldVelocity.Length() / 3; Vector2 nextPosition = projectile.position + oldVelocity; for (int i = 0; i < rnd; i++) { float rot = oldVelocity.ToRotation(); rot += (rnd / 2 - i + Main.rand.NextFloat(-3, 3)) * 0.12f; Vector2 velocity = -rot.ToRotationVector2() * speed; int type = Main.rand.Next(4); int damage = projectile.damage / 2 + type * 3; if (this is PearlglassProjectile) { damage = projectile.damage * 2 / 3 + type * 3; } float knockBack = projectile.knockBack / 5 + type / 5; Projectile.NewProjectile(projectile.position, velocity, shardType, damage, knockBack, projectile.owner, type); Glass.CreateDust(this, nextPosition); } }