Пример #1
0
        public static void BreakSprite(Area area, TextureRegion region, Vector2 position, int depth = -1)
        {
            var s = 5;

            for (int x = 0; x < region.Width; x += s)
            {
                for (int y = 0; y < region.Height; y += s)
                {
                    var r = new TextureRegion(region, s, s);

                    r.Source.X += x;
                    r.Source.Y += y;

                    var part = new ParticleEntity(new Particle(Controllers.Destroy, new TexturedParticleRenderer {
                        Region = r
                    }));

                    part.Particle.Angle = (float)(Math.Atan2(r.Center.Y - y, r.Center.X - x) - Math.PI + Rnd.Float(-1, 1));
                    part.Position       = position + new Vector2(x, y);
                    area.Add(part);

                    if (depth != -1)
                    {
                        part.Depth = depth;
                    }
                }
            }
        }
Пример #2
0
        public static ParticleEntity Wrap(Particle particle, Area area, Vector2 where)
        {
            var e = new ParticleEntity(particle);

            e.Position          = where;
            e.Particle.Position = where;

            area.Add(e);

            return(e);
        }