예제 #1
0
        // --------------------- BASE METHODS ------------------

        /// <summary>
        /// Initialization of the particle-system
        /// </summary>
        public override void Awake()
        {
            _smokePlumeParticles = new ParticleSystem3D {
                Settings = new Settings {
                    TextureName       = "vault_smoke",
                    MaxParticles      = 1500,
                    ParticlesPerRound = 1,
                    Duration          = 3.0f,
                    // Create a wind effect by tilting the gravity vector sideways.
                    Gravity     = new Vector3(-5, -2.5f, 0),
                    EndVelocity = 0.75f,

                    MinHorizontalVelocity = 0,
                    MaxHorizontalVelocity = 5,

                    MinVerticalVelocity = 2.5f,
                    MaxVerticalVelocity = 15,

                    MinColor = new Color(0, 0, 0, 255),
                    MaxColor = new Color(128, 128, 128, 128),

                    MinRotateSpeed = -1,
                    MaxRotateSpeed = 1,

                    MinStartSize = 1,
                    MaxStartSize = 2,

                    MinEndSize = 2,
                    MaxEndSize = 5
                }
            };

            _smokePlumeParticles.Awake();
            ParticleRendering.AddInstance(_smokePlumeParticles, true);
        }
예제 #2
0
        /// <summary>
        /// A fog particle system
        /// </summary>
        /// <returns></returns>
        public static ParticleSystem3D CreateFogParticleSystem3D()
        {
            ParticleSystem3D pSystem = new ParticleSystem3D()
            {
                NumParticles        = 100,
                MinColor            = Color.Black,
                MaxColor            = Color.Black,
                MinLife             = TimeSpan.FromSeconds(3),
                MaxLife             = TimeSpan.FromSeconds(4),
                LocalVelocity       = new Vector3(0.0f, 3.0f, 0.0f),
                RandomVelocity      = new Vector3(0.2f, 1.0f, 0.2f),
                MinSize             = 40,
                MaxSize             = 70,
                EndDeltaScale       = 3f,
                EmitterSize         = new Vector2(500),
                EmitterShape        = ParticleSystem3D.Shape.FillCircle,
                InterpolationColors = new List <Color>()
                {
                    new Color(226, 207, 190), new Color(200, 153, 109), Color.Transparent
                },
                LinearColorEnabled = true,
                AlphaEnabled       = true,
            };

            return(pSystem);
        }
예제 #3
0
        /// <summary>
        /// A sparks particle system
        /// </summary>
        /// <returns></returns>
        public static ParticleSystem3D CreateSparksParticleSystem3D()
        {
            ParticleSystem3D pSystem = new ParticleSystem3D()
            {
                NumParticles        = 800,
                MinColor            = Color.White,
                MaxColor            = Color.Yellow,
                LocalVelocity       = new Vector3(10f, 10f, 10f),
                RandomVelocity      = new Vector3(5f, 10f, 5f),
                MinLife             = TimeSpan.FromSeconds(3),
                MaxLife             = TimeSpan.FromSeconds(9),
                InitialAngle        = 0.5f,
                MinRotateSpeed      = 0.01f,
                MaxRotateSpeed      = 0.05f,
                MinSize             = 20,
                MaxSize             = 80,
                EmitterSize         = new Vector2(50, 0),
                Gravity             = new Vector3(0f, -0.3f, 0f),
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.Gray
                },
                LinearColorEnabled = true,
                AlphaEnabled       = false,
            };

            return(pSystem);
        }
예제 #4
0
        /// <summary>
        /// A fire particle system
        /// </summary>
        /// <returns></returns>
        public static ParticleSystem3D CreateFireParticleSystem3D()
        {
            ParticleSystem3D pSystem = new ParticleSystem3D()
            {
                NumParticles        = 500,
                MinColor            = Color.Black,
                MaxColor            = Color.Black,
                MinLife             = TimeSpan.FromSeconds(3),
                MaxLife             = TimeSpan.FromSeconds(5),
                LocalVelocity       = new Vector3(0.0f, 3.0f, 0.0f),
                RandomVelocity      = new Vector3(0.2f, 1.0f, 0.2f),
                MinSize             = 40,
                MaxSize             = 70,
                EndDeltaScale       = 3f,
                EmitterSize         = new Vector2(500),
                EmitterShape        = ParticleSystem3D.Shape.Circle,
                InterpolationColors = new List <Color>()
                {
                    Color.Red, Color.Orange
                },
                LinearColorEnabled = true,
                AlphaEnabled       = true,
            };

            return(pSystem);
        }
예제 #5
0
        /// <summary>
        /// A vapor particle system
        /// </summary>
        /// <returns></returns>
        public static ParticleSystem3D CreateVaporParticleSystem3D()
        {
            ParticleSystem3D pSystem = new ParticleSystem3D()
            {
                NumParticles        = 100,
                MinColor            = Color.Black,
                MaxColor            = Color.Black,
                MinLife             = TimeSpan.FromSeconds(2),
                MaxLife             = TimeSpan.FromSeconds(4),
                LocalVelocity       = new Vector3(0.0f, 3.0f, 0.0f),
                RandomVelocity      = new Vector3(10f, 10f, 10f),
                MinSize             = 40,
                MaxSize             = 50,
                EndDeltaScale       = 10f,
                EmitterSize         = new Vector2(100),
                EmitterShape        = ParticleSystem3D.Shape.Rectangle,
                InterpolationColors = new List <Color>()
                {
                    Color.White
                },
                LinearColorEnabled = true,
                AlphaEnabled       = true,
            };

            return(pSystem);
        }
예제 #6
0
        /// <summary>
        /// A rain particle system
        /// </summary>
        /// <returns></returns>
        public static ParticleSystem3D CreateRainParticleSystem3D()
        {
            ParticleSystem3D pSystem = new ParticleSystem3D()
            {
                NumParticles        = 2000,
                MinColor            = Color.White,
                MaxColor            = Color.Gray,
                LocalVelocity       = new Vector3(0f, 3f, 0f),
                RandomVelocity      = new Vector3(1f, 1f, 1f),
                MinLife             = TimeSpan.FromSeconds(1.5f),
                MaxLife             = TimeSpan.FromSeconds(3),
                InitialAngle        = 0.5f,
                MinRotateSpeed      = 0.01f,
                MaxRotateSpeed      = 0.05f,
                MinSize             = 1,
                MaxSize             = 3,
                EmitterSize         = new Vector2(1200, 200),
                EmitterShape        = ParticleSystem3D.Shape.FillRectangle,
                Gravity             = new Vector3(0, -1f, 0f),
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.Gray
                },
                LinearColorEnabled = true,
                AlphaEnabled       = false,
                CollisionBehavior  = ParticleSystem3D.ParticleCollisionBehavior.Bounce,
                CollisionType      = ParticleSystem3D.ParticleCollisionFlags.MinY,
                CollisionMinY      = 0,
                CollisionSpread    = new Vector3(15),
                Bounciness         = 0.4f
            };

            return(pSystem);
        }
예제 #7
0
        // --------------------- BASE METHODS ------------------

        /// <summary>
        /// Initialization of the particle-system
        /// </summary>
        public override void Awake()
        {
            _cashDropParticles = new ParticleSystem3D {
                Settings = new Settings {
                    TextureName       = "base_cash_drop",
                    MaxParticles      = 2,
                    ParticlesPerRound = 1,
                    Duration          = 5.0f,
                    // Create a wind effect by tilting the gravity vector sideways.
                    Gravity     = new Vector3(-0.5f, -0.2f, 0),
                    EndVelocity = 0.75f,

                    MinHorizontalVelocity = 0,
                    MaxHorizontalVelocity = 1.0f,

                    MinVerticalVelocity = 2.5f,
                    MaxVerticalVelocity = 3.0f,

                    MinRotateSpeed = 0,
                    MaxRotateSpeed = 0,

                    MinStartSize = 1,
                    MaxStartSize = 3,

                    MinEndSize = 2,
                    MaxEndSize = 5
                }
            };


            _cashDropParticles.Awake();
            ParticleRendering.AddInstance(_cashDropParticles);
        }
예제 #8
0
        // --------------------- BASE METHODS ------------------

        /// <summary>
        /// Initialization of the particle-system
        /// </summary>
        public override void Awake()
        {
            _cashParticles = new ParticleSystem3D {
                Settings = new Settings {
                    TextureName  = "cash",
                    MaxParticles = 1800,
                    Duration     = 8.0f,
                    // Create a wind effect by tilting the gravity vector sideways.
                    Gravity     = new Vector3(-1.0f, -5.5f, 0),
                    EndVelocity = 0.75f,

                    MinHorizontalVelocity = 0,
                    MaxHorizontalVelocity = 5,

                    MinVerticalVelocity = 2.5f,
                    MaxVerticalVelocity = 10.0f,

                    MinRotateSpeed = -1,
                    MaxRotateSpeed = 1,

                    MinStartSize = 1.0f,
                    MaxStartSize = 1.01f,

                    MinEndSize = 1.02f,
                    MaxEndSize = 1.03f
                }
            };

            _cashParticles.Awake();
            ParticleRendering.AddInstance(_cashParticles);
        }
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

            if (this.mesh != null)
            {
                if (this.mesh.IndexBuffer != null)
                {
                    this.GraphicsDevice.DestroyIndexBuffer(this.mesh.IndexBuffer);
                }

                if (this.mesh.VertexBuffer != null)
                {
                    this.GraphicsDevice.DestroyVertexBuffer(this.mesh.VertexBuffer);
                }

                this.mesh = null;
            }

            this.settings      = this.System;
            this.numParticles  = this.System.NumParticles;
            this.numPrimitives = this.numParticles * 2;
            this.numVertices   = this.numParticles * 4;
            this.numIndices    = this.numParticles * 6;
            this.particles     = new Particle[this.numParticles];

            // Create Indexbuffer
            ushort[] indices = new ushort[this.numIndices];

            for (int i = 0; i < this.numParticles; i++)
            {
                indices[(i * 6) + 0] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 1] = (ushort)((i * 4) + 2);
                indices[(i * 6) + 2] = (ushort)((i * 4) + 1);

                indices[(i * 6) + 3] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 4] = (ushort)((i * 4) + 3);
                indices[(i * 6) + 5] = (ushort)((i * 4) + 2);
            }

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life  = TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];
            DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);

            vertexBuffer.SetData(this.vertices, this.numVertices);

            this.mesh = new Mesh(0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
예제 #10
0
        /// <summary>
        /// Initialize a new model for hardware-instanciation
        /// </summary>
        /// <param name="particleType">Type of the particles to store uniquely</param>
        /// <param name="particleSystem">Particle-system</param>
        public static void Initialize(ParticleType3D particleType, ParticleSystem3D particleSystem)
        {
            // Startup the particle-systems properly
            particleSystem.Awake();
            particleSystem.Start();

            ParticleSystems3D[particleType] = new ParticleInstance(particleSystem);
        }
예제 #11
0
        /// <summary>
        /// Add a particle-system to render
        /// </summary>
        /// <param name="particleSystem">New particle-system</param>
        /// <param name="useForDepth">Used for depth rendering</param>
        public static void AddInstance(ParticleSystem3D particleSystem, bool useForDepth = false)
        {
            ParticleSystems.Add(particleSystem);

            if (useForDepth)
            {
                DepthParticleSystems.Add(particleSystem);
            }
        }
예제 #12
0
 /// <summary>
 /// Remove a particle-system to not be drawn anymore
 /// </summary>
 /// <param name="particleSystem">Particle-system to remove</param>
 public static void RemoveInstance(ParticleSystem3D particleSystem)
 {
     ParticleSystems.Remove(particleSystem);
     DepthParticleSystems.Remove(particleSystem);
 }
예제 #13
0
 /// <summary>
 /// Instanciate a new particle-system
 /// </summary>
 /// <param name="particleSystem">System which is used for rendering</param>
 public ParticleInstance(ParticleSystem3D particleSystem)
 {
     ParticleSystem = particleSystem;
 }
예제 #14
0
        private static void InitializeParticleSystems()
        {
            foreach (Powerup powerup in powerupcomponents)
            {
                Color minColor = powerup.powerupColor;
                minColor.A = 0;
                Color maxColor = powerup.powerupColor;
                maxColor.A = 64;

                ParticleSystem3D rayParticles = new ParticleSystem3D {
                    Settings = new Settings {
                        TextureName       = "powerup_ray",
                        MaxParticles      = 10000,
                        ParticlesPerRound = 10,
                        Duration          = 1.0f,
                        Gravity           = new Vector3(0, 0, 0),
                        EndVelocity       = 0.75f,

                        MinHorizontalVelocity = 0,
                        MaxHorizontalVelocity = 0,

                        MinVerticalVelocity = 0.5f,
                        MaxVerticalVelocity = 1.0f,

                        MinColor = minColor,
                        MaxColor = maxColor,

                        MinRotateSpeed = 0,
                        MaxRotateSpeed = 0,

                        MinStartSize = 0.1f,
                        MaxStartSize = 0.2f,

                        MinEndSize = 0.2f,
                        MaxEndSize = 0.5f
                    }
                };

                maxColor.A = 128;
                ParticleSystem3D starParticles = new ParticleSystem3D {
                    Settings = new Settings {
                        TextureName       = "powerup_star",
                        MaxParticles      = 50,
                        ParticlesPerRound = 1,
                        Duration          = 1.0f,

                        Gravity     = new Vector3(0, 0, 0),
                        EndVelocity = 0.75f,

                        MinHorizontalVelocity = 0,
                        MaxHorizontalVelocity = 0,

                        MinVerticalVelocity = 0.1f,
                        MaxVerticalVelocity = 0.5f,

                        MinColor = minColor,
                        MaxColor = maxColor,

                        MinRotateSpeed = 0,
                        MaxRotateSpeed = 0,

                        MinStartSize = 0.1f,
                        MaxStartSize = 0.2f,

                        MinEndSize = 0.2f,
                        MaxEndSize = 0.5f
                    }
                };

                ParticleRendering.Initialize(powerup.ParticleRay, rayParticles);
                ParticleRendering.Initialize(powerup.ParticleStar, starParticles);
            }
        }
예제 #15
0
        /// <summary>
        /// Creates a new explosion decorator
        /// </summary>
        /// <param name="name">The entity name</param>
        /// <param name="frame">The explosion frame </param>
        public ExplosionDecorator(string name, int frame)
        {
            this.particleSystems = new List <ParticleSystem3D>();

            this.entity = new Entity(name)
                          .AddComponent(this.cachedTransform = new Transform3D())
            ;

            ParticleSystem3D particleSystem;
            var emitter1 = new Entity()
                           .AddComponent(new Transform3D())
                           .AddComponent(emitter        = new Sound3DEmitter())
                           .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles        = 25,
                EmitRate            = 300000,
                MinLife             = TimeSpan.FromSeconds(1),
                MaxLife             = TimeSpan.FromSeconds(1.5),
                LocalVelocity       = Vector3.Zero,
                RandomVelocity      = Vector3.One * 0.7f,
                MinSize             = 20,
                MaxSize             = 25,
                MaxRotateSpeed      = 0.025f,
                MinRotateSpeed      = -0.055f,
                InitialAngle        = MathHelper.TwoPi,
                EndDeltaScale       = 2f,
                EmitterSize         = new Vector2(4),
                EmitterShape        = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.White, Color.Black
                },
                LinearColorEnabled = true,
                Gravity            = Vector3.Zero,
                Emit = false
            })
                           .AddComponent(new ParticleSystemRenderer3D())
                           .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_1.png", DefaultLayers.Additive)
            {
                VertexColorEnabled = true
            }))
            ;

            this.particleSystems.Add(particleSystem);


            var emitter2 = new Entity()
                           .AddComponent(new Transform3D())
                           .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles        = 4,
                EmitRate            = 300000,
                MinLife             = TimeSpan.FromSeconds(0.2),
                MaxLife             = TimeSpan.FromSeconds(0.3),
                LocalVelocity       = Vector3.Zero,
                RandomVelocity      = Vector3.One * 0.01f,
                MinSize             = 30,
                MaxSize             = 40,
                InitialAngle        = MathHelper.TwoPi,
                MaxRotateSpeed      = 0.1f,
                MinRotateSpeed      = -0.1f,
                EndDeltaScale       = 0.3f,
                EmitterSize         = new Vector2(1),
                EmitterShape        = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.Black
                },
                LinearColorEnabled = true,
                Gravity            = Vector3.Zero,
                Emit = false
            })
                           .AddComponent(new ParticleSystemRenderer3D())
                           .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_3.png", DefaultLayers.Additive)
            {
                VertexColorEnabled = true
            }))
            ;

            this.particleSystems.Add(particleSystem);

            var emitter3 = new Entity()
                           .AddComponent(new Transform3D())
                           .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles        = 60,
                EmitRate            = 300000,
                MinLife             = TimeSpan.FromSeconds(2),
                MaxLife             = TimeSpan.FromSeconds(2.4),
                LocalVelocity       = Vector3.Zero,
                RandomVelocity      = Vector3.One * 1f,
                MinSize             = 0.7f,
                MaxSize             = 0.7f,
                InitialAngle        = MathHelper.TwoPi,
                Gravity             = Vector3.Zero,
                EndDeltaScale       = 1,
                EmitterSize         = new Vector2(1),
                EmitterShape        = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.Black
                },
                LinearColorEnabled = true,
                Emit = false
            })
                           .AddComponent(new ParticleSystemRenderer3D())
                           .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Blaster.png", DefaultLayers.Additive)
            {
                VertexColorEnabled = true
            }))
            ;

            this.particleSystems.Add(particleSystem);

            var emitter4 = new Entity()
                           .AddComponent(new Transform3D())
                           .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles        = 15,
                EmitRate            = 300000,
                MinLife             = TimeSpan.FromSeconds(1.5),
                MaxLife             = TimeSpan.FromSeconds(4),
                LocalVelocity       = Vector3.Zero,
                RandomVelocity      = Vector3.One * 0.2f,
                MinSize             = 15,
                MaxSize             = 20,
                MaxRotateSpeed      = 0.015f,
                MinRotateSpeed      = -0.015f,
                InitialAngle        = MathHelper.TwoPi,
                EndDeltaScale       = 2f,
                EmitterSize         = new Vector2(4),
                EmitterShape        = ParticleSystem3D.Shape.FillRectangle,
                AlphaEnabled        = true,
                InterpolationColors = new List <Color>()
                {
                    Color.White * 0.5f, Color.Black
                },

                LinearColorEnabled = true,

                Gravity = Vector3.Zero,
                Emit    = false
            })
                           .AddComponent(new ParticleSystemRenderer3D())
                           .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_5.png", DefaultLayers.Alpha)
            {
                VertexColorEnabled = true
            }))
            ;

            this.particleSystems.Add(particleSystem);


            Entity shockwave = new Entity("shockwave")
                               .AddComponent(new Transform3D()
            {
                Rotation = new Vector3(0.3f, -0.2f, -0.4f)
            })
                               .AddComponent(new Model("Content/Models/Plane.FBX"))
                               .AddComponent(new ModelRenderer())
                               .AddComponent(this.shockwave = new ShockwaveBehavior())
                               .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_4.png", DefaultLayers.Additive)))
            ;


            this.entity.AddChild(emitter1);
            this.entity.AddChild(emitter2);
            this.entity.AddChild(emitter3);
            this.entity.AddChild(emitter4);
            this.entity.AddChild(shockwave);

            this.entity.EntityInitialized += (s, e) =>
            {
                var screenplay = this.entity.Scene.EntityManager.Find("ScreenplayManager").FindComponent <ScreenplayManager>();
                screenplay.FrameEvent(frame, this.BayExplosion);
            };
        }