예제 #1
0
 public ParticleSystem(Game game)
     : base(game)
 {
     //content = new ContentManager(game.Services);
     content  = game.Content;
     settings = new ParticleSystemSettings();
 }
예제 #2
0
        internal void Initialize(ParticleSystemSettings settings, bool makeAlive)
        {
            Age     = 0;
            IsAlive = makeAlive;

            Vector3 minPosition = (settings.EmitPosition - (settings.EmitRange * .5f));
            Vector3 maxPosition = (settings.EmitPosition + (settings.EmitRange * .5f));

            Vector3 position = Utility.GetRandomVector3(minPosition, maxPosition);

            Vertex.Position = position;

            if (settings.EmitRadius != Vector2.Zero)
            {
                float angle = Utility.GetRandomFloat(0, MathHelper.TwoPi);

                Vertex.Position = new Vector3(
                    position.X + (float)Math.Sin(angle) * settings.EmitRadius.X,
                    position.Y,
                    position.Z + (float)Math.Cos(angle) * settings.EmitRadius.Y);
            }

            velocity = Utility.GetRandomVector3(
                settings.MinimumVelocity, settings.MaximumVelocity);

            acceleration = Utility.GetRandomVector3(
                settings.MinimumAcceleration, settings.MaximumAcceleration);

            lifetime = Utility.GetRandomFloat(
                settings.MinimumLifetime, settings.MaximumLifetime);

            if (settings.DisplayColorsInOrder)
            {
                Vertex.Color    = settings.Colors[0];
                ColorChangeRate = lifetime / settings.Colors.Length;
            }
            else
            {
                Vertex.Color =
                    settings.Colors[Utility.GetRandomInt(0, settings.Colors.Length)];
            }

            //Vertex.PointSize = Utility.GetRandomFloat(
            //    settings.MinimumSize, settings.MaximumSize);

            externalForce = settings.ExternalForce;
        }
예제 #3
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            settings = InitializeSettings();

            particles = new Particle[settings.Capacity];

            //vertices = new VertexPointSprite[settings.Capacity];
            vertices = new VertexPositionColor[settings.Capacity];

            for (int i = 0; i < settings.Capacity; i++)
            {
                particles[i] = new Particle();
                particles[i].Initialize(settings, false);
            }

            numberOfActiveParticles = 0;

            base.Initialize();
        }
예제 #4
0
 internal void Initialize(ParticleSystemSettings settings)
 {
     Initialize(settings, true);
 }