public Thruster(Ship parent, Vector3 pos, Vector3 dir) : base(parent.Game) { if (pSys == null) { var pSet = new ParticleSettings() { BlendState = BlendState.NonPremultiplied, MaxParticles = 150, Duration = TimeSpan.FromSeconds(0.5), DurationRandomness = 0.1f, EmitterVelocitySensitivity = 0, MinVelocity = 1f, MaxVelocity = 2f, Gravity = Vector3.Zero, EndVelocity = 0, MinColor = Color.White, MaxColor = Color.White, MinRotateSpeed = -0.1f, MaxRotateSpeed = 0.1f, MinStartSize = 0.25f, MaxStartSize = 0.35f, MinEndSize = 0.5f, MaxEndSize = 0.6f }; var pTex = new Texture2D(GraphicsDevice, 5, 5); pTex.SetData(Enumerable.Repeat(Color.FromNonPremultiplied(0, 0, 255, 125), 25).ToArray()); var pEff = Game.Content.Load<Effect>("Shaders/Particles"); pSys = new ParticleSystem(Game, pSet, pTex, pEff, parent.Camera); Game.Components.Add(pSys); } this.parent = parent; this.pos = pos; this.Direction = dir; this.obj = new Primitive(GraphicsDevice, 0.1f, Primitives.Sphere) { Position = pos }; parent.Mesh.PrimitiveObjects.Add(this.obj); emitter = new ParticleEmitter(pSys) { Position = parent.Position + pos, Direction = dir, ParticlesPerSecond = 3 }; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); this.Services.AddService(typeof(SpriteBatch), spriteBatch); DiagnosticsManager.Initialize(this); SpriteBatchHelpers.Initialize(GraphicsDevice); Primitives.Initialize(GraphicsDevice); Billboard.Initialize(GraphicsDevice, Content.Load<Effect>("Shaders/Billboarding")); // TODO: use this.Content to load your game content here CreateSpheres(); ship = new Ship(this); followCam = new FollowCamera(camera, ship); lightningTexture = new LightningTexture(GraphicsDevice, 50, 100); #region Particles pSet = new ParticleSettings() { BlendState = BlendState.Additive, MaxParticles = 10, Duration = TimeSpan.FromSeconds(0.5), DurationRandomness = 0.1f, EmitterVelocitySensitivity = 0, MinVelocity = 1f, MaxVelocity = 2f, Gravity = Vector3.Zero, EndVelocity = 0, MinColor = Color.White, MaxColor = Color.White, MinRotateSpeed = -0.1f, MaxRotateSpeed = 0.1f, MinStartSize = 0.25f, MaxStartSize = 0.35f, MinEndSize = 0.5f, MaxEndSize = 0.6f }; var pTex = new Texture2D(GraphicsDevice, 5, 5); pTex.SetData(Enumerable.Repeat(Color.FromNonPremultiplied(0, 0, 255, 125), 25).ToArray()); var pEff = Content.Load<Effect>("Shaders/Particles"); pSys = new ParticleSystem(this, pSet, pTex, pEff, camera); pEmi = new ParticleEmitter(pSys) { Position = Vector3.UnitX, ParticlesPerSecond = 10 }; pEmi2 = new ParticleEmitter(pSys) { Position = -Vector3.UnitX, ParticlesPerSecond = 10 }; //pEmi = new ParticleEmitter(pSys) { Position = Vector3.UnitY, ParticlesPerSecond = 10 }; //pEmi = new ParticleEmitter(pSys) { Position = new Vector3(Vector2.One, 0), ParticlesPerSecond = 10 }; #endregion base.LoadContent(); }