Пример #1
0
        internal void SetType(ParticleType type)
        {
            Type = type;

            Scale = Type.ScaleModifier.Random;
            Angle = Type.AngleModifier.Random;
            Alpha = Type.AlphaModifier.Random;

            LifeMax = (int)Math.Round(Type.realLife.Random);
            Life = 0;
            LifePercent = 0;

            if (Type.Mode == ParticleType.FrameMode.Random)
                Frame = (int)Calc.Random.Next(Type.Sprite.Length);
            else
                Frame = 0;

            if (Type.BlendWithTime)
                Color = Type.Blend[0];
            else
                Color = Calc.Random.Choose(Type.Blend);

            Velocity = new Angle(Type.Direction.Random, true).ToVector(Type.Speed.Random);

            DrawScale = new Vector2(Type.ScaleX.Min, Type.ScaleY.Min) * Type.Size.Min * Scale;
            DrawAngle = new Angle(Type.Angle.Min + Angle, true);
        }
Пример #2
0
        /// <summary>
        /// Adds a particle to the system within a given radius.
        /// </summary>
        /// <param name="x">X center of the circle.</param>
        /// <param name="y">Y center of the circle.</param>
        /// <param name="radius">Radius of the circle.</param>
        /// <param name="type">The type of particle to add.</param>
        /// <param name="amount">The amount of particles to add.</param>
        public void AddParticleCircle(float x, float y, float radius, ParticleType type, int amount = 1)
        {
            Vector2 vector = new Vector2();

            for (int i = 0; i < amount; ++i)
            {
                vector = Calc.Random.NextAngle().ToVector(Calc.Random.NextFloat(radius));
                AddParticle(x + vector.X, y + vector.Y, type);
            }
        }
Пример #3
0
        public ParticleType SetStep(ParticleType type, int numParticles = 1, float chance = 1.0f)
        {
            StepParticle = type;
            StepParticleAmount = numParticles;
            StepParticleChance = chance;

            return this;
        }
Пример #4
0
        public ParticleType SetDeath(ParticleType type, int numParticles = 1, float chance = 1.0f)
        {
            DeathParticle = type;
            DeathParticleAmount = numParticles;
            DeathParticleChance = chance;

            return this;
        }
Пример #5
0
 public ParticleRecord(string name, string subtexture, SpriteRecord record)
 {
     TextureName = name;
     SubtextureName = subtexture;
     Record = record;
     Type = new ParticleType();
 }
Пример #6
0
 /// <summary>
 /// Adds a particle to the system.
 /// </summary>
 /// <param name="x">The x position to add the particle at.</param>
 /// <param name="y">The y position to add the particle at.</param>
 /// <param name="type">The type of particle to add.</param>
 /// <param name="amount">The amount of particles to add.</param>
 public void AddParticle(float x, float y, ParticleType type, int amount = 1)
 {
     for(int i = 0; i < amount; ++i)
         AddParticle(x, y, type);
 }
Пример #7
0
        private void AddParticle(float x, float y, ParticleType type)
        {
            while (ParticlesActive >= MaxParticles)
                RemoveParticle(0);

            Particle particle = particles[ParticlesActive++];
            particle.SetType(type);
            particle.Position.X = x;
            particle.Position.Y = y;
        }