private static void LoadParticleSystemSettings()
 {
     string dir = System.IO.Path.Combine(System.Reflection.Assembly.GetExecutingAssembly().Location, "../Content/resources/particleSystemSettings");
     System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dir);
     System.IO.FileInfo[] files = di.GetFiles("*.vtpss");
     foreach (System.IO.FileInfo file in files)
     {
         StreamReader read = new StreamReader(file.FullName);
         ParticleSystemSettings psset = new ParticleSystemSettings();
         psset.Load(read);
         read.Close();
         RendererAssetPool.ParticleSystemSettings.Add(Path.GetFileNameWithoutExtension(file.Name), psset);
     }
 }
Beispiel #2
0
        private void LoadParticleSettings()
        {
            ParticleSystemSettings settings = new ParticleSystemSettings();

            settings.Capacity = 100;
            settings.Duration = TimeSpan.FromSeconds(.5f);
            settings.DurationRandomness = 0;

            settings.GlobalForce = Vector3.Zero;
            settings.MinForceSensitivity = 0.75f;
            settings.MaxForceSensitivity = 1;
            settings.InertiaSensitivity = 1;

            settings.MinStartHorizontalVelocity = -600;
            settings.MaxStartHorizontalVelocity = 600;
            settings.MinStartVerticalVelocity = -600;
            settings.MaxStartVerticalVelocity = 600;

            settings.MinEndHorizontalVelocity = 20;
            settings.MaxEndHorizontalVelocity = 20;
            settings.MinEndVerticalVelocity = 20;
            settings.MaxEndVerticalVelocity = 20;

            settings.MinStartSize = 1;
            settings.MaxStartSize = 1;
            settings.MinEndSize = 1;
            settings.MaxEndSize = 1;

            settings.MinRotateSpeed = 0;
            settings.MaxRotateSpeed = 50;

            settings.MinColor = Color.DarkGray;
            settings.MaxColor = Color.Gray;

            settings.SourceBlend = Blend.SourceAlpha;
            settings.DestinationBlend = Blend.One;

            Texture2D texture = content.Load<Texture2D>("explosion");

            particles = new ParticleSystem(texture, settings);
        }
        /// <summary>
        /// Creates a new particle system from a ParticleSystemSettings object.
        /// </summary>
        /// <param name="_settings">The ParticleSystemSettings object.</param>
        public ParticleSystem(ParticleSystemSettings _settings)
        {
            if (_settings.Initialized)
            {
                settings = _settings;
            }
            else
            {
                settings = RendererAssetPool.ParticleSystemSettings["Sample"];
            }
            texture = settings.Texture;
            particles = new Particle[settings.Capacity];
            random = new Random();
            currentTime = 0;

            vertDeclaration = new VertexDeclaration(GraphicOptions.graphics.GraphicsDevice,
                                                     Particle.VertexElements);

            vertBuffer = new DynamicVertexBuffer(GraphicOptions.graphics.GraphicsDevice,
                                                settings.Capacity * Particle.SizeInBytes,
                                                BufferUsage.WriteOnly | BufferUsage.Points);

            LoadEffect();
        }