public override void AI() { projectile.velocity.Y += 0.2f; projectile.alpha = Math.Max(projectile.alpha - 255 / FADEINTIME, 0); int temp = projectile.frame; projectile.UpdateFrame((int)(10 * 60f / TOTALTIME)); projectile.spriteDirection = projectile.direction = -Parent.direction; if (projectile.frame != temp) { if (projectile.frame == DAMAGEFRAME) { BruteShockwave.MakeShockwave(projectile.Center, -projectile.direction, (int)(projectile.damage * 0.75f), 20); if (!Main.dedServ) { for (int i = 0; i < 4; i++) { ParticleHandler.SpawnParticle(new ImpactLine(projectile.Bottom + new Vector2(Main.rand.NextFloat(45, 55) * -projectile.direction, 0), -Vector2.UnitY.RotatedByRandom(MathHelper.Pi / 3) * Main.rand.NextFloat(1, 2.5f), Color.White, new Vector2(0.33f, Main.rand.NextFloat(1f, 1.5f)), 15)); } } } projectile.netUpdate = true; } AiTimer++; }
public override void ExplodeEffect() { Main.PlaySound(new LegacySoundStyle(soundId: SoundID.Item, style: 14).WithPitchVariance(0.1f), projectile.Center); DustHelper.DrawDustImage(projectile.Center, ModContent.DustType <WinterbornDust>(), 0.3f, "SpiritMod/Effects/Snowflakes/Flake" + Main.rand.Next(3), 0.4f); float rot = Main.rand.NextFloat(MathHelper.TwoPi); for (int i = 0; i < 8; i++) { DustHelper.DrawDustImage(projectile.Center + (Vector2.UnitX.RotatedBy(rot + (MathHelper.TwoPi * i / 8f)) * 60), ModContent.DustType <WinterbornDust>(), 0.15f, "SpiritMod/Effects/Snowflakes/Flake" + Main.rand.Next(3), 0.25f, rot: Main.rand.NextFloat(MathHelper.TwoPi)); } for (int i = 0; i < 30; i++) { float maxDist = 100; float Dist = Main.rand.NextFloat(maxDist); Vector2 offset = Main.rand.NextVector2Unit(); ParticleHandler.SpawnParticle(new SmokeParticle(projectile.Center + (offset * Dist), Main.rand.NextFloat(5f) * offset * (1 - (Dist / maxDist)), new Color(30, 30, 90) * 0.5f, Main.rand.NextFloat(0.4f, 0.6f), 40)); } for (int i = 0; i < 8; i++) { ParticleHandler.SpawnParticle(new FireParticle(projectile.Center, (projectile.velocity / 4) - (Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2 * 3) * Main.rand.NextFloat(4)), new Color(135, 253, 255), new Color(0, 21, 255), Main.rand.NextFloat(0.5f, 0.7f), 40, delegate(Particle particle) { if (particle.Velocity.Y < 16) { particle.Velocity.Y += 0.12f; } })); } }
public override bool PreAI() { if (Main.rand.Next(3) == 1) { StarParticle particle = new StarParticle( projectile.Center + Main.rand.NextVector2Circular(5, 5), projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.3f, 0.3f)) * 0.1f, Main.rand.NextBool() ? new Color(125, 255, 253) : new Color(48, 255, 176), Main.rand.NextFloat(0.05f, 0.15f), Main.rand.Next(20, 40)); ParticleHandler.SpawnParticle(particle); } var target = Main.npc.Where(n => n.active && Vector2.Distance(n.Center, projectile.Center) < 200 && n.GetGlobalNPC <ArtemisGNPC>().artemisMarked).OrderBy(n => Vector2.Distance(n.Center, projectile.Center)).FirstOrDefault(); if (target != default) { Vector2 direction = target.Center - projectile.Center; direction.Normalize(); direction *= 10; projectile.velocity = Vector2.Lerp(projectile.velocity, direction, 0.05f); } Lighting.AddLight(projectile.Center, new Color(48, 255, 176).ToVector3() * 0.3f); return(true); }
public override void Kill(int timeLeft) { //Main.PlaySound(SoundID.Item10, projectile.Center); if (!Main.dedServ) { Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/EnergyImpact").WithPitchVariance(0.1f).WithVolume(0.66f), projectile.Center); ParticleHandler.SpawnParticle(new GranitechGunBurst(projectile.Center, Main.rand.NextFloat(0.9f, 1.1f), projectile.oldVelocity.ToRotation())); for (int i = 0; i < 4; ++i) { Vector2 vel = Vector2.Normalize(projectile.oldVelocity).RotatedByRandom(MathHelper.ToRadians(30)) * Main.rand.NextFloat(6f, 10f) + (projectile.velocity * 0.8f); ParticleHandler.SpawnParticle(new GranitechParticle(projectile.Center, vel, Main.rand.NextBool(2) ? new Color(255, 56, 85) : new Color(239, 241, 80), Main.rand.NextFloat(3f, 3.5f), 22)); } for (int i = 0; i < 4; ++i) { Vector2 vel = Vector2.Normalize(projectile.oldVelocity).RotatedByRandom(MathHelper.ToRadians(180)) * Main.rand.NextFloat(6f, 10f) + (projectile.velocity * 0.4f); ParticleHandler.SpawnParticle(new GranitechParticle(projectile.Center, vel, Main.rand.NextBool(2) ? new Color(255, 56, 85) : new Color(239, 241, 80), Main.rand.NextFloat(3f, 3.5f), 22)); } } /*for (int i = 0; i < 4; ++i) * { * float speed = Main.rand.NextFloat(3, 5.5f); * var d = Dust.NewDustPerfect(projectile.Center, ModContent.DustType<GranitechGunDust>(), new Vector2(speed, 0).RotatedByRandom(MathHelper.Pi) + (projectile.velocity * 0.4f), 0, default); * GranitechGunDust.RandomizeFrame(d); * d.scale = speed / 4f; * d.fadeIn = speed / 4f; * }*/ spawnRings = false; }
public override void AbstractAI() { projectile.rotation += MathHelper.PiOver4 * Owner.direction; if (SwingDirection == Owner.direction) { projectile.rotation += MathHelper.PiOver2 * Owner.direction; projectile.direction = projectile.spriteDirection *= -1; } float noParticleTheshold = 0.1f; if (Main.rand.NextBool() && !Main.dedServ && UseProgress > SWING_TIME + noParticleTheshold && UseProgress < (1 - noParticleTheshold) && _hitPause == 0) { Vector2 directionUnit = Owner.DirectionTo(projectile.Center); Vector2 spawnPos = Owner.MountedCenter + directionUnit * projectile.Size.Length(); Vector2 vel = Owner.DirectionTo(projectile.Center).RotatedByRandom(MathHelper.Pi / 16) * Main.rand.NextFloat(0.75f, 1.25f); ParticleHandler.SpawnParticle(new StarParticle(spawnPos, vel, Color.White, Main.rand.NextFloat(0.1f, 0.12f), 25)); } Owner.reuseDelay = Owner.HeldItem.reuseDelay; if (Timer > maxTime) { projectile.Kill(); } }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { for (int i = 0; i < 8; i++) { Vector2 vel = Vector2.Zero - projectile.velocity; vel.Normalize(); vel = vel.RotatedBy(Main.rand.NextFloat(-0.5f, 0.5f)); vel *= Main.rand.NextFloat(2, 5); ImpactLine line = new ImpactLine(target.Center - (vel * 10), vel, new Color(48, 255, 176), new Vector2(0.25f, Main.rand.NextFloat(0.75f, 1.75f)), 70); line.TimeActive = 30; ParticleHandler.SpawnParticle(line); } for (int j = 0; j < 7; j++) { Vector2 vel = Vector2.Zero - projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.3f, 0.3f)) * 0.25f; int timeLeft = Main.rand.Next(40, 100); StarParticle particle = new StarParticle( projectile.Center + Main.rand.NextVector2Circular(10, 10) - (vel * 5), vel + Main.rand.NextVector2Circular(3, 3), new Color(48, 255, 176), Main.rand.NextFloat(0.1f, 0.2f), timeLeft); particle.TimeActive = (uint)(timeLeft / 2); ParticleHandler.SpawnParticle(particle); } if (!target.GetGlobalNPC <ArtemisGNPC>().artemisMarked) { Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType <ArtemisCrescent>(), 0, 0, projectile.owner, target.whoAmI); } target.GetGlobalNPC <ArtemisGNPC>().artemisMarked = true; target.GetGlobalNPC <ArtemisGNPC>().artemisTicker = 180; }
public override void OnHitKill(int hitDirection, double damage) { if (!Main.dedServ) { for (int i = 0; i < 2; i++) { ParticleHandler.SpawnParticle(new PulseCircle(npc.Center, Color.HotPink * 0.2f, 120 + 30 * i, 15, PulseCircle.MovementType.OutwardsSquareRooted) { RingColor = Color.HotPink }); } for (int i = 0; i < 10; i++) { ParticleHandler.SpawnParticle(new ImpactLine(npc.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.5f, 1.5f), Color.HotPink, new Vector2(0.5f, Main.rand.NextFloat(1f, 3f)), 15)); } for (int i = 0; i < 7; i++) { ParticleHandler.SpawnParticle(new StarParticle(npc.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(6f), Color.LightPink, Color.HotPink, Main.rand.NextFloat(0.2f, 0.4f), 25)); } for (int i = 0; i < 7; i++) { ParticleHandler.SpawnParticle(new PathfinderGores.PathfinderGore(npc.Center, Main.rand.NextVector2Circular(14, 14), Main.rand.NextFloat(0.8f, 1.2f), 180)); } } }
public Emitter(Clock clock, ParticleHandler particleHandler) { Clock = clock; Active = true; ParticleHandler = particleHandler; Fps = 60f; }
public override void PreUpdate() { if (active) { attackTimer++; if (attackTimer >= 90) { for (int i = 0; i < Main.npc.Length; i++) { NPC npc = Main.npc[i]; if (Vector2.Distance(player.Center, npc.Center) <= 500f && !npc.friendly && npc.damage > 0 && npc.life > 0 && npc.life < npc.lifeMax && npc.active) { int proj = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType <ElectricGuitarProjPlayer>(), 35, 2, player.whoAmI); Main.projectile[proj].ai[0] = npc.position.X; Main.projectile[proj].ai[1] = npc.position.Y; ParticleHandler.SpawnParticle(new PulseCircle(player.Center, new Color(255, 36, 50) * 0.124f, (.45f) * 100, 20, PulseCircle.MovementType.Outwards) { Angle = 0f, ZRotation = 0, RingColor = new Color(255, 36, 50) * 0.84f, Velocity = Vector2.Zero }); Main.projectile[proj].netUpdate = true; Main.PlaySound(new Terraria.Audio.LegacySoundStyle(2, 47).WithPitchVariance(0.8f).WithVolume(0.7f), player.Center); Main.PlaySound(new Terraria.Audio.LegacySoundStyle(2, 12).WithVolume(0.6f), player.Center); Main.PlaySound(SoundID.DD2_LightningAuraZap, player.position); break; } } attackTimer = 0; } } }
public override void CustomDraw(SpriteBatch spriteBatch) { Texture2D tex = ParticleHandler.GetTexture(Type); Vector2 newscale = new Vector2(MathHelper.Clamp(Velocity.Length() / 7.5f, 1f, 2f), 1 / MathHelper.Clamp(Velocity.Length() / 7.5f, 1f, 2f)); spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Velocity.ToRotation(), tex.Size() / 2, Scale * newscale, SpriteEffects.None, 0); }
public override void CustomDraw(SpriteBatch spriteBatch) { Texture2D texture = ParticleHandler.GetTexture(Type); var drawFrame = new Rectangle(0, _frame * texture.Height / 2, texture.Width, texture.Height / 2); Effect effect = SpiritMod.ShaderDict["PrimitiveTextureMap"]; effect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("NPCs/Boss/Occultist/SoulTrail")); Vector2[] vertices = _chain.VerticesArray(); vertices.IterateArray(delegate(ref Vector2 vertex, int index, float progress) { IterateVerticesSine(ref vertex, progress); }); var strip = new PrimitiveStrip { Color = Color.White * _opacity, Width = 13 * Scale, PositionArray = vertices, TaperingType = StripTaperType.None, }; PrimitiveRenderer.DrawPrimitiveShape(strip, effect); var origin = new Vector2(drawFrame.Width / 2, drawFrame.Height); spriteBatch.Draw(texture, _chain.StartPosition - Main.screenPosition, drawFrame, Color.White * _opacity, Rotation, origin, Scale, SpriteEffects.None, 0); Texture2D bloom = SpiritMod.Instance.GetTexture("Effects/Ripple"); spriteBatch.Draw(bloom, _chain.StartPosition - Main.screenPosition, null, Color.Red * _opacity, 0, bloom.Size() / 2, 0.75f, SpriteEffects.None, 0); }
public override void ExplodeEffect() { Main.PlaySound(new LegacySoundStyle(soundId: SoundID.Item, style: 14).WithPitchVariance(0.1f), projectile.Center); for (int i = 0; i < 10; i++) { Vector2 offset = Main.rand.NextVector2Circular(50, 50); ParticleHandler.SpawnParticle(new WarheadBoom(projectile.Center + offset, Main.rand.NextFloat(1f, 1.4f), offset.ToRotation() + MathHelper.PiOver2)); } for (int i = 0; i < 20; i++) { float maxDist = 70; float Dist = Main.rand.NextFloat(maxDist); Vector2 offset = Main.rand.NextVector2Unit(); ParticleHandler.SpawnParticle(new SmokeParticle(projectile.Center + (offset * Dist), Main.rand.NextFloat(5f) * offset * (1 - (Dist / maxDist)), new Color(60, 60, 60) * 0.5f, Main.rand.NextFloat(0.4f, 0.6f), 40)); } for (int i = 0; i < 6; i++) { ParticleHandler.SpawnParticle(new FireParticle(projectile.Center, (projectile.velocity / 2) - (Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2 * 3) * Main.rand.NextFloat(6)), new Color(246, 255, 0), new Color(232, 37, 2), Main.rand.NextFloat(0.5f, 0.7f), 40, delegate(Particle particle) { if (particle.Velocity.Y < 16) { particle.Velocity.Y += 0.12f; } })); } }
private void OnHitEffects() { if (Main.dedServ || _hitvisualtimer > 0) { return; } _hitvisualtimer = 3; for (int i = -1; i <= 1; i += 2) { for (int j = 0; j < 2; j++) //smaller lines { ParticleHandler.SpawnParticle(new ImpactLine(projectile.Center, projectile.velocity.RotatedBy(MathHelper.PiOver2 * i).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(0.1f, 0.2f), Color.White, new Vector2(0.25f, Main.rand.NextFloat(1f, 1.5f)), 15)); } //larger blueish lines with less randomization ParticleHandler.SpawnParticle(new ImpactLine(projectile.Center, projectile.velocity.RotatedBy(MathHelper.PiOver2 * i).RotatedByRandom(MathHelper.Pi / 8) * Main.rand.NextFloat(0.15f, 0.2f), Color.Lerp(Color.White, Color.Cyan, 0.5f), new Vector2(0.25f, Main.rand.NextFloat(3f, 4f)), 15)); } //impact star particles ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, Vector2.Zero, Color.Lerp(Color.White, Color.Cyan, 0.5f), Main.rand.NextFloat(0.5f, 0.6f), 12)); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/starHit").WithPitchVariance(0.2f).WithVolume(0.33f), projectile.Center); for (int i = 0; i < 5; i++) { ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, projectile.velocity.RotatedByRandom(MathHelper.Pi / 8) * Main.rand.NextFloat(), Color.White, Color.Cyan, Main.rand.NextFloat(0.15f, 0.25f), 20)); } }
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { hitDirection = Math.Sign(direction.X); if (Empowered) { foreach (NPC npc in Main.npc) { if (npc.active && npc.CanBeChasedBy(this) && npc.Distance(target.Center) < 150 && !npc.HasBuff(ModContent.BuffType <CurseBreakerMark>())) { npc.AddBuff(ModContent.BuffType <CurseBreakerMark>(), 180); Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <CurseBreakerCurse>(), projectile.damage, 0, Player.whoAmI, npc.whoAmI); } } } else if (target.HasBuff(ModContent.BuffType <CurseBreakerMark>())) { if (!cursed) { ParticleHandler.SpawnParticle(new PulseCircle(Player.Center, new Color(242, 41, 58) * 0.124f, (.9f) * 100, 20, PulseCircle.MovementType.OutwardsSquareRooted) { Angle = 0f, ZRotation = 0, RingColor = new Color(242, 41, 58), Velocity = Vector2.Zero }); cursed = true; cursedTimer = 8; } } }
public void performTickUpdate(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) { ParticleHandler.update(Game1.currentGameTime, Game1.currentLocation); Contact.PainTileHandler.tickUpdate(); Contact.TileContactMorphHandler.update(); ForegroundHandler.update(); }
public override void AI() { _splitTimer = System.Math.Max(_splitTimer--, 0); projectile.Size = new Vector2(10, 10) * projectile.scale; Vector2 nearestCenter = Main.player[Player.FindClosest(projectile.position, projectile.width, projectile.height)].Center; projectile.velocity += projectile.DirectionTo(nearestCenter) * 0.15f; float speed = (((1 - (projectile.scale / 20f)) * 8f) + 0.5f) * (1 + (_splitTimer / 20f)); if (projectile.velocity.Length() > speed) { projectile.velocity = Vector2.Normalize(projectile.velocity) * speed; } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; Lighting.AddLight(projectile.Center, Color.LightCyan.ToVector3() / 3); if (Main.rand.NextBool(5) && !Main.dedServ) { ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.3f), Color.White, Color.Cyan, Main.rand.NextFloat(0.1f, 0.2f) * projectile.scale, 25)); } }
public override void AI() { if (!Main.dedServ) { ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, Vector2.Normalize(projectile.velocity.RotatedByRandom(MathHelper.PiOver4)) * Main.rand.NextFloat(0.3f), Color.Pink, Color.Red, Main.rand.NextFloat(0.1f, 0.2f) * projectile.scale, 25)); } }
public void newDay(object sender, StardewModdingAPI.Events.DayStartedEventArgs e) { BackgroundHandler.updateBackground(); ForegroundHandler.updateForeground(); ParticleHandler.updateParticleSystems(Game1.currentLocation); //ParticleSystem testSystem = new ParticleSystem("Content/Particles/Test_P"); //testSystem.tileLocation = new Microsoft.Xna.Framework.Vector2(24, 10); //ParticleSystem testSystem = new ParticleSystem(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(32, 0, 10, 10), new Microsoft.Xna.Framework.Vector2(24, 10), 4, 0.1f, 5f, 1, 24000, 0, 0, -0.05f, 0.55f, // new Dictionary<int, float> // { // {ParticleSystem.Out, 0 }, // {ParticleSystem.North, -2 }, // {ParticleSystem.East, -2 }, // {ParticleSystem.Up, 0 }, // {ParticleSystem.Right, 0 } // }, // new Dictionary<int, float> // { // {ParticleSystem.Out, 0 }, // {ParticleSystem.North, 10f }, // {ParticleSystem.East, 10f }, // {ParticleSystem.Up, 0 }, // {ParticleSystem.Right, 0 } // } //); //ParticleHandler.systems.Add(testSystem); }
//public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) //{ // Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f); // for (int k = 0; k < projectile.oldPos.Length; k++) // { // Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY); // Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length); // spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f); // } // return true; //} public override void AI() { if (!initialized) { initialized = true; if (Main.netMode != NetmodeID.Server) { trail = new MarkOfZeusPrimTrailTwo(projectile, 2f * (float)(Math.Sqrt(charge) / 5)); SpiritMod.primitives.CreateTrail(trail); } } trail?.AddPoints(); if (Main.rand.Next(3) == 0) { int timeLeft = Main.rand.Next(40, 100); StarParticle particle = new StarParticle( projectile.Center, projectile.velocity.RotatedBy(Main.rand.NextFloat(-1.57f, 1.57f)) * 0.3f, Color.Gold, Main.rand.NextFloat(0.1f, 0.2f), timeLeft); particle.TimeActive = (uint)(timeLeft / 2); ParticleHandler.SpawnParticle(particle); } }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (Main.netMode == NetmodeID.Server) { return; } Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/EnergyImpact").WithPitchVariance(0.1f).WithVolume(0.6f), target.Center); float scale = Main.rand.NextFloat(0.8f, 1f); DrawAberration.DrawChromaticAberration(BeamDirection, 2f, delegate(Vector2 offset, Color colorMod) { Color color = new Color(99, 255, 229).MultiplyRGB(colorMod); ParticleHandler.SpawnParticle(new PulseCircle(target.Center + offset, color * 0.4f, scale * 100, (int)(LASER_TIME * 0.66f), PulseCircle.MovementType.OutwardsSquareRooted) { Angle = BeamDirection.ToRotation(), ZRotation = 0.6f, RingColor = color, Velocity = BeamDirection }); }); ParallelParticles(target.Center, BeamDirection * Main.rand.NextFloat(10, 15), 25, Main.rand.NextFloat(1.5f, 2f), Main.rand.Next(7, 10)); }
public override void AI() { projectile.velocity.X = .5f * projectile.direction; Dust dust = Main.dust[Dust.NewDust(new Vector2(projectile.Center.X - (120f * projectile.direction), projectile.Center.Y - 30 + Main.rand.Next(-25, 25)), 0, 0, ModContent.DustType <Dusts.BlizzardDust>(), 0f, 0f, 100, new Color(), Main.rand.NextFloat(1.125f, 1.775f))]; dust.velocity.Y = 0f; dust.velocity.X = Main.rand.NextFloat(13f, 16f) * projectile.direction; if (Main.rand.NextBool(3)) { ParticleHandler.SpawnParticle(new SmokeParticle(new Vector2(projectile.Center.X - (120f * projectile.direction), projectile.Center.Y + Main.rand.Next(-25, 25)), new Vector2(Main.rand.NextFloat(-1.5f, 1.5f)), Color.Lerp(Color.LightBlue * .8f, White * .8f, projectile.timeLeft / 120f), Main.rand.NextFloat(0.55f, 0.75f), 30, delegate(Particle p) { p.Velocity *= 0.93f; p.Velocity.Y = 0f; p.Velocity.X = Main.rand.NextFloat(11f, 14f) * projectile.direction; })); } if (Main.rand.NextBool(5)) { ParticleHandler.SpawnParticle(new SnowflakeParticle(new Vector2(projectile.Center.X - (120f * projectile.direction), projectile.Center.Y + Main.rand.Next(-25, 25)), new Vector2(Main.rand.NextFloat(-1.5f, 1.5f), Main.rand.NextFloat(-4.5f, -2.5f)), Blue, White, Main.rand.NextFloat(.45f, .95f), 45, .5f, Main.rand.Next(3), delegate(Particle p) { p.Velocity *= 0.93f; p.Velocity.Y += 0.15f; p.Velocity.X = Main.rand.NextFloat(12f, 15f) * projectile.direction; })); } ParticleHandler.SpawnParticle(new FireParticle(new Vector2(projectile.Center.X - (120f * projectile.direction), projectile.Center.Y + Main.rand.Next(-25, 25)), new Vector2(Main.rand.NextFloat(-1.5f, 1.5f), Main.rand.NextFloat(-4.5f, -2.5f)), Blue, White, Main.rand.NextFloat(0.15f, 0.45f), 30, delegate(Particle p) { p.Velocity *= 0.93f; p.Velocity.Y = 0f; p.Velocity.X = Main.rand.NextFloat(13f, 16f) * projectile.direction; })); }
public override void TargettingBehavior(Player player, NPC target) { projectile.direction = projectile.spriteDirection = Math.Sign(projectile.DirectionTo(target.Center).X) > 0 ? -1 : 1; Vector2 desiredPosition = player.MountedCenter - new Vector2(0, 60 + (float)Math.Sin(Main.GameUpdateCount / 6f) * 6); desiredPosition += projectile.DirectionTo(target.Center) * 30; projectile.velocity = Vector2.Lerp(projectile.velocity, Vector2.Lerp(projectile.Center, desiredPosition, 0.15f) - projectile.Center, 0.1f); if (++AiTimer >= SHOOTTIME) { Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(target.Center) * 7, ModContent.ProjectileType <FairyProj>(), projectile.damage, projectile.knockBack, projectile.owner); projectile.velocity -= projectile.DirectionTo(target.Center) * 4; AiTimer = 0; if (!Main.dedServ) { Main.PlaySound(SoundID.Item9.WithPitchVariance(0.3f), projectile.Center); for (int i = 0; i < 10; i++) { ParticleHandler.SpawnParticle(new FireParticle(projectile.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(1f, 2f), new Color(120, 239, 255) * 0.66f, new Color(94, 255, 126) * 0.66f, Main.rand.NextFloat(0.35f, 0.5f), 25, delegate(Particle p) { p.Velocity = p.Velocity.RotatedByRandom(0.1f) * 0.97f; })); } } } }
public void HitEffect(Vector2 position) { Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/GranitechImpact").WithPitchVariance(0.4f).WithVolume(0.4f), projectile.Center); projectile.damage = (int)(projectile.damage * 0.75f); if (Main.dedServ) { return; } Vector2 newPos = Vector2.Lerp(projectile.Center, position, 0.5f); Vector2 direction = Vector2.Normalize(newPos - BasePosition); if (_hitTimer == 0) { Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/EnergyImpact").WithPitchVariance(0.1f).WithVolume(0.4f), projectile.Center); _hitTimer = MAX_HITTIMER; ParticleHandler.SpawnParticle(new GranitechSaber_Hit(position, Main.rand.NextFloat(0.9f, 1.1f), direction.ToRotation())); } int numParticles = Main.rand.Next(6, 9); for (int i = 0; i < numParticles; i++) { Vector2 velocity = direction.RotatedByRandom(MathHelper.Pi / 6) * Main.rand.NextFloat(3, 20); ParticleHandler.SpawnParticle(new GranitechParticle(position, velocity, Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), Main.rand.NextFloat(2.5f, 3f), 25)); } }
void Start() { //Cache references to manager components. GameObject g = WorldConstants.MatchController; Manager = g.GetComponent <LevelManager>(); Input = g.GetComponent <InputManager>(); //Bind the input manager. Input.RegisterPlayerInput(ActorData.PlayerID, Input.FindFirstAvailableInput()); //Initialize data. MovementKeyAxes = Vector2.zero; LockVerticalControls = false; ChangeState(GetStartingState(), false); RunningParts = WorldConstants.Creator.CreateRunningDebrisParticles(this); WallslidingParts = WorldConstants.Creator.CreateWallslidingDebrisParticles(this); SoftLanding = WorldConstants.Creator.CreateLandingParticles(false, this); HardLanding = WorldConstants.Creator.CreateLandingParticles(true, this); foreach (GameObject go in GameObject.FindGameObjectsWithTag("MainCamera")) { if (go.name.Substring(0, 1) == ActorData.PlayerID.ToString()) { CameraScript = go.GetComponent <CameraFollowScript>(); break; } } }
private void OnHitEffects() { if (Main.dedServ) { return; } for (int i = -1; i <= 1; i += 2) { for (int j = 0; j < 2; j++) { ParticleHandler.SpawnParticle(new ImpactLine(projectile.Center, projectile.velocity.RotatedBy(MathHelper.PiOver2 * i).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.1f, 0.2f), Color.White, new Vector2(0.25f, Main.rand.NextFloat(0.6f, 1f)), 10)); } } ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, Vector2.Zero, Color.White, Main.rand.NextFloat(0.2f, 0.3f), 10)); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/starHit").WithPitchVariance(0.2f).WithVolume(0.33f), projectile.Center); for (int i = 0; i < 3; i++) { ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.5f), Color.White, Main.rand.NextFloat(0.1f, 0.2f), 20)); } }
public override void AI() { if (Main.rand.NextBool(10)) { Vector2 velocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi / 4) * Main.rand.NextFloat(2f, 3f); ParticleHandler.SpawnParticle(new CursebreakerRunes(projectile.Center, velocity, Red, Black, Main.rand.NextFloat(0.75f, 1.25f), 30, delegate(Particle p) { p.Velocity *= 0.95f; p.Scale *= 0.95f; })); } Lighting.AddLight(projectile.Center, Color.Red.ToVector3() * 0.3f); counter += 0.025f; if (target.active) { if (target.HasBuff(ModContent.BuffType <CurseBreakerMark>())) { projectile.scale = MathHelper.Clamp(counter * 3, 0, 1); projectile.timeLeft = 12; } else { projectile.scale -= 0.083f; } projectile.Center = target.Center; } else { projectile.active = false; } }
public override void Kill(int timeLeft) { SpiritMod.tremorTime = (int)(charge * 0.66f); Main.PlaySound(SoundID.Item70, projectile.Center); for (double i = 0; i < 6.28; i += Main.rand.NextFloat(1f, 2f)) { int lightningproj = Projectile.NewProjectile(projectile.Center + projectile.velocity - (new Vector2((float)Math.Sin(i), (float)Math.Cos(i)) * 5f), new Vector2((float)Math.Sin(i), (float)Math.Cos(i)) * 2.5f, ModContent.ProjectileType <MarkOfZeusProj3>(), projectile.damage, projectile.knockBack, projectile.owner, charge); Main.projectile[lightningproj].timeLeft = (int)(30 * Math.Sqrt(charge)); } for (double i = 0; i < 6.28; i += 0.15) { Dust dust = Dust.NewDustPerfect(projectile.Center + projectile.velocity, 133, new Vector2((float)Math.Sin(i) * Main.rand.NextFloat(3f) * (float)(Math.Sqrt(charge) / 3), (float)Math.Cos(i)) * Main.rand.NextFloat(4f) * (float)(Math.Sqrt(charge) / 3)); Dust dust2 = Dust.NewDustPerfect(projectile.Center + projectile.velocity, 133, new Vector2((float)Math.Sin(i) * Main.rand.NextFloat(1.8f) * (float)(Math.Sqrt(charge) / 3), (float)Math.Cos(i)) * Main.rand.NextFloat(2.4f) * (float)(Math.Sqrt(charge) / 3)); dust.noGravity = true; dust2.noGravity = true; dust.scale = 0.75f; dust2.scale = 0.75f; } for (int j = 0; j < 13; j++) { Vector2 vel = Vector2.Zero - projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.3f, 0.3f)) * 0.25f; StarParticle particle = new StarParticle( projectile.Center + Main.rand.NextVector2Circular(10, 10) + projectile.velocity, Main.rand.NextVector2Circular(7, 5), Color.Gold, Main.rand.NextFloat(0.1f, 0.2f), Main.rand.Next(30, 60)); ParticleHandler.SpawnParticle(particle); } }
public override void AI() { if (projectile.frameCounter == 0) { projectile.rotation = Main.rand.NextFloat(6.28f); for (int i = 0; i < 8; i++) { Vector2 vel = (projectile.rotation + 3.14f).ToRotationVector2() * 5; vel.Normalize(); vel = vel.RotatedBy(Main.rand.NextFloat(-0.5f, 0.5f)); vel *= Main.rand.NextFloat(2, 5); ImpactLine line = new ImpactLine(Main.npc[(int)projectile.ai[0]].Center - (vel * 5), vel, Color.Red, new Vector2(0.25f, Main.rand.NextFloat(0.75f, 1.75f)), 70); line.TimeActive = 30; ParticleHandler.SpawnParticle(line); } } projectile.Center = Main.npc[(int)projectile.ai[0]].Center; projectile.velocity = Vector2.Zero; projectile.frameCounter++; if (projectile.frameCounter % 5 == 0) { projectile.frame++; } if (projectile.frame >= Main.projFrames[projectile.type]) { projectile.active = false; } }
public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox) { Vector2 prev = Vector2.Zero; foreach (Vector2 point in points) { if (prev != Vector2.Zero) { float collisionPoint = 0f; if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), point, prev, 20, ref collisionPoint)) { Vector2 startPos = point + (Vector2.Normalize(prev - point) * collisionPoint); for (int i = 0; i < 3; i++) { Vector2 vel = Vector2.Normalize(point - prev).RotatedBy(Main.rand.NextFloat(-0.3f, 0.3f)) * 3; //vel = vel.RotatedBy(Main.rand.NextBool() ? -1.57f : 1.57f); vel.Normalize(); vel = vel.RotatedBy(Main.rand.NextFloat(-0.5f, 0.5f)); vel *= Main.rand.NextFloat(2, 5); VoidImpactLine line = new VoidImpactLine(startPos - (vel * 2), vel, Color.Purple, new Vector2(0.25f, Main.rand.NextFloat(0.75f, 1.75f)), 70); line.TimeActive = 30; ParticleHandler.SpawnParticle(line); } return(true); } } prev = point; } return(false); }
public override void Kill(int timeLeft) { if (Parent.type != ModContent.NPCType <StarWeaverNPC>() || !Parent.active || !Target.active) { return; } if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/starHit").WithVolume(0.65f).WithPitchVariance(0.3f), projectile.Center); for (int i = 0; i < 10; i++) { ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, Main.rand.NextVector2Circular(6, 6), Color.White, Color.Goldenrod, Main.rand.NextFloat(0.1f, 0.2f), 25)); } } for (int i = 0; i < 5; i++) { Vector2 vel = 26 * Vector2.UnitX.RotatedBy(TargetAngle + (MathHelper.TwoPi * (i / 5f))); Projectile.NewProjectileDirect(projectile.Center, vel, ModContent.ProjectileType <WeaverStarFragment>(), projectile.damage, projectile.knockBack, projectile.owner, 1f).netUpdate = true; } for (int i = 0; i < 5; i++) { Vector2 vel = Main.rand.NextFloat(8, 12) * Vector2.UnitX.RotatedBy(TargetAngle + (MathHelper.TwoPi * ((i + 0.5f) / 5f))); Projectile.NewProjectileDirect(projectile.Center, vel, ModContent.ProjectileType <WeaverStarFragment>(), (int)(projectile.damage * 0.75f), projectile.knockBack, projectile.owner, 0.5f).netUpdate = true; } }
public void Initialize() { //Objekte der Klassen werden initialisiert. map = new Map(new System.Drawing.Bitmap("Collision-Maps/Collision-Bitmap.bmp")); player = new Player("Cookie2", new Vector2f(200, 1400)); enemy = new Enemy01(); checkPointList = checkPointList01(); text = new Texture("Collision-Maps/Collision-Bitmap.bmp"); sprite = new Sprite(text); sprite.Scale = new Vector2f(50, 50); powerups = new Powerups01(); hud = new Hud(); start = new TimeSpan(0, 0, 3); Stopwatch timer = new Stopwatch(); TimeSpan time = new TimeSpan(); timer.Start(); time = new TimeSpan(0, 0, 1); pH = new ParticleHandler(); }