Пример #1
0
        public virtual void Update(Part particle)
        {
            particle.life -= Atlas.Elapsed;
            particle.alpha = Math.Min(1, particle.life);

            if (particle.life < 0)
                particle.alive = false;
        }
Пример #2
0
 public void Draw(Part particle)
 {
     if (particle.scale > 0 && particle.alpha > 0)
     {
         Atlas.Graphics.DrawSprite(Atlas.Content.GetContent<Texture2D>("images/debug_arrow"),
             particle.position, null,
             particle.color * Math.Min(particle.alpha, 1),
             new Vector2(16, 16),
             particle.angle,
             particle.scale, false);
     }
 }
Пример #3
0
        public void Emit(Vector2 position)
        {
            alive = true;

            foreach (Part p in particles)
            {
                if (!p.alive)
                {
                    particleProcessor.Emit(p, position);
                    return;
                }
            }

            Part pt = new Part(Atlas, particleProcessor);
            particles.Add(pt);
            particleProcessor.Emit(pt, position);
        }
Пример #4
0
        public void Emit(Part particle, Vector2 position)
        {
            particle.Reset();
            particle.position = position;

            float angle = (float)(Math.PI * 2 * Atlas.Rand);

            if (strength.Max != 0 || strength.Min != 0)
            {
                particle.vectors[1] = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle))
                    * strength.ToDivision(Atlas.Rand);
            }

            particle.angle = (float)(Math.PI * 2 * Atlas.Rand);
            particle.color = Color.Lerp(Color.White, Color.Gray, Atlas.Rand);

            particle.life = _totalLife;
        }
Пример #5
0
        public void Update(Part particle)
        {
            particle.vectors[0] += _accelertation * Atlas.Elapsed;
            particle.vectors[1] -= particle.vectors[1] * (drag * Atlas.Elapsed);

            particle.position += (particle.vectors[0] + particle.vectors[1]) * Atlas.Elapsed;

            particle.life -= Atlas.Elapsed;

            particle.alpha = Math.Min(particle.life / _totalLife, (_totalLife - particle.life) / 4);

            particle.scale = 2 - (particle.life / _totalLife) * (particle.life / _totalLife);

            if (particle.life < 0)
                particle.alive = false;
        }
Пример #6
0
 public virtual void Emit(Part particle, Vector2 position)
 {
     particle.Reset();
     particle.position = position;
     particle.life = 1;
 }
Пример #7
0
        public void Emit(Part particle, Vector2 position)
        {
            particle.Reset();
            particle.position = position;

            float angle = Atlas.Rand * (float)Math.PI * 2;

            wantedAngle = wantedAngle % ((float)Math.PI * 2);
            if (wantedAngle < 0) wantedAngle = wantedAngle + (float)Math.PI * 2;

            while (Math.Abs(angle - wantedAngle) > (float)Math.PI) angle = angle + Math.Sign(wantedAngle - angle) * (float)Math.PI * 2;

            float power = 1 - (Math.Abs(angle - wantedAngle) / ((float)Math.PI)) * wantedAngleWeight;

            particle.vectors[0] = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle))
                * strength.ToDivision(Atlas.Rand * power);

            particle.angle = angle;
            particle.color = color;

            particle.life = _totalLife;
        }
Пример #8
0
 public void Draw(Part particle)
 {
     Atlas.Graphics.DrawSprite(Atlas.Content.GetContent<Texture2D>("part"),
                                 particle.position, null, Color.White * particle.alpha, Vector2.One * 2,
                                 particle.angle, particle.scale, false);
 }
Пример #9
0
        public void Update(Part particle)
        {
            particle.position += particle.vectors[0] * Atlas.Elapsed;

            particle.life -= Atlas.Elapsed;

            particle.color = color;

            particle.alpha = particle.life;
            particle.scale = 2 - (particle.life / _totalLife) * (particle.life / _totalLife);

            if (particle.life < 0)
                particle.alive = false;
        }