Example #1
0
        void RemoveRainAt(int index)
        {
            RainParticle removed = rainParticles[index];

            for (int i = index; i < rainCount - 1; i++)
            {
                rainParticles[i] = rainParticles[i + 1];
            }
            rainParticles[rainCount - 1] = removed;
            rainCount--;
        }
Example #2
0
        RainParticle GetRainParticle()
        {
            if (rainCount == maxParticles)
            {
                RemoveRainAt(0);
            }
            rainCount++;

            RainParticle particle = rainParticles[rainCount - 1];

            if (particle != null)
                return(particle); }
Example #3
0
        public void AddRainParticle(Vector3 pos)
        {
            Vector3 startPos = pos;

            for (int i = 0; i < 2; i++)
            {
                double  velX     = rnd.NextDouble() * 0.8 - 0.4;            // [-0.4, 0.4]
                double  velZ     = rnd.NextDouble() * 0.8 - 0.4;
                double  velY     = rnd.NextDouble() + 0.4;
                Vector3 velocity = new Vector3((float)velX, (float)velY, (float)velZ);

                double xOffset = rnd.NextDouble() - 0.5;                 // [-0.5, 0.5]
                double yOffset = rnd.NextDouble() * 0.1 + 0.01;
                double zOffset = rnd.NextDouble() - 0.5;
                pos = startPos + new Vector3(0.5f + (float)xOffset,
                                             (float)yOffset, 0.5f + (float)zOffset);
                double       life = 40;
                RainParticle p    = AddParticle(rainParticles, ref rainCount, true);
                p.ResetState(pos, velocity, life);
                p.Big  = rnd.Next(0, 20) >= 18;
                p.Tiny = rnd.Next(0, 30) >= 28;
            }
        }
Example #4
0
        public void AddRainParticle(Vector3 pos)
        {
            Vector3 startPos = pos;

            for (int i = 0; i < 2; i++)
            {
                double  velX     = rnd.NextDouble() * 0.8 - 0.4;            // [-0.4, 0.4]
                double  velZ     = rnd.NextDouble() * 0.8 - 0.4;
                double  velY     = rnd.NextDouble() + 0.4;
                Vector3 velocity = new Vector3((float)velX, (float)velY, (float)velZ);

                double xOffset = rnd.NextDouble() - 0.5;                 // [-0.5, 0.5]
                double yOffset = rnd.NextDouble() * 0.1 + 0.01;
                double zOffset = rnd.NextDouble() - 0.5;
                pos = startPos + new Vector3(0.5f + (float)xOffset,
                                             (float)yOffset, 0.5f + (float)zOffset);
                double       life = 40;
                RainParticle p    = GetRainParticle();
                p.ResetState(pos, velocity, life);
                int type = rnd.Next(0, 30);
                p.Size = (byte)(type >= 28 ? 2 : (type >= 25 ? 4 : 3));
            }
        }