public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name      = ComputeNewName(parent, "Empty particle system");
            var component = new ParticleSystemComponent();

            return(CreateEntityWithComponent(name, component));
        }
Ejemplo n.º 2
0
 public override void Cancel()
 {
     ExplosionParticle?.ParticleSystem?.Dispose();
     ExplosionParticle = null;
     TrailParticle?.ParticleSystem?.Dispose();
     TrailParticle = null;
 }
Ejemplo n.º 3
0
        public override void Pracuj()
        {
            if (Ruch != Rodzaj_Ruchu.RuchZaden || !Zniszczony)
            {
                Pozycja   += Normalna * V;
                V         += A;
                Odleglosc -= V;
            }

            if (!Zniszczony)
            {
                foreach (Obiekt temp in GlobalAcc.ListaKolizji)
                {
                    if (Kolizja(temp))
                    {
                        Zniszczony = true;
                        temp.ReakcjaKolizja(Sila, Pozycja);

                        Vector2 dif           = Pozycja - temp.Pozycja;
                        float   obrot_wybuchu = MathHelper.PiOver2 + (float)Math.Atan2(dif.Y, dif.X);

                        Color koncowy = KolorLaseru;
                        koncowy.A = 0;

                        ParticleSystemComponent PSC = new ParticleSystemComponent(
                            true, true, new ParticleCirle((int)Pozycja.X, (int)Pozycja.Y, 2, 3, 2, 3, KolorLaseru, KolorLaseru, koncowy, koncowy, 0, 0, 10, 10,
                                                          0f, MathHelper.TwoPi, 6, 6, 1, Rodzaj_Ruchu.RuchPrzyspieszony, 360));

                        ParticleSystem.dodaj(PSC);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void ReakcjaKolizja(float sila, Vector2 gdzie)
        {
            if (Zniszczony)
            {
                return;
            }
            if (AktTarcza > 0)
            {
                AktTarcza -= sila;
                sila       = 0f;

                float Alpha  = (AktTarcza / MaxTarcza) * 255;
                Color start1 = new Color(100, 255, 255, (int)Alpha);
                Color koniec = new Color(100, 255, 255, 0);

                float   odl = Vector2.Distance(gdzie, Pozycja);
                Vector2 dif = gdzie - Pozycja;
                float   obr = MathHelper.PiOver2 + (float)Math.Atan2(dif.Y, dif.X);


                ParticleCirle Tarcza = new ParticleCirle((int)(Pozycja.X + Normalna.X * V), (int)(Pozycja.Y + Normalna.Y * V), 2, 4, 2, 4, start1, start1, koniec, Color.Transparent,
                                                         MaxR / 2 + 15f, MaxR / 2 + 15f, MaxR / 2 + 10f, MaxR / 2 + 10f, -MathHelper.PiOver4 + obr, MathHelper.PiOver4 + obr, 12, 15, 1, Rodzaj_Ruchu.RuchZaden, 120);
                Tarcza.Przyczep(this);     //tarcza podąża za statkiem

                ParticleSystemComponent PSC = new ParticleSystemComponent(true, true, Tarcza);
                ParticleSystem.dodaj(PSC);

                if (AktTarcza < 0f)
                {
                    sila      = -AktTarcza;
                    AktTarcza = 0f;
                }
            }
            if (sila > 0f)
            {
                AktKadlub -= sila;

                if (AktKadlub < 0f)
                {
                    Random rand = new Random();
                    Zniszczony = true;
                    SpriteAnimated[] Wybuchy = { new SpriteAnimated((int)Pozycja.X, (int)Pozycja.Y, Grafika.Eksplozja3, 25) };
                    foreach (SpriteAnimated X in Wybuchy)
                    {
                        GlobalAcc.ListaAnimacji1.Add(X);
                    }
                    GlobalAcc.StatekGracza.IloscPkt += Punkty;
                    if (GlobalAcc.StatekGracza.DoublePoints.active)
                    {
                        GlobalAcc.StatekGracza.IloscPkt += Punkty;
                    }
                }
            }
        }
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name = ComputeNewName(parent, "Simple particle system");

            var component = new ParticleSystemComponent();
            var emitter   = new ParticleEmitter {
                ParticleLifetime = new Vector2(1, 2)
            };

            // 100 Particles per second
            var spawner = new SpawnerPerSecond();

            emitter.Spawners.Add(spawner);

            // Size
            var randSize = new InitialSizeSeed {
                RandomSize = new Vector2(0.05f, 0.1f)
            };

            emitter.Initializers.Add(randSize);

            // Position
            emitter.Initializers.Add(new InitialPositionSeed());

            // Velocity
            var randVel = new InitialVelocitySeed
            {
                VelocityMin = new Vector3(-0.5f, 1f, -0.5f),
                VelocityMax = new Vector3(0.5f, 3, 0.5f)
            };

            emitter.Initializers.Add(randVel);

            // Gravity
            var gravity = new UpdaterForceField
            {
                EnergyConservation = 1f,
                FieldShape         = null
            };

            gravity.FieldFalloff.StrengthInside = gravity.FieldFalloff.StrengthOutside = 1f;
            gravity.ForceFixed    = new Vector3(0, -9.81f, 0);
            gravity.ForceDirected = gravity.ForceRepulsive = gravity.ForceVortex = 0f;
            emitter.Updaters.Add(gravity);

            component.ParticleSystem.Emitters.Add(emitter);

            return(CreateEntityWithComponent(name, component));
        }
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name = ComputeNewName(parent, "Smoke particle system");

            var component = new ParticleSystemComponent();
            var emitter   = new ParticleEmitter {
                ParticleLifetime = new Vector2(1, 2)
            };


            // 20 Particle per second
            var spawner = new SpawnerPerSecond {
                SpawnCount = 20
            };

            emitter.Spawners.Add(spawner);

            // Size
            var randSize = new InitialSizeSeed {
                RandomSize = new Vector2(0.35f, 0.55f)
            };

            emitter.Initializers.Add(randSize);

            // Position
            var randPos = new InitialPositionSeed
            {
                PositionMin = new Vector3(-0.2f, 0, -0.2f),
                PositionMax = new Vector3(0.2f, 0, 0.2f)
            };

            emitter.Initializers.Add(randPos);

            // Velocity
            var randVel = new InitialVelocitySeed
            {
                VelocityMin = new Vector3(-0.5f, 1f, -0.5f),
                VelocityMax = new Vector3(0.5f, 3, 0.5f)
            };

            emitter.Initializers.Add(randVel);

            component.ParticleSystem.Emitters.Add(emitter);

            return(CreateEntityWithComponent(name, component));
        }
Ejemplo n.º 7
0
        public Player(int playerIndex)
        {
            PlayerIndex = playerIndex;

            Attributes          = new PlayerAttributes();
            MovementController  = new PlayerMovementController();
            ShotController      = new PlayerShotController();
            CollisionController = new PlayerCollisionController();
            RenderComponent     = new RenderTextureComponent(Resource.Player, PLAYER_SIZE, PLAYER_SIZE)
                                  .SetColorFilter(PlayerColor);
            ParticleSystemComponent = new ParticleSystemComponent(new PlayerParticleEmitter(this));
            Collider = new CircleCollider(COLLIDER_SIZE / 2.2f);

            AddComponent(Attributes);
            AddComponent(MovementController);
            AddComponent(ShotController);
            AddComponent(CollisionController);
            AddComponent(RenderComponent);
            AddComponent(ParticleSystemComponent);
            AddComponent(Collider);

            //AddComponent(new PlayerTrail());
        }
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name = ComputeNewName(parent, "Ribbon particle system");

            var component = new ParticleSystemComponent();
            var emitter   = new ParticleEmitter {
                ParticleLifetime = new Vector2(2, 2)
            };


            // 30 Particles per second
            var spawner = new SpawnerPerSecond {
                SpawnCount = 30
            };

            emitter.Spawners.Add(spawner);

            // Ribbon
            var ribbonShape = new ShapeBuilderRibbon
            {
                SmoothingPolicy         = SmoothingPolicy.Best,
                Segments                = 15,
                TextureCoordinatePolicy = TextureCoordinatePolicy.Stretched,
                TexCoordsFactor         = 1f
            };

            emitter.ShapeBuilder = ribbonShape;

            // Velocity
            var randVel = new InitialVelocitySeed
            {
                VelocityMin = new Vector3(-0.15f, 3f, -0.15f),
                VelocityMax = new Vector3(0.15f, 3, 0.15f)
            };

            emitter.Initializers.Add(randVel);

            // Spawn Order
            var initialOrder = new InitialSpawnOrder();

            emitter.Initializers.Add(initialOrder);

            // Size by Lifetime
            var sizeCurve = new ComputeAnimationCurveFloat();
            var key0      = new AnimationKeyFrame <float>
            {
                Key   = 0,
                Value = 0.1f
            };
            var key1 = new AnimationKeyFrame <float>
            {
                Key   = 0.9f,
                Value = 0f
            };

            sizeCurve.KeyFrames.Add(key0);
            sizeCurve.KeyFrames.Add(key1);

            var sizeAnimation = new UpdaterSizeOverTime {
                SamplerMain = { Curve = sizeCurve }
            };

            emitter.Updaters.Add(sizeAnimation);

            emitter.SortingPolicy = EmitterSortingPolicy.ByOrder;

            component.ParticleSystem.Emitters.Add(emitter);

            return(CreateEntityWithComponent(name, component));
        }