Random rand = new Random(); // random number generator

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">the current instance of the game</param>
        /// <param name="newSettings">setting for the particle system</param>
        public ParticleSystem(Game game, ParticleSystemSettings newSettings)
            : base(game)
        {
            m_settings = newSettings;

            m_particleList = new List<Particle>(m_settings.InitialParticleCount);

            for (int i = 0; i < m_settings.InitialParticleCount; ++i)
            {
                m_particleList.Add(new Particle());
            }
        }
        private ParticleSystemSettings m_settings = null;   // particles settings

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">the current instance of the game</param>
        /// <param name="newSettings">setting for the particle system</param>
        public ParticleSystem(Game game, ParticleSystemSettings newSettings, Texture2D Sprite)
            : base(game)
        {
            m_settings       = newSettings;
            m_particleSprite = Sprite;
            m_particleList   = new List <Particle>(m_settings.InitialParticleCount);

            for (int i = 0; i < m_settings.InitialParticleCount; ++i)
            {
                m_particleList.Add(new Particle());
            }

            m_origin = new Vector2(m_particleSprite.Width / 2, m_particleSprite.Height / 2);
        }
Beispiel #3
0
        public override void Initialize()
        {
            ParticleSystemSettings settings = new ParticleSystemSettings();
            settings.ParticleTextureFileName = "ParticleStar";
            settings.IsBurst = false;
            settings.SetLifeTimes(0.5f, 1f);
            settings.SetScales(0.1f, 0.4f);
            settings.ParticlesPerSecond = 50.0f;
            settings.InitialParticleCount = (int)(settings.ParticlesPerSecond * settings.MaximumLifeTime);
            settings.SetDirectionAngles(0, 360);

            emitter = new ParticleEmitter.ParticleSystem(game, settings);
            emitter.Initialize();

            base.Initialize();
        }