Exemplo n.º 1
0
        public void RandomizeMapColor(bool firstRun = false)
        {
            Matrix4 color = this.Graphics.Blue;

            for (int i = 0; i < 50; i++)
            {
                int rand = GlobalRandom.Next(5);

                color = this.Graphics.Blue;
                if (rand == 1)
                {
                    color = this.Graphics.Green;
                }
                if (rand == 2)
                {
                    color = this.Graphics.Purple;
                }
                if (rand == 3)
                {
                    color = this.Graphics.Orange;
                }
                if (rand == 4)
                {
                    color = this.Graphics.Red;
                }

                if (!firstRun && color != this.Graphics.WallColorUniform.Matrix)
                {
                    break;
                }
            }

            this.Graphics.WallColorUniform.Matrix = color;
        }
Exemplo n.º 2
0
 public void PlayOmnomnom()
 {
     this.lastRandom += 1 + GlobalRandom.Next(this.omnomnoms.Length - 1);
     this.lastRandom %= this.omnomnoms.Length;
     Source s = this.omnomnoms[this.lastRandom].GenerateSource();
     s.Play();
 }
Exemplo n.º 3
0
        private ScreenShake(float force, float seconds, float speedInv, List <ScreenShake> container)
        {
            this.Force           = force;
            this.initialLifetime = seconds;
            this.Seconds         = seconds;
            this.SpeedInv        = speedInv;
            this.container       = container;
            Vector2 dir = GameMath.Vector2FromRotation((float)(MathHelper.TwoPi * GlobalRandom.NextDouble()));

            this.Direction = new Vector3(dir.X, 0, dir.Y);
        }
Exemplo n.º 4
0
        public Vector2 Create2()
        {
            // Get the length
            float length = (float)GlobalRandom.Rand(lengthD, avgLength, lengthDev);

            // Get the angle
            float angle = (float)GlobalRandom.Rand(angleD, avgAngle, angleDev);

            // Get the vector
            return(GameMath.Vector2FromRotation(angle, length));
        }
Exemplo n.º 5
0
        public virtual Vector3 Create()
        {
            // Get the length
            float length = (float)GlobalRandom.Rand(lengthD, avgLength, lengthDev);

            // Get the angle
            float angle  = (float)GlobalRandom.Rand(angleD, avgAngle, angleDev);
            float angle2 = (float)GlobalRandom.Rand(angleD, avgAngle, angleDev);

            // Get the vector
            return(GameMath.Vector3FromRotation(angle, angle2, length));
        }
Exemplo n.º 6
0
        protected virtual ParticleT createParticle(float elepsedS)
        {
            float percentage = this.calculateEmitterPercentage();

            // Calculate the lifetime
            float lifetime = 1f;

            if (this.AverageLifetimes.Length == 1)
            {
                lifetime = this.AverageLifetimes[0].Value;
            }
            else
            {
                int i = this.AverageLifetimes.GetToIndex(percentage);
                lifetime = GameMath.Lerp(this.AverageLifetimes[i - 1].Value, this.AverageLifetimes[i].Value, AverageLifetimes.GetLerpFactor(i, percentage));
            }
            lifetime = (float)GlobalRandom.Rand(this.Distribution, lifetime, this.LifeTimeDeviation);

            // Adjust the scales
            PercentageArray <float> scales = this.ScalePercentages.Clone();

            if (ScaleDiesToo)
            {
                float factor = lifetime / this.AverageLifetimes[0].Value;
                for (int i = 0; i < scales.Length; i++)
                {
                    scales[i].Value = scales[i].Value * factor;
                }
            }

            // Adjust the alphas
            PercentageArray <float> alphas = this.AlphaPercentages.Clone();

            if (AlphaDiesToo)
            {
                float factor = lifetime / this.AverageLifetimes[0].Value;
                for (int i = 0; i < alphas.Length; i++)
                {
                    alphas[i].Value = alphas[i].Value * factor;
                }
            }

            // Create the particle
            ParticleT particle = this.createParticle(elepsedS, lifetime, scales, alphas);

            return(particle);
        }
Exemplo n.º 7
0
        //protected abstract ParticleT createParticle(float elepsedS, float lifetime, PercentageArray<float> scales, byte alpha);
        protected virtual ParticleT createParticle(float elepsedS, float lifetime, PercentageArray <float> scales, PercentageArray <float> alphas)
        {
            Vector3   velocity = this.Velocity.Create();
            ParticleT particle = new ParticleT();

            particle.Initialize(
                this.Position + velocity * elepsedS * (GlobalRandom.Next(4) + 1f) / 4f,
                velocity,
                this.Acceleration.Create(),
                lifetime,
                this.ColorPercentages,
                scales,
                alphas,
                this.Geometry
                );
            return(particle);
        }
Exemplo n.º 8
0
        public virtual void Update(UpdateEventArgs e)
        {
            if (this.firstTime)
            {
                // Pregenerate particles if nescessary
                for (int i = 0; i < this.PreGenerate; i++)
                {
                    ParticleT p               = this.addParticle(0);
                    int       maxUpdates      = (int)(this.AverageLifetimes[0].Value / this.Velocity.AverageLength);
                    int       amountOfUpdates = GlobalRandom.Next(0, maxUpdates);
                    for (int j = 0; j < amountOfUpdates; j++)
                    {
                        p.Update(e);
                    }
                }
                this.firstTime = false;
            }

            // Substract lifetime and check if there is nothing left of it.
            if (this.manageLifetime(e))
            {
                this.Stop();
            }

            // Add new particles if nescessary
            if (!this.Stopped())
            {
                this.timeLeftToSpawn -= e.ElapsedTimeInSf;
                while (this.timeLeftToSpawn < 0)
                {
                    for (int i = 0; i < this.NumberOfParticlesToSpawn; i++)
                    {
                        this.addParticle(e.ElapsedTimeInSf);
                    }
                    this.timeLeftToSpawn += this.SecondsBetweenSpawning;
                }
            }

            // Update all the live particles and remove those that are dead.
            LinkedListNode <ParticleT> n = this.particles.First;

            while (n != null)
            {
                if (n.Value.IsDead())
                {
                    if (n == this.particles.First)
                    {
                        this.particles.RemoveFirst();
                        n = this.particles.First;
                        continue;
                    }
                    else
                    {
                        n = n.Previous;
                        this.particles.Remove(n.Next);
                        n = n.Next;
                        continue;
                    }
                }
                n.Value.Update(e);
                n = n.Next;
            }
        }