Particle system class.
Inheritance: Component
Ejemplo n.º 1
0
        public static ParticleSystem2D CreateDinosaurs()
        {
            ParticleSystem2D dinoParticle = new ParticleSystem2D()
            {
                NumParticles = 10,
                EmitRate = 60,
                MinColor = Color.Black,
                MaxColor = Color.Black,
                MinLife = TimeSpan.FromSeconds(2f),
                MaxLife = TimeSpan.FromSeconds(4f),
                LocalVelocity = new Vector2(0.4f, -5f),
                RandomVelocity = new Vector2(3f, 1f),
                MinSize = 10,
                MaxSize = 25,
                MinRotateSpeed = 0.06f,
                MaxRotateSpeed = -0.06f,
                InitialAngleVariation = 100,
                EmitterSize = new Vector2(30),
                Gravity = new Vector2(0, 0.08f),
                EmitterShape = ParticleSystem2D.Shape.FillCircle,
                InterpolationColors = new List<Color>() { Color.Transparent },
            };

            return dinoParticle;
        }
Ejemplo n.º 2
0
        protected override void Initialize()
        {
            base.Initialize();

            var explosionParticles = this.Owner.FindChild("explosionParticles");

            if (explosionParticles != null)
            {
                this.particleSystem = explosionParticles.FindComponent <WaveEngine.Components.Particles.ParticleSystem2D>();
                if (this.particleSystem != null)
                {
                    this.particleSystem.Emit = false;
                }
            }

            var dinosEntity = this.Owner.FindChild("dinos");

            if (dinosEntity != null)
            {
                this.dinos = dinosEntity.FindComponent <WaveEngine.Components.Particles.ParticleSystem2D>();
                if (this.dinos != null)
                {
                    this.dinos.Emit = false;
                }
            }
        }
Ejemplo n.º 3
0
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateDinosaurs()
        {
            WaveEngine.Components.Particles.ParticleSystem2D dinoParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles          = 10,
                EmitRate              = 60,
                MinColor              = Color.Black,
                MaxColor              = Color.Black,
                MinLife               = 2f,
                MaxLife               = 4f,
                LocalVelocity         = new Vector2(0.4f, -5f),
                RandomVelocity        = new Vector2(3f, 1f),
                MinSize               = 10,
                MaxSize               = 25,
                MinRotateSpeed        = 0.06f,
                MaxRotateSpeed        = -0.06f,
                InitialAngleVariation = 100,
                EmitterSize           = new Vector3(30),
                Gravity               = new Vector2(0, 0.08f),
                EmitterShape          = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
                InterpolationColors   = new List <Color>()
                {
                    Color.White, Color.Transparent
                },
            };

            return(dinoParticle);
        }
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateDinosaurs()
        {
            WaveEngine.Components.Particles.ParticleSystem2D dinoParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles = 10,
                EmitRate = 60,
                MinColor = Color.Black,
                MaxColor = Color.Black,
                MinLife = 2f,
                MaxLife = 4f,
                LocalVelocity = new Vector2(0.4f, -5f),
                RandomVelocity = new Vector2(3f, 1f),
                MinSize = 10,
                MaxSize = 25,
                MinRotateSpeed = 0.06f,
                MaxRotateSpeed = -0.06f,
                InitialAngleVariation = 100,
                EmitterSize = new Vector3(30),
                Gravity = new Vector2(0, 0.08f),
                EmitterShape = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
                InterpolationColors = new List<Color>() { Color.White, Color.Transparent },
            };

            return dinoParticle;
        }
Ejemplo n.º 5
0
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateSmokeParticle()
        {
            WaveEngine.Components.Particles.ParticleSystem2D pSystem = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                SortEnabled         = true,
                NumParticles        = 150,
                EmitRate            = 50,
                MinColor            = Color.White,
                MaxColor            = Color.White,
                MinLife             = 2,
                MaxLife             = 4,
                LocalVelocity       = new Vector2(0.2f, 0f),
                RandomVelocity      = new Vector2(0.1f, 0.1f),
                MinSize             = 8,
                MaxSize             = 15,
                EndDeltaScale       = 4f,
                MinRotateSpeed      = -0.01f,
                MaxRotateSpeed      = 0.01f,
                EmitterSize         = new Vector3(10),
                EmitterShape        = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
                InterpolationColors = new List <Color>()
                {
                    Color.White, Color.Transparent
                },
                LinearColorEnabled = true,
                AlphaEnabled       = true,
            };

            return(pSystem);
        }
Ejemplo n.º 6
0
        public static ParticleSystem2D CreateSmokeParticle()
        {
            ParticleSystem2D pSystem = new ParticleSystem2D()
            {
                SortEnabled = true,
                NumParticles = 150,
                EmitRate = 50,
                MinColor = Color.White,
                MaxColor = Color.White,
                MinLife = TimeSpan.FromSeconds(2),
                MaxLife = TimeSpan.FromSeconds(4),
                LocalVelocity = new Vector2(0.2f, 0f),
                RandomVelocity = new Vector2(0.1f, 0.1f),
                MinSize = 8,
                MaxSize = 15,
                EndDeltaScale = 4f,
                MinRotateSpeed = -0.01f,
                MaxRotateSpeed = 0.01f,
                EmitterSize = new Vector3(10),
                EmitterShape = ParticleSystem2D.Shape.FillCircle,
                InterpolationColors = new List<Color>() { Color.White, Color.Transparent },
                LinearColorEnabled = true,
                AlphaEnabled = true,

            };

            return pSystem;
        }
Ejemplo n.º 7
0
        protected override void Initialize()
        {
            base.Initialize();

            this.particleSystem = this.Owner.FindChild("explosionParticles").FindComponent<ParticleSystem2D>();
            this.particleSystem.Emit = false;

            this.dinos = this.Owner.FindChild("dinos").FindComponent<ParticleSystem2D>();
            this.dinos.Emit = false;
        }
Ejemplo n.º 8
0
        protected override void Initialize()
        {
            base.Initialize();

            this.particleSystem      = this.Owner.FindChild("explosionParticles").FindComponent <WaveEngine.Components.Particles.ParticleSystem2D>();
            this.particleSystem.Emit = false;

            this.dinos      = this.Owner.FindChild("dinos").FindComponent <WaveEngine.Components.Particles.ParticleSystem2D>();
            this.dinos.Emit = false;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitEmiterBehavior" /> class.
        /// </summary>
        /// <param name="rabbits">The rabbits.</param>
        public RabbitEmiterBehavior(List<Rabbit> rabbits)
        {
            this.rabbits = rabbits;
            this.deadRabbits = new List<Rabbit>();

            // Explosion
            this.explosion = new Entity("explosion")
                                .AddComponent(new Transform2D())
                                .AddComponent(ParticleFactory.CreateExplosion())
                                .AddComponent(new Material2D(new BasicMaterial2D(Directories.TexturePath + "starParticle.wpk", DefaultLayers.Additive)))
                                .AddComponent(new ParticleSystemRenderer2D("explosion"));  
          
            // Cached
            this.explosionSystem = this.explosion.FindComponent<ParticleSystem2D>();
            this.explosionTransform = this.explosion.FindComponent<Transform2D>();
        }
Ejemplo n.º 10
0
        public static ParticleSystem2D CreateFireParticle()
        {
            ParticleSystem2D fireParticle = new ParticleSystem2D()
            {
                NumParticles = 80,
                EmitRate = 130,
                MinLife = TimeSpan.FromSeconds(0.2f),
                MaxLife = TimeSpan.FromSeconds(1f),
                LocalVelocity = new Vector2(0.2f, -0.2f),
                RandomVelocity = new Vector2(0.4f, 0.4f),
                MinSize = 15,
                MaxSize = 30,
                MinRotateSpeed = 0.1f,
                MaxRotateSpeed = -0.1f,
                EndDeltaScale = 0.0f,
                EmitterSize = new Vector2(10),
                EmitterShape = ParticleSystem2D.Shape.FillCircle
            };

            return fireParticle;
        }
Ejemplo n.º 11
0
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateFireParticle()
        {
            WaveEngine.Components.Particles.ParticleSystem2D fireParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles   = 80,
                EmitRate       = 130,
                MinLife        = 0.2f,
                MaxLife        = 1f,
                LocalVelocity  = new Vector2(0.2f, -0.2f),
                RandomVelocity = new Vector2(0.4f, 0.4f),
                MinSize        = 15,
                MaxSize        = 30,
                MinRotateSpeed = 0.1f,
                MaxRotateSpeed = -0.1f,
                EndDeltaScale  = 0.0f,
                EmitterSize    = new Vector3(10),
                EmitterShape   = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
            };

            return(fireParticle);
        }
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateFireParticle()
        {
            WaveEngine.Components.Particles.ParticleSystem2D fireParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles = 80,
                EmitRate = 130,
                MinLife = 0.2f,
                MaxLife = 1f,
                LocalVelocity = new Vector2(0.2f, -0.2f),
                RandomVelocity = new Vector2(0.4f, 0.4f),
                MinSize = 15,
                MaxSize = 30,
                MinRotateSpeed = 0.1f,
                MaxRotateSpeed = -0.1f,
                EndDeltaScale = 0.0f,
                EmitterSize = new Vector3(10),
                EmitterShape = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
            };

            return fireParticle;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates the explosion particle.
        /// </summary>
        /// <returns>
        /// The explosion Cconfigured Particle System
        /// </returns>
        public static ParticleSystem2D CreateExplosionParticle()
        {
            ParticleSystem2D fireParticle = new ParticleSystem2D()
            {
                NumParticles = 20,
                EmitRate = 20,
                Gravity = new Vector2(0, -0.05f),
                MinLife = TimeSpan.FromSeconds(0.8f),
                MaxLife = TimeSpan.FromSeconds(2f),
                LocalVelocity = new Vector2(0.1f, -0.1f) * 2,
                RandomVelocity = new Vector2(0.2f, 0.2f) * 2,
                MinSize = 80,
                MaxSize = 120,
                MinRotateSpeed = 0.05f,
                MaxRotateSpeed = -0.05f,
                EndDeltaScale = 0.0f,
                EmitterSize = new Vector3(25),
                EmitterShape = ParticleSystem2D.Shape.FillCircle
            };

            return fireParticle;
        }
Ejemplo n.º 14
0
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateExplosion()
        {
            WaveEngine.Components.Particles.ParticleSystem2D explosionParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles   = 200,
                EmitRate       = 1500,
                MinLife        = 1f,
                MaxLife        = 3f,
                LocalVelocity  = new Vector2(0.4f, -2f),
                RandomVelocity = new Vector2(2f, 1.5f),
                MinSize        = 15,
                MaxSize        = 40,
                MinRotateSpeed = 0.03f,
                MaxRotateSpeed = -0.03f,
                EndDeltaScale  = 0f,
                EmitterSize    = new Vector3(30),
                Gravity        = new Vector2(0, 0.03f),
                EmitterShape   = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
            };

            return(explosionParticle);
        }
Ejemplo n.º 15
0
        public static ParticleSystem2D CreateExplosion()
        {
            ParticleSystem2D explosionParticle = new ParticleSystem2D()
            {
                NumParticles = 200,
                EmitRate = 1500,
                MinLife = TimeSpan.FromSeconds(1f),
                MaxLife = TimeSpan.FromSeconds(3f),
                LocalVelocity = new Vector2(0.4f, -2f),
                RandomVelocity = new Vector2(2f, 1.5f),
                MinSize = 15,
                MaxSize = 40,
                MinRotateSpeed = 0.03f,
                MaxRotateSpeed = -0.03f,
                EndDeltaScale = 0f,
                EmitterSize = new Vector2(30),
                Gravity = new Vector2(0, 0.03f),
                EmitterShape = ParticleSystem2D.Shape.FillCircle,
            };

            return explosionParticle;
        }
        public static WaveEngine.Components.Particles.ParticleSystem2D CreateExplosion()
        {
            WaveEngine.Components.Particles.ParticleSystem2D explosionParticle = new WaveEngine.Components.Particles.ParticleSystem2D()
            {
                NumParticles = 200,
                EmitRate = 1500,
                MinLife = 1f,
                MaxLife = 3f,
                LocalVelocity = new Vector2(0.4f, -2f),
                RandomVelocity = new Vector2(2f, 1.5f),
                MinSize = 15,
                MaxSize = 40,
                MinRotateSpeed = 0.03f,
                MaxRotateSpeed = -0.03f,
                EndDeltaScale = 0f,
                EmitterSize = new Vector3(30),
                Gravity = new Vector2(0, 0.03f),
                EmitterShape = WaveEngine.Components.Particles.ParticleSystem2D.Shape.FillCircle,
            };

            return explosionParticle;
        }
Ejemplo n.º 17
0
        protected override void Initialize()
        {
            base.Initialize();

            var explosionParticles = this.Owner.FindChild("explosionParticles");
            if (explosionParticles != null)
            {
                this.particleSystem = explosionParticles.FindComponent<WaveEngine.Components.Particles.ParticleSystem2D>();
                if (this.particleSystem != null)
                {
                    this.particleSystem.Emit = false;
                }
            }

            var dinosEntity = this.Owner.FindChild("dinos");
            if (dinosEntity != null)
            {
                this.dinos = dinosEntity.FindComponent<WaveEngine.Components.Particles.ParticleSystem2D>();
                if (this.dinos != null)
                {
                    this.dinos.Emit = false;
                }
            }
        }
        /// <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++)
            {
                double life = (this.settings.EmitRate > 0) ? -1 : TimeSpan.FromSeconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalSeconds;

                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life = life
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];

            // Initializes the coordinate textures of the vertices
            for (int i = 0; i < this.numVertices; i++)
            {
                this.vertices[i++].TexCoord = texcoord1;
                this.vertices[i++].TexCoord = texcoord2;
                this.vertices[i++].TexCoord = texcoord3;
                this.vertices[i].TexCoord = texcoord4;
            }

            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)
                {
                    DisableBatch = true
                };
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Squid" /> class.
        /// </summary>
        /// <param name="positionY">The position Y.</param>
        public Squid(float positionY)
        {
            this.initialPosY = positionY;
            this.gamePlayPosY = WaveServices.ViewportManager.BottomEdge + 50;

            this.entity = new Entity("SquidEntity")
                            .AddComponent(new Transform2D()
                            {
                                Origin = new Vector2(0.5f, 0f),
                                X = WaveServices.ViewportManager.VirtualWidth / 2,
                                Y = this.gamePlayPosY,
                                DrawOrder = 0.3f,
                            })
                            .AddComponent(new AnimationUI())
                            .AddComponent(new SquidBehavior())
                            .AddComponent(new Sprite(Directories.TexturePath + "squidSpriteSheet.wpk"))
                            .AddComponent(Animation2D.Create<TexturePackerGenericXml>(Directories.TexturePath + "squidSpriteSheet.xml")
                                                .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 30, FramesPerSecond = 30 }))
                            .AddComponent(new PerPixelCollider(Directories.TexturePath + "squidCollider.wpk", 0.5f))
                            .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha));

            // Cached
            this.transform = this.entity.FindComponent<Transform2D>();
            this.animation2D = this.entity.FindComponent<Animation2D>();
            this.direction = -Vector2.UnitY;
            this.animation = this.entity.FindComponent<AnimationUI>();

            // Bubble
            this.entity.AddChild(new Entity("bubblesParticle")
                .AddComponent(new Transform2D()
                {
                    LocalY = 210,
                })
                .AddComponent(ParticleFactory.CreateBubbleParticles())
                .AddComponent(
                    new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk",
                        DefaultLayers.Additive)))
                .AddComponent(new ParticleSystemRenderer2D("bubblesParticle")));

            // Cached
            this.particleSystem = this.entity.FindChild("bubblesParticle").FindComponent<ParticleSystem2D>();

            // Animations
            this.appearAnim = new SingleAnimation(gamePlayPosY, this.initialPosY, TimeSpan.FromSeconds(1.5f), EasingFunctions.Cubic);            
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.rabbitParticles = this.Owner.FindChild("rabbitParticles").FindComponent<ParticleSystem2D>();            
        }
Ejemplo n.º 21
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.bubleParticles = this.Owner.FindChild("BubbleParticles").FindComponent<ParticleSystem2D>();
            this.blockBuilderBehavior = this.EntityManager.Find("BlockBuilder").FindComponent<BlockBuilderBehavior>();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

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

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

            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];

            // Sets the time passed between 2 particles creation.
            this.emitLapse = (this.settings.EmitRate > 0) ? 1000 / this.settings.EmitRate : 0;

            // 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);
            }

            this.indexBuffer = new IndexBuffer(indices);
            this.GraphicsDevice.BindIndexBuffer(this.indexBuffer);

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                double life = (this.settings.EmitRate > 0) ? -1 : TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds;

                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life = life
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];

            // Initializes the coordinate textures of the vertices
            for (int i = 0; i < this.numVertices; i++)
            {
                this.vertices[i++].TexCoord = TEXCOORD1;
                this.vertices[i++].TexCoord = TEXCOORD2;
                this.vertices[i++].TexCoord = TEXCOORD3;
                this.vertices[i].TexCoord = TEXCOORD4;
            }

            this.vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);
            this.vertexBuffer.SetData(this.vertices, this.numVertices);
            this.GraphicsDevice.BindVertexBuffer(this.vertexBuffer);
        }