/// <summary>C:\Users\John Getty\Desktop\MPE\ParticleTextures\Particle001.png
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            _renderer =new BillboardRenderer {GraphicsDeviceService = _graphics};

            var colors = new[]
                                   {
                                       Color.Pink.ToVector3(), Color.Yellow.ToVector3(), Color.Lavender.ToVector3(),
                                       Color.Salmon.ToVector3()
                                   };
            _manager = new ParticleEffectManager(_renderer);
            for (int i = 0; i < 4; i++)
            {
                _emitters[i] = new SphereEmitter
                                   {
                                       Radius = 10,
                                       Radiate = true,
                                       Budget = 16384,
                                       ReleaseColour = colors[i],
                                       ReleaseQuantity = 50/(i+1),
                                       BlendMode = EmitterBlendMode.Add,
                                       ReleaseSpeed =  .2f * (4-i),
                                       ReleaseOpacity = .1f,
                                       ReleaseScale = (i+1) * 5 *.02f,
                                       Term = 1,
                                   };

                if (i==1)
                {
                    _emitters[i].Modifiers.Add(new LinearGravityModifier { Gravity = new Vector3(-2, -2, 0) });
                    _emitters[i].Modifiers.Add(new OpacityModifier {Initial = 0.2f, Ultimate = 0f});
                }
                if (i==2)
                {
                    _emitters[i].Modifiers.Add(new LinearGravityModifier { Gravity = new Vector3(1, -1, 0) });
                    _emitters[i].Modifiers.Add(new ColourModifier
                                                   {
                                                       InitialColour = Color.Red.ToVector3(),
                                                       UltimateColour = Color.White.ToVector3()
                                                   });
                    _emitters[i].Modifiers.Add(new OpacityModifier {Initial = 0.4f, Ultimate = 0f});
                   
                }
            }
            _effect = new ParticleEffect { _emitters[0], _emitters[1], _emitters[2], _emitters[3] };
            _effect.Initialise();

            _manager.Add(_effect);



            _projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, _graphics.GraphicsDevice.Viewport.AspectRatio, 1f, 500f);


            base.Initialize();
        }
Beispiel #2
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)
        {
            SphereEmitter value = (exisitingInstance as SphereEmitter) ?? new SphereEmitter();

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

            base.DeepCopy(value);

            return(value);
        }
        public override Emitter DeepCopy()
        {
            SphereEmitter copy = new SphereEmitter
            {
                Radius = this.Radius,
                Shell = this.Shell,
                Radiate = this.Radiate
            };

            base.CopyBaseFields(copy);

            return copy;
        }