Esempio n. 1
0
        public Particle(ParticleEmitter emitter)
        {
            this.alive = true;
            this.creationTime = GameTimeManager.GetInstance().currentUpdateStartMS;

            if (emitter.particleTexture == null)
                this.texture = ParticleManager.DEFAULT_TEXTURE;
            else this.texture = emitter.particleTexture;

            this.x = emitter.x + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRandomX);
            this.y = emitter.y + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRandomY);
            this.z = emitter.z;

            this.scale = emitter.particleScale + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleScaleRandom);

            this.speedX = emitter.particleSpeedX + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRandomSpeedX);
            this.speedY = emitter.particleSpeedY + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRandomSpeedY);

            this.lifespanMS = emitter.particleLifespanMS + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleLifespanRandomMS);

            this.radianRotation = emitter.particleRadianRotation + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRadianRotationRandom);
            this.radianRotationSpeed = emitter.particleRadianRotationSpeed + ((RANDOM.Next(0, 10000) / 10000f) * emitter.particleRadianRotationSpeedRandom);

            this.gravity = emitter.particleGravity;
            this.terminalVelocity = emitter.particleTerminalVelocity;

            this.color = emitter.particleColor;

            this.fadeAccordingToLifespan = emitter.fadeAccordingToLifespan;
            this.inverseFade = emitter.inverseFade;

            this.scaleAccordingToLifespan = emitter.scaleAccordingToLifespan;
            this.inverseScale = emitter.inverseScale;

            this.emitter = emitter;

            this.emitter.particles.AddLast(this);
        }
Esempio n. 2
0
        public AbstractParticle(ParticleEmitter emitter)
        {
            long ticks = DateTime.UtcNow.Ticks;
            this.creationTime = new TimeSpan(ticks).TotalMilliseconds;

            if (emitter.particleTexture == null)
                this.texture = ParticleManager.DEFAULT_TEXTURE;
            else this.texture = emitter.particleTexture;

            Random random = new Random();
            this.x = emitter.x + ((random.Next(0, 10000) / 10000f) * emitter.particleRandomX);
            this.y = emitter.y + ((random.Next(0, 10000) / 10000f) * emitter.particleRandomY);
            this.z = emitter.z;

            this.scale = emitter.particleScale + ((random.Next(0, 10000) / 10000f) * emitter.particleScaleRandom);

            this.speedX = emitter.particleSpeedX + ((random.Next(0, 10000) / 10000f) * emitter.particleRandomSpeedX);
            this.speedY = emitter.particleSpeedY + ((random.Next(0, 10000) / 10000f) * emitter.particleRandomSpeedY);

            this.lifespanMS = emitter.particleLifespanMS + ((random.Next(0, 10000) / 10000f) * emitter.particleLifespanRandomMS);

            this.radianRotation = emitter.particleRadianRotation + ((random.Next(0, 10000) / 10000f) * emitter.particleRadianRotationRandom);
            this.radianRotationSpeed = emitter.particleRadianRotationSpeed + ((random.Next(0, 10000) / 10000f) * emitter.particleRadianRotationSpeedRandom);

            this.color = emitter.particleColor;

            this.fadeAccordingToLifespan = emitter.fadeAccordingToLifespan;
            this.inverseFade = emitter.inverseFade;

            this.scaleAccordingToLifespan = emitter.scaleAccordingToLifespan;
            this.inverseScale = emitter.inverseScale;

            this.emitter = emitter;

            this.emitter.particles.AddLast(this);
        }