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());
            }
        }
Exemple #2
0
        /// <summary>
        /// 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()
        {
            // TODO: Add your initialization logic here
            _gameObjectService = new GameObjectService();
            _bgColor = new Color(134, 185, 288);

            ParticleSystemSettings settings = new ParticleSystemSettings();
            position = new Vector2(this.Window.ClientBounds.Width/2, this.Window.ClientBounds.Height);
            settings.ParticleTextureFileName = "Graphics/Bubble";
            settings.IsBurst = true;
            settings.SetLifeTimes(1.0f, 1.5f);
            settings.SetScales(0.001f, 0.04f);
            settings.ParticlesPerSecond = 100.0f;
            settings.InitialParticleCount = (int)(settings.ParticlesPerSecond * settings.MaximumLifeTime);
            settings.SetDirectionAngles(0, 360);

            emitter = new ParticleSystem(this, settings);
            Components.Add(emitter);

            base.Initialize();
        }