예제 #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 Vector3(30),
                Gravity               = new Vector2(0, 0.08f),
                EmitterShape          = ParticleSystem2D.Shape.FillCircle,
                InterpolationColors   = new List <Color>()
                {
                    Color.White, Color.Transparent
                },
            };

            return(dinoParticle);
        }
예제 #2
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.bubleParticles       = this.Owner.FindChild("BubbleParticles").FindComponent <ParticleSystem2D>();
            this.blockBuilderBehavior = this.EntityManager.Find("BlockBuilder").FindComponent <BlockBuilderBehavior>();
        }
예제 #3
0
 protected override void ResolveDependencies()
 {
     base.ResolveDependencies();
     wo        = Owner.Parent.FindComponent <WorldObject>();
     particles = Owner.FindComponent <ParticleSystem2D>();
     mat       = (Owner.FindComponent <MaterialsMap>().DefaultMaterial as StandardMaterial);
 }
예제 #4
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);
        }
예제 #5
0
        public override void Initialize()
        {
            particles = new ParticleSystem2D(ID + "ParticleSystem", particleSystemFilepath);
            particles.SetPosition(position);
            particles.OnComplete += new OnFinishedEvent(Finished);

            base.Initialize();
        }
예제 #6
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;
        }
예제 #7
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);
        }
예제 #8
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>();
        }
        /// <summary>
        /// Resolve dependencies
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.childParticleSystem = this.Owner.FindChild(GameConstants.ENTITYCHILDPARTICLES).FindComponent <ParticleSystem2D>();

            this.timeToEmit   = TimeSpan.FromSeconds(0.5);
            this.timeToRemove = TimeSpan.FromSeconds(5);

            var scene = this.Owner.Scene as GameScene;

            if (scene != null)
            {
                this.scene = scene;
                this.score = scene.Score;
            }

            // TODO: Workaround, remove when fixed (do not store EndDeltaScale in WaveEditor)
            this.childParticleSystem.EndDeltaScale = 1.0f;
        }
예제 #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 Vector3(10),
                EmitterShape   = ParticleSystem2D.Shape.FillCircle
            };

            return(fireParticle);
        }
예제 #11
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);
        }
예제 #12
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 Vector3(30),
                Gravity        = new Vector2(0, 0.03f),
                EmitterShape   = ParticleSystem2D.Shape.FillCircle,
            };

            return(explosionParticle);
        }
예제 #13
0
        /// <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];

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

            IndexBuffer indexBuffer = new IndexBuffer(indices);

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

            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);
        }
예제 #14
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>();
        }