Exemplo n.º 1
0
        /// <summary>
        /// Copies the properties of this instance into the specified existing instance.
        /// </summary>
        /// <param name="exisitingInstance">An existing emitter instance.</param>
        protected override AbstractEmitter DeepCopy(AbstractEmitter exisitingInstance)
        {
            CircleEmitter value = (exisitingInstance as CircleEmitter) ?? new CircleEmitter();

            value.Radiate = this.Radiate;
            value.Radius  = this.Radius;
            value.Shell   = this.Shell;

            base.DeepCopy(value);

            return(value);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns an unitialised deep copy of the Emitter.
        /// </summary>
        /// <returns>A deep copy of the Emitter.</returns>
        public override Emitter DeepCopy()
        {
            CircleEmitter copy = new CircleEmitter
            {
                Radius = this.Radius,
                Radiate = this.Radiate,
                Ring = this.Ring
            };

            base.CopyBaseFields(copy);

            return copy;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns an unitialised deep copy of the Emitter.
        /// </summary>
        /// <returns>A deep copy of the Emitter.</returns>
        public override Emitter DeepCopy()
        {
            CircleEmitter copy = new CircleEmitter
            {
                Radius  = this.Radius,
                Radiate = this.Radiate,
                Ring    = this.Ring
            };

            base.CopyBaseFields(copy);

            return(copy);
        }
Exemplo n.º 4
0
        /// <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);
        }