public static void SpawnProjectile(Entity shooter, ParticleTemplate template) { //Don't spawn more particles than the set limit if (Count() >= MaxParticles || template == null) return; Particle projectile = new Particle(shooter.Position, template, shooter); projectile.Rotation = shooter.Rotation; projectile.Speed = template.GetValue<float>(ParticleValues.Speed); projectile.Team = shooter.Team; //Spawn projectile from gun barrel and not unit origin projectile.X += (float)Math.Cos(shooter.Rotation) * shooter.Width/2; projectile.Y += (float)Math.Sin(shooter.Rotation) * shooter.Width/2; //Spawn it and add it last in our list SpawnList.AddLast(projectile); }
public void Render(Particle particle, int cameraOffset) { Rectangle target = particle.Bounds; if (!Camera.ObjectIsVisible(target)) return; //Calculate screen position target.X -= (int)Camera.Position.X - cameraOffset; target.Y -= (int)Camera.Position.Y; //Draw it there _spriteBatch.Draw(particle.Texture, target, null, Color.White * particle.Alpha, particle.Rotation, new Vector2(particle.Texture.Width / 2.0f, particle.Texture.Height / 2.0f), SpriteEffects.None, 0); }