Пример #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;
        }
Пример #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();
 }
Пример #3
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);
        }
Пример #4
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;
            }
        }