public void Burst()
        {
            for (int i = 0; i < 4; i++)
            {
                //Params:
                //0: x-speed initial
                //1: y-speed initial
                //2: x-accel
                //3: y-accel
                //4: x source
                //5: y source
                Particle p = new Particle(RNG.Next(-1000, 1000), RNG.Next(-1000, 1000), 0, 0, _SourceX, _SourceY);

                p.Params[2] = 2 * ((_TargetX - _SourceX) - p.Params[0] * TrackingTime) / (TrackingTime * TrackingTime);
                p.Params[3] = 2 * ((_TargetY - _SourceY) - p.Params[1] * TrackingTime) / (TrackingTime * TrackingTime);

                p.TimeToLive = TrackingTime;
                p.X = _SourceX;
                p.Y = _SourceY;
                p.Scale = 64 / 256.0f;
                p.Color = _Color;

                p.Transform += TrackToTarget;

                Animation frame = AnimationFactory.GenerateAnimation(@"Lensflare", 256, 256, 1, 0);

                p.Sprite = new Sprite(frame, new Vector2(200, 200));
                //p.Sprite.Animation.CurrentFrame = RNG.Next(5);

                this.Add(p);

            }
        }
Beispiel #2
0
        public ParticleEffect(int bufferSize = 0)
            : base(G.Game)
        {
            Particles = new List<Particle>();
            ParticleBuffer = new List<Particle>();

            for (int i = 0; i < bufferSize; i++)
            {
                Particle p = new Particle();
                ParticleBuffer.Add(p);
            }
        }
Beispiel #3
0
        public Particle CreateParticle(params double[] Parameters)
        {
            Particle p;

            if (ParticleBuffer.Count > 0)
            {
                p = ParticleBuffer[0];
                ParticleBuffer.RemoveAt(0);
                p.Init(Parameters);
            }
            else
            {
                p = new Particle(Parameters);
            }

            return p;
        }
        public void Burst()
        {
            Particle p = new Particle();

            p.TimeToLive = ExplodeTime;
            p.X = _SourceX;
            p.Y = _SourceY;
            p.Scale = 128 / 200.0f;
            p.Color = _Color;

            p.Transform += TrackToTarget;

            Animation frame = AnimationFactory.GenerateAnimation(@"Explosion", 200, 200, 6, 0.06);

            p.Sprite = new Sprite(frame, new Vector2(-200, -200));

            this.Add(p);
        }
Beispiel #5
0
 public virtual void Add(Particle p)
 {
     p.Enabled = true;
     Particles.Add(p);
 }