public PMIData(string texture, string name, ushort mass, Vector4 color, ParticleBlendMode blend, int layer)
 {
     TextureName = texture;
     Name = name;
     Mass = mass;
     Color = color;
     Blend = blend;
     Layer = layer;
 }
示例#2
0
 public void Add(Vector2 spawnPos, Vector2 velocity, float life, bool canCollide, Rectangle sourcerect, float rot, float scale, Color col, float a, SpecialParticle special, ParticleBlendMode blend, bool onTop)
 {
     Particle p = new Particle();
     p.Special = special;
     p.BlendMode = blend;
     p.Position = spawnPos;
     p.Velocity = velocity;
     p.Life = life;
     p.CanCollide = canCollide;
     p.SourceRect = sourcerect;
     p.Alpha = a;
     p.Active = true;
     p.RotationSpeed = rot;
     p.Color = col;
     p.Rotation = rot;
     p.Scale = scale;
     p.OnTop = onTop;
     Particles.Add(p);
 }
        protected override void Render(GraphicsContext graphicsContext, ref ParticleBuffer.Iterator iterator, TextureDefinition texture, ParticleBlendMode blendMode)
        {
            if (!this.IsSpriteBatchAlreadyRunning)
            {
                graphicsContext.SpriteBatch.Begin(SpriteSortMode.Deferred, blendMode.ToBlendState(), SamplerState.PointClamp, null, null, null);
            }

            float inverseTextureWidth = 1f / texture.Width;
            Vector2 origin = new Vector2(texture.Width, texture.Height) / 2f;

            Particle particle = iterator.First;
            do
            {
                float scale = particle.Scale * inverseTextureWidth;          // Color * alpha is slow....
                graphicsContext.SpriteBatch.Draw(texture, particle.Position, new Color(particle.Color) * particle.Opacity, particle.Rotation, origin, particle.Scale);
            } while (iterator.MoveNext(ref particle));

            if (!this.IsSpriteBatchAlreadyRunning)
            {
                graphicsContext.SpriteBatch.End();
            }
        }
 protected virtual void SetBlendState(ParticleBlendMode mode)
 {
     Device.BlendState = ParticleBlendState.State(mode);
 }
示例#5
0
 public void Draw(SpriteBatch sb, ParticleBlendMode blend, LightingEngine le, bool onTop)
 {
     foreach (Particle p in Particles.Where(part => part.Active && part.BlendMode==blend && part.OnTop==onTop))
     {
         sb.Draw(_texParticles,
                 p.Position,
                 p.SourceRect, le.CurrentSunColor * p.Alpha, p.Rotation, new Vector2(p.SourceRect.Width / 2, p.SourceRect.Height / 2), p.Scale, SpriteEffects.None, 1);
     }
 }
 protected abstract void Render(GraphicsContext graphicsContext, ref ParticleBuffer.Iterator iterator, TextureDefinition texture, ParticleBlendMode blendMode);
示例#7
0
 public ParticleManagerInitializer(Texture2D tex, string name, ushort num, Color col, ParticleBlendMode mode)
     : this(tex, name, num, col.ToVector4(), mode, 0)
 {
 }
示例#8
0
 public ParticleManagerInitializer(Texture2D tex, string name, ushort num, Vector4 vec, ParticleBlendMode mode, int layer)
 {
     Texture = tex;
     Name = name;
     Number = num;
     color = vec;
     Blend = mode;
     Layer = layer;
 }
示例#9
0
 public static BlendState State(ParticleBlendMode blend)
 {
     return blendStates[(int)blend];
 }