Ejemplo n.º 1
0
        // surcharge
        public void AddParticles(Vector2 where, Statue statue)
        {
            // the number of particles we want for this effect is a random number
            // somewhere between the two constants specified by the subclasses.
            int numParticles =
                MoteurParticule.Random.Next(minNumParticles, maxNumParticles);

            // create that many particles, if you can.
            for (int i = 0; i < numParticles && freeParticles.Count > 0; i++)
            {
                // grab a particle from the freeParticles queue, and Initialize it.
                Particle p = freeParticles[0];
                freeParticles.RemoveAt(0);
                InitializeParticle(p, where, statue);
            }
        }
Ejemplo n.º 2
0
        // surcharge
        protected virtual void InitializeParticle(Particle p, Vector2 where, Statue statue)
        {
            // first, call PickRandomDirection to figure out which way the particle
            // will be moving. velocity and acceleration's values will come from this.
            Vector2 direction;
            if (statue.SourceRectangle.Value.Y == 357)
                direction = new Vector2(0, -1);
            else if (statue.SourceRectangle.Value.Y == 0)
                direction = new Vector2(0, 1);
            else if (statue.SourceRectangle.Value.Y == 123)
                direction = new Vector2(-1, 0);
            else
                direction = new Vector2(1, 0);

            // pick some random values for our particle
            float velocity =
                MoteurParticule.RandomBetween(minInitialSpeed, maxInitialSpeed);
            float acceleration =
                MoteurParticule.RandomBetween(minAcceleration, maxAcceleration);
            float lifetime =
                MoteurParticule.RandomBetween(minLifetime, maxLifetime);
            float scale =
                MoteurParticule.RandomBetween(minScale, maxScale);
            float rotationSpeed =
                MoteurParticule.RandomBetween(minRotationSpeed, maxRotationSpeed);

            // then initialize it with those random values. initialize will save those,
            // and make sure it is marked as active.
            p.Initialize(
                where, velocity * direction, acceleration * direction,
                lifetime, scale, rotationSpeed);
        }