public void CreateBloodSplatter(Vector3 playerPosition, Color color)
 {
     for (int i = 0; i < 30; i++)
     {
         Particle p = new Particle();
         p.Color = color;
         p.Size = (float)(randGen.NextDouble()*0.2 + 0.05);
         p.Position = playerPosition;
         p.Position.Y -= (float)randGen.NextDouble();
         p.Velocity = new Vector3((float)randGen.NextDouble() * 5 - 2.5f, (float)randGen.NextDouble() * 4f, (float)randGen.NextDouble() * 5 - 2.5f);
         particleList.Add(p);
     }
 }
 private static bool ParticleExpired(Particle particle)
 {
     return particle.FlaggedForDeletion;
 }
 public void CreateExplosionDebris(Vector3 explosionPosition)
 {
     for (int i = 0; i < 50; i++)
     {
         Particle p = new Particle();
         p.Color = new Color(90,60,40);
         p.Size = (float)(randGen.NextDouble() * 0.4 + 0.05);
         p.Position = explosionPosition;
         p.Position.Y += (float)randGen.NextDouble() - 0.5f;
         p.Velocity = new Vector3((float)randGen.NextDouble() * 8 - 4, (float)randGen.NextDouble() * 8, (float)randGen.NextDouble() * 8 - 4);
         particleList.Add(p);
     }
 }
Beispiel #4
0
        public void CreateBlockDebris(Vector3 explosionPosition, BlockType block, float mag)
        {
            if (mag < 0.1f)
                return;

            if (block == BlockType.Water)
            {
                mag = mag / 6;
            }
            else if (block == BlockType.Lava)
            {
                mag = mag / 5;
                if (_P.blockEngine.BlockAtPoint(explosionPosition + new Vector3(0.0f,0.5f,0.0f)) == BlockType.Lava)
                {//would not be visible
                    return;
                }
            }

            for (int i = 0; i < (int)(5*mag); i++)
            {
                Particle p = new Particle();

                p.Size = (float)(randGen.NextDouble() * 0.1 + 0.02);
                p.Position = explosionPosition;
                p.Position.X += (float)randGen.NextDouble() - 0.5f;
                p.Position.Z += (float)randGen.NextDouble() - 0.5f;
                p.Position.Y += (float)randGen.NextDouble() - 0.5f;
                p.Velocity = new Vector3(0.0f, (float)randGen.NextDouble() * 2 - 1, 0.0f);
                p.Bounce = 0.2f;
                p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(2.0 + randGen.NextDouble());//2
                p.SizeChange = 0.1f;

                if (block == BlockType.Gold)
                {
                    int ll = randGen.Next(0, 3);
                    if (ll == 2)
                    {
                        p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                    }
                    else
                    {
                        p.Color = new Vector4(0.65f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 0.15f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 1.0f);
                        p.Gravity = 20.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Bounce = 0.1f;
                    }

                }
                else if (block == BlockType.Sand)
                {
                    p.Color = new Vector4(0.9f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.7f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.3f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                }
                else if (block == BlockType.RadarRed)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.RadarBlue)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.SolidRed || block == BlockType.SolidRed2 || block == BlockType.GlassR || block == BlockType.ArtCaseR || block == BlockType.ResearchR || block == BlockType.BeaconRed)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.SolidBlue || block == BlockType.SolidBlue2 || block == BlockType.GlassB || block == BlockType.ArtCaseB || block == BlockType.ResearchB || block == BlockType.BeaconBlue)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.ConstructionR)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.ConstructionB)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.Metal)
                {
                    p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                }
                else if (block == BlockType.Ore)
                {
                    int ll = randGen.Next(0, 3);
                    if (ll == 2)
                    {
                        p.Color = new Vector4(0.45f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.255f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.186f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                    }
                    else
                    {
                        p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                        p.Gravity = 20.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Bounce = 0.4f;
                    }
                }
                else if (block == BlockType.Highlight)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(4.0 - randGen.NextDouble());
                    p.Color = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
                    p.Bounce = 0.0f;
                    p.Position += new Vector3((float)(randGen.NextDouble() * 1.0f), (float)(randGen.NextDouble() * 1.0f), (float)(randGen.NextDouble() * 1.0f));
                    p.Velocity = new Vector3((float)(randGen.NextDouble() * 0.5f), (float)(randGen.NextDouble() * 0.5f), (float)(randGen.NextDouble() * 0.5f));
                    p.Gravity = 2.0f;
                }
                else if (block == BlockType.Water)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.0 - randGen.NextDouble());
                    p.Color = new Vector4(0.1f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.4f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.70f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                    p.SizeChange = 0.2f;
                    p.Bounce = 0.0f;
                    p.Position.Y += ((float)randGen.NextDouble()*0.5f) + 0.75f ;
                    p.Velocity = new Vector3(0.0f, -0.25f + (float)randGen.NextDouble(), 0.0f);
                    p.Gravity = 6.0f;
                }
                else if (block == BlockType.Lava)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.0 - randGen.NextDouble());
                    int ll = randGen.Next(0, 2);
                    if (ll == 0)
                    {
                        p.Color = new Vector4(0.95f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.7f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.05f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                        p.Gravity = 6.0f;
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, 1.0f + (float)randGen.NextDouble() * 2.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    else if(ll == 1)
                    {
                        p.Color = new Vector4(0.3f + (float)((randGen.NextDouble() - 0.5f) * 0.01f), 0.01f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.0f, 1.0f);
                        p.Gravity = 2.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, 1.0f + (float)randGen.NextDouble() * 2.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    else if (ll == 2)
                    {
                        p.Gravity = 4.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.02f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 0.01f, 1.0f);
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, (float)randGen.NextDouble() * 1.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    p.SizeChange = 0.2f;
                    p.Bounce = 0.0f;
                    p.Position.Y += 1.0f + (float)randGen.NextDouble() - 0.5f;

                }
                else if (block == BlockType.Dirt || block == BlockType.DirtSign || block == BlockType.Grass)
                {
                    p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                }
                else
                {
                    p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                    //p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                }

                particleList.Add(p);
            }
        }
Beispiel #5
0
        public void CreateTrail(Vector3 Position, Color color)
        {
            for (int i = 0; i < 1; i++)
            {
                Particle p = new Particle();
                p.Color = color.ToVector4();

                p.Size = 0.15f;
                p.Position = Position;
                p.Gravity = -2.0f;
                //p.Position.Y += (float)randGen.NextDouble();
                p.Velocity = new Vector3((float)randGen.NextDouble() * 2 - 1.0f, 0.0f, (float)randGen.NextDouble() * 2 - 1.0f);
                p.Lifetime = DateTime.Now;
                p.Bounce = 0.5f;
                p.SizeChange = 0.2f;
                particleList.Add(p);
            }
        }
Beispiel #6
0
 public void CreateExplosionDebris(Vector3 explosionPosition)
 {
     for (int i = 0; i < 50; i++)
     {
         Particle p = new Particle();
         p.Color = new Vector4(0.35f,0.235f,0.156f,1.0f);
         p.Size = (float)(randGen.NextDouble() * 0.4 + 0.05);
         p.Position = explosionPosition;
         p.Position.Y += (float)randGen.NextDouble() - 0.5f;
         p.Velocity = new Vector3((float)randGen.NextDouble() * 8 - 4, (float)randGen.NextDouble() * 8, (float)randGen.NextDouble() * 8 - 4);
         p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(5.0);
         p.Expirytime = TimeSpan.FromSeconds(0.0);
         particleList.Add(p);
     }
 }
Beispiel #7
0
        public void CreateDiggingDebris(Vector3 explosionPosition, BlockType block)
        {
            for (int i = 0; i < 10; i++)
            {
                Particle p = new Particle();
                p.Color = new Vector4(0.3f,0.3f,0.3f,1.0f);//0.35f,0.235f,0.156f,1.0f);//new Color(90, 60, 40);
                p.Size = (float)(randGen.NextDouble() * 0.05 + 0.01);
                p.Position = explosionPosition;
                p.Position.Y += (float)randGen.NextDouble() - 0.5f;
                p.Velocity = new Vector3((float)randGen.NextDouble() * 4 - 2, (float)randGen.NextDouble() * 3, (float)randGen.NextDouble() * 4 - 2);
                p.Lifetime = DateTime.Now+TimeSpan.FromSeconds(2.0);
                p.Bounce = 0.3f;
                p.SizeChange = 0.1f;

                if (block == BlockType.Gold)
                {
                    int ll = randGen.Next(0, 3);
                    if (ll == 2)
                    {
                        p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                    }
                    else
                    {
                        p.Color = new Vector4(0.65f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 0.15f + (float)((randGen.NextDouble() - 0.5f) * 0.1f), 1.0f);
                        p.Gravity = 20.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Bounce = 0.1f;
                    }

                }
                else if (block == BlockType.SolidRed || block == BlockType.SolidRed2 || block == BlockType.GlassR || block == BlockType.ArtCaseR || block == BlockType.ResearchR || block == BlockType.BeaconRed)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.RadarRed)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.RadarBlue)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.SolidBlue || block == BlockType.SolidBlue2 || block == BlockType.GlassB || block == BlockType.ArtCaseB || block == BlockType.ResearchB || block == BlockType.BeaconBlue)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.Metal)
                {
                    p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                }
                else if (block == BlockType.ConstructionR)
                {
                    p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 0.1f, 0.1f, 1.0f);
                }
                else if (block == BlockType.ConstructionB)
                {
                    p.Color = new Vector4(0.1f, 0.1f, 0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.2f), 1.0f);
                }
                else if (block == BlockType.Sand)
                {
                    p.Color = new Vector4(0.9f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.7f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.3f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                }
                else if (block == BlockType.Ore)
                {
                    int ll = randGen.Next(0, 3);
                    if (ll == 2)
                    {
                        p.Color = new Vector4(0.45f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.255f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.186f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                    }
                    else
                    {
                        p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                        p.Gravity = 20.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Bounce = 0.4f;
                    }
                }
                else if (block == BlockType.Highlight)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.0 - randGen.NextDouble());
                    p.Color = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
                    int ll = randGen.Next(0, 5);
                    int llb = randGen.Next(0, 3) - 1;
                    if (ll == 1)
                    {
                        p.Position.X += 0.5f * llb;
                        _P.addChatMessage("" + llb, ChatMessageType.SayAll, 10);
                    }
                    else if (ll == 2)
                    {
                        p.Position.Y += 0.5f * llb;
                    }
                    else if (ll == 3)
                    {
                        p.Position.Z += 0.5f * llb;
                    }
                    p.Velocity = new Vector3((float)(randGen.NextDouble() * 0.5f), (float)(randGen.NextDouble() * 0.5f), (float)(randGen.NextDouble() * 0.5f));
                    p.Gravity = 0.0f;
                }
                else if (block == BlockType.Water)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.0 - randGen.NextDouble());
                    p.Color = new Vector4(0.1f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.4f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.70f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                    p.SizeChange = 0.2f;
                    p.Bounce = 0.0f;
                    p.Position.Y += ((float)randGen.NextDouble() * 0.5f) + 0.75f;
                    p.Velocity = new Vector3(0.0f, -0.25f + (float)randGen.NextDouble(), 0.0f);
                    p.Gravity = 6.0f;
                }
                else if (block == BlockType.Lava)
                {
                    p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.0 - randGen.NextDouble());
                    int ll = randGen.Next(0, 2);
                    if (ll == 0)
                    {
                        p.Color = new Vector4(0.95f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.7f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.05f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 1.0f);
                        p.Gravity = 6.0f;
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, 1.0f + (float)randGen.NextDouble() * 2.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    else if (ll == 1)
                    {
                        p.Color = new Vector4(0.3f + (float)((randGen.NextDouble() - 0.5f) * 0.01f), 0.01f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.0f, 1.0f);
                        p.Gravity = 2.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, 1.0f + (float)randGen.NextDouble() * 2.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    else if (ll == 2)
                    {
                        p.Gravity = 4.0f + (float)randGen.NextDouble() - 0.5f;
                        p.Color = new Vector4(0.8f + (float)((randGen.NextDouble() - 0.5f) * 0.025f), 0.02f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 0.01f, 1.0f);
                        p.Velocity = new Vector3(((float)randGen.NextDouble() - 0.5f) * 2.0f, (float)randGen.NextDouble() * 1.0f - 0.25f, ((float)randGen.NextDouble() - 0.5f) * 2.0f);
                    }
                    p.SizeChange = 0.2f;
                    p.Bounce = 0.0f;
                    p.Position.Y += 1.0f + (float)randGen.NextDouble() - 0.5f;

                }
                else if (block == BlockType.Dirt || block == BlockType.DirtSign || block == BlockType.Grass)
                {
                    p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                }
                else
                {
                    p.Color = Vector4.One * (0.2f + (float)(randGen.NextDouble() * 0.7f));
                    //p.Color = new Vector4(0.35f + (float)((randGen.NextDouble() - 0.5f) * 0.03f), 0.235f + (float)((randGen.NextDouble() - 0.5f) * 0.02f), 0.156f + (float)((randGen.NextDouble() - 0.5f) * 0.015f), 1.0f);
                }
                particleList.Add(p);
            }
        }
Beispiel #8
0
 public void CreateBloodSplatter(Vector3 playerPosition, Color color, float strength)
 {
     for (int i = 0; i < 30; i++)
     {
         Particle p = new Particle();
         p.Color = color.ToVector4();
         if (color == Color.Red)
         {
             p.Color.X += (float)(randGen.NextDouble() * 0.5 - 0.3);
         }
         else
         {
             p.Color.X += (float)(randGen.NextDouble() * 0.5 - 0.3);
             p.Color.Z -= (float)(randGen.NextDouble() * 0.8 - 0.4);
         }
         p.Size = (float)(0.05 + (strength*0.15));
         p.Position = playerPosition;
         p.Position.Y -= (float)randGen.NextDouble();
         p.Velocity = new Vector3((float)randGen.NextDouble() * 4 - 2.0f, (float)randGen.NextDouble() * 2f, (float)randGen.NextDouble() * 4 - 2.0f);
         p.Lifetime = DateTime.Now + TimeSpan.FromSeconds(0.4 + (strength*1.25));
         p.Bounce = 0.01f;
         p.SizeChange = 0.2f - (strength*0.2f);
         if (p.SizeChange < 0.0f)
             p.SizeChange = 0.015f;
         particleList.Add(p);
     }
 }