/// <summary> /// Initializes a new instance of the <see cref="GravitySensor"/> class. /// </summary> /// <param name="world">The World object.</param> /// <param name="debugViewXNA">The DebugViewXNA object.</param> /// <param name="content">The ContentManager object.</param> /// <param name="graphics">The GraphicsDeviceManager object.</param> /// <param name="position">The initial position of the sensor.</param> /// <param name="radius">The radius of the sensor's shape.</param> /// <param name="density">The density of the sensor.</param> /// <param name="strength">The gravity strength of the sensor.</param> /// <param name="minRadius">The minimum radius the gravity can affect.</param> /// <param name="maxRadius">The maximum radius the gravity can affect.</param> /// <param name="effect">The ParticleEffect for the sensor.</param> /// <param name="screenManager">The ScreenManager object.</param> public GravitySensor(World world, DebugViewXNA debugViewXNA, ContentManager content, GraphicsDeviceManager graphics, Vector2 position, float radius, float density, float strength, float minRadius, float maxRadius, ScreenManager.ScreenManager screenManager ) : base(world, debugViewXNA, content, graphics, position, radius, density, strength, minRadius, maxRadius) { this.mParticleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = this.mGraphics }; this.mParticleManager = new ParticleEffectManager(this.mParticleRenderer); this.mEmitter = new CircleEmitter { Radius = this.mRadius, Ring = true, Radiate = true, Budget = 500, ReleaseColour = new VariableFloat3 { Value = new Vector3(0, 1, 1), Variation = new Vector3(0, 0, 0) }, ReleaseQuantity = 4, ReleaseImpulse = new Vector2(0, 0), ReleaseOpacity = new VariableFloat { Value = 1f, Variation = 0f }, ReleaseRotation = new VariableFloat { Value = 3.14f, Variation = 3.14f }, ReleaseSpeed = new VariableFloat { Value = 50f, Variation = 25f }, ReleaseScale = new VariableFloat { Value = 48f, Variation = 32f }, BlendMode = EmitterBlendMode.Add, Term = 0.9f, MinimumTriggerPeriod = 0f }; this.mEmitter.ParticleTexture = mContent.Load<Texture2D>(@"Textures\LensFlare"); this.mEmitter.Modifiers.Add(new ColourModifier { InitialColour = Color.White.ToVector3(), UltimateColour = Color.Aqua.ToVector3() }); this.mEmitter.Modifiers.Add(new RotationRateModifier { InitialRate = 10f, FinalRate = 1f }); this.mEmitter.Modifiers.Add(new OpacityInterpolatorModifier { InitialOpacity = 0f, MiddleOpacity = 0.15f, MiddlePosition = 0.7f, FinalOpacity = 0f }); this.mParticleEffect = new ParticleEffect { this.mEmitter }; this.mParticleEffect.Initialise(); this.mParticleManager.Add(this.mParticleEffect); this.mParticleRenderer.LoadContent(this.mContent); this.mParticleEffect.LoadContent(this.mContent); this.mParticleEnabled = true; this.mWorld.ContactManager.BeginContact += BeginContact; this.mWorld.ContactManager.EndContact += EndContact; this.mInfo = new SensorInfoText(this.mContent, this.mGraphics, ConvertUnits.ToDisplayUnits(this.mPosition), Color.White); }
/// <summary> /// Initializes a new instance of the <see cref="GravitySensor"/> class. /// </summary> /// <param name="world">The World object.</param> /// <param name="debugViewXNA">The DebugViewXNA object.</param> /// <param name="content">The ContentManager object.</param> /// <param name="graphics">The GraphicsDeviceManager object.</param> /// <param name="position">The initial position of the sensor.</param> /// <param name="radius">The radius of the sensor's shape.</param> /// <param name="density">The density of the sensor.</param> /// <param name="strength">The gravity strength of the sensor.</param> /// <param name="minRadius">The minimum radius the gravity can affect.</param> /// <param name="maxRadius">The maximum radius the gravity can affect.</param> /// <param name="effect">The ParticleEffect for the sensor.</param> /// <param name="screenManager">The ScreenManager object.</param> public GravitySensor(World world, DebugViewXNA debugViewXNA, ContentManager content, GraphicsDeviceManager graphics, Vector2 position, float radius, float density, float strength, float minRadius, float maxRadius, ParticleEffect effect, ScreenManager.ScreenManager screenManager ) : base(world, debugViewXNA, content, graphics, position, radius, density, strength, minRadius, maxRadius) { this.mParticleEffect = effect; this.mParticleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = this.mGraphics }; this.mParticleManager = new ParticleEffectManager(this.mParticleRenderer); this.mParticleManager.Add(this.mParticleEffect); this.mParticleEffect.LoadContent(this.mContent); this.mParticleEffect.Initialise(); this.mParticleRenderer.LoadContent(this.mContent); this.mParticleEnabled = true; this.mWorld.ContactManager.BeginContact += BeginContact; this.mWorld.ContactManager.EndContact += EndContact; this.mInfo = new SensorInfoText(this.mContent, this.mGraphics, ConvertUnits.ToDisplayUnits(this.mPosition), Color.White); }