示例#1
0
        protected virtual void InitializeParticle(Particle p, Vector2 where)
        {
            // first, call PickRandomDirection to figure out which way the particle
            // will be moving. velocity and acceleration's values will come from this.

            Vector2 direction;
            float angle = MoteurParticule.RandomBetween(0, MathHelper.TwoPi);
            direction = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));

            // 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);
        }
示例#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);
        }