コード例 #1
0
ファイル: PercentageArray.cs プロジェクト: Mattias1/pacman
        /// <summary>
        /// A percentageArray with only one value
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static PercentageArray <T> Singleton(T value)
        {
            PercentageArray <T> array = new PercentageArray <T>(1);

            array[0] = new PercentageElement <T>(0, value);
            return(array);
        }
コード例 #2
0
ファイル: PercentageArray.cs プロジェクト: Mattias1/pacman
        public PercentageArray <T> Clone()
        {
            PercentageArray <T> clone = new PercentageArray <T>(this.array.Length);

            for (int i = 0; i < clone.Length; i++)
            {
                clone[i] = this.array[i].Clone();
            }
            return(clone);
        }
コード例 #3
0
ファイル: PercentageArray.cs プロジェクト: Mattias1/pacman
        /// <summary>
        /// A percentage array with certain values. The percentages are evenly spaced.
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public static PercentageArray <T> FromArray(T[] values)
        {
            PercentageArray <T> array = new PercentageArray <T>(values.Length);

            for (int i = 0; i < values.Length; i++)
            {
                array[i] = new PercentageElement <T>(100 * i / (values.Length - 1), values[i]);
            }
            return(array);
        }
コード例 #4
0
ファイル: PercentageArray.cs プロジェクト: Mattias1/pacman
        /// <summary>
        /// A percentage array with percentages and values
        /// </summary>
        /// <param name="values">Params in the form: Pct, Value, Pct, Value, ...</param>
        /// <returns></returns>
        public static PercentageArray <T> FromParams(object[] values)
        {
            PercentageArray <T> array = new PercentageArray <T>(values.Length / 2);

            for (int i = 0; i < values.Length; i += 2)
            {
                array[i / 2] = new PercentageElement <T>((float)values[i], (T)values[i + 1]);
            }
            return(array);
        }
コード例 #5
0
ファイル: Particle.cs プロジェクト: Mattias1/pacman
 public virtual void Initialize(Vector3 position, Vector3 velocity, Vector3 acceleration, float lifeTime,
                                PercentageArray <Color> colorPs, PercentageArray <float> scalePs, PercentageArray <float> alphaPs, Geo geo)
 {
     this.position         = position;
     this.velocity         = velocity;
     this.acceleration     = acceleration;
     this.timeLeft         = this.lifeTime = lifeTime;
     this.colorPercentages = colorPs;
     this.scalePercentages = scalePs;
     this.alphaPercentages = alphaPs;
     this.geometry         = geo;
 }
コード例 #6
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
        protected virtual ParticleT createParticle(float elepsedS)
        {
            float percentage = this.calculateEmitterPercentage();

            // Calculate the lifetime
            float lifetime = 1f;

            if (this.AverageLifetimes.Length == 1)
            {
                lifetime = this.AverageLifetimes[0].Value;
            }
            else
            {
                int i = this.AverageLifetimes.GetToIndex(percentage);
                lifetime = GameMath.Lerp(this.AverageLifetimes[i - 1].Value, this.AverageLifetimes[i].Value, AverageLifetimes.GetLerpFactor(i, percentage));
            }
            lifetime = (float)GlobalRandom.Rand(this.Distribution, lifetime, this.LifeTimeDeviation);

            // Adjust the scales
            PercentageArray <float> scales = this.ScalePercentages.Clone();

            if (ScaleDiesToo)
            {
                float factor = lifetime / this.AverageLifetimes[0].Value;
                for (int i = 0; i < scales.Length; i++)
                {
                    scales[i].Value = scales[i].Value * factor;
                }
            }

            // Adjust the alphas
            PercentageArray <float> alphas = this.AlphaPercentages.Clone();

            if (AlphaDiesToo)
            {
                float factor = lifetime / this.AverageLifetimes[0].Value;
                for (int i = 0; i < alphas.Length; i++)
                {
                    alphas[i].Value = alphas[i].Value * factor;
                }
            }

            // Create the particle
            ParticleT particle = this.createParticle(elepsedS, lifetime, scales, alphas);

            return(particle);
        }
コード例 #7
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
        //protected abstract ParticleT createParticle(float elepsedS, float lifetime, PercentageArray<float> scales, byte alpha);
        protected virtual ParticleT createParticle(float elepsedS, float lifetime, PercentageArray <float> scales, PercentageArray <float> alphas)
        {
            Vector3   velocity = this.Velocity.Create();
            ParticleT particle = new ParticleT();

            particle.Initialize(
                this.Position + velocity * elepsedS * (GlobalRandom.Next(4) + 1f) / 4f,
                velocity,
                this.Acceleration.Create(),
                lifetime,
                this.ColorPercentages,
                scales,
                alphas,
                this.Geometry
                );
            return(particle);
        }
コード例 #8
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the percentages and alpha values (in [0,1]) (in the form: pct, alpha, pct, alpha, ...)
 /// </summary>
 /// <param name="percentageAlphaValues"></param>
 public void SetPercentageAlphas(params object[] percentageAlphaValues)
 {
     this.AlphaPercentages = PercentageArray <float> .FromParams(percentageAlphaValues);
 }
コード例 #9
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the alpha values (in [0,1]) (and interpolate the percentages linearely)
 /// </summary>
 /// <param name="scales"></param>
 public void SetAlphas(params float[] scales)
 {
     this.AlphaPercentages = PercentageArray <float> .FromArray(scales);
 }
コード例 #10
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the percentages and scales (in the form: pct, scale, pct, scale, ...)
 /// </summary>
 /// <param name="percentageScales"></param>
 public void SetPercentageScales(params object[] percentageScales)
 {
     this.ScalePercentages = PercentageArray <float> .FromParams(percentageScales);
 }
コード例 #11
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the scales (and interpolate the percentages linearely)
 /// </summary>
 /// <param name="scales"></param>
 public void SetScales(params float[] scales)
 {
     this.ScalePercentages = PercentageArray <float> .FromArray(scales);
 }
コード例 #12
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the colours (and interpolate the percentages linearely)
 /// </summary>
 /// <param name="colors"></param>
 public void SetColors(params Color[] colors)
 {
     this.ColorPercentages = PercentageArray <Color> .FromArray(colors);
 }
コード例 #13
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the percentages and lifetimes (in the form: pct, time, pct, time, ...) (in s)
 /// </summary>
 /// <param name="percentageLifetimes"></param>
 public void SetPercentageAverageLifetimes(params object[] percentageLifetimes)
 {
     this.AverageLifetimes = PercentageArray <float> .FromParams(percentageLifetimes);
 }
コード例 #14
0
        protected override TextParticle3D createParticle(float elepsedS, float lifetime, PercentageArray <float> scales, PercentageArray <float> alphas)
        {
            TextParticle3D particle = base.createParticle(elepsedS, lifetime, scales, alphas);

            particle.SetText(this.text);
            return(particle);
        }
コード例 #15
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the lifetimes (and interpolate the percentages linearely) (in s)
 /// </summary>
 /// <param name="lifetimes"></param>
 public void SetAverageLifetimes(params float[] lifetimes)
 {
     this.AverageLifetimes = PercentageArray <float> .FromArray(lifetimes);
 }
コード例 #16
0
ファイル: Particle2D.cs プロジェクト: Mattias1/pacman
        public override void Initialize(Vector3 position, Vector3 velocity, Vector3 acceleration, float lifeTime, PercentageArray <Color> colorPs, PercentageArray <float> scalePs, PercentageArray <float> alphaPs, Sprite2DGeometry geo)
        {
            base.Initialize(position, velocity, acceleration, lifeTime, colorPs, scalePs, alphaPs, geo);

            this.position.Z     = 0;
            this.velocity.Z     = 0;
            this.acceleration.Z = 0;
        }
コード例 #17
0
ファイル: ParticleEmitter.cs プロジェクト: Mattias1/pacman
 /// <summary>
 /// Set the percentages and colours (in the form: pct, color, pct, color, ...)
 /// </summary>
 /// <param name="percentageColors"></param>
 public void SetPercentageColors(params object[] percentageColors)
 {
     this.ColorPercentages = PercentageArray <Color> .FromParams(percentageColors);
 }