コード例 #1
0
        /// <summary>
        /// When overridden in the derived class, handles updating the <see cref="ParticleEmitter"/>.
        /// </summary>
        /// <param name="emitter">The <see cref="ParticleEmitter"/> to be modified.</param>
        /// <param name="elapsedTime">The amount of time that has elapsed since the last update.</param>
        protected override void HandleUpdate(ParticleEmitter emitter, int elapsedTime)
        {
            _timeout -= elapsedTime;

            // Store the original value
            _emitterReleaseAmount = emitter.ReleaseAmount;

            // If bursting, set the release amount to 0 (it will be restored later in HandleRestore)
            if (!_isBursting)
            {
                emitter.ReleaseAmount = 0;
            }

            // After enough time has elapsed, flip between bursting and not bursting
            if (_timeout <= 0)
            {
                if (_isBursting)
                {
                    _timeout = RestPeriod;
                }
                else
                {
                    _timeout = EmitPeriod;
                }

                _isBursting = !_isBursting;
            }
        }
コード例 #2
0
ファイル: ParticleEmitter.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Initializes a new instance of the <see cref="ParticleEmitter"/> class.
        /// </summary>
        /// <param name="owner">The <see cref="IParticleEffect"/> that owns this <see cref="IParticleEmitter"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="owner"/> is null.</exception>
        protected ParticleEmitter(IParticleEffect owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            _owner = owner;

            ((ParticleEffect)owner).AddParticleEmitter(this);

            _budget    = DefaultBudget;
            _particles = new Particle[_initialParticleArraySize];

            // Set some default values
            BlendMode       = _defaultBlendMode;
            ParticleLife    = new VariableInt(2000);
            ReleaseAmount   = new VariableUShort(1);
            ReleaseColor    = new VariableColor(Color.White);
            ReleaseRate     = new VariableUShort(100);
            ReleaseRotation = new VariableFloat(0);
            ReleaseScale    = new VariableFloat(1);
            ReleaseSpeed    = new VariableFloat(50);
            Name            = DefaultName;
        }
コード例 #3
0
        public void RandomVariableUShortTest()
        {
            for (var i = 0; i < _randomVariableTestIterations; i++)
            {
                const ushort min = ushort.MinValue;
                const ushort max = ushort.MaxValue;

                var a = (ushort)RandomHelper.NextInt(min, max);
                var b = (ushort)RandomHelper.NextInt(min, max);

                var v = new VariableUShort(a, b);

                WriteTest(v, (x, y, z) => x.Write(y, (VariableUShort)z), (x, y) => x.ReadVariableUShort(y));
            }
        }
コード例 #4
0
        /// <summary>
        /// When overridden in the derived class, handles updating the <see cref="ParticleEmitter"/>.
        /// </summary>
        /// <param name="emitter">The <see cref="ParticleEmitter"/> to be modified.</param>
        /// <param name="elapsedTime">The amount of time that has elapsed since the last update.</param>
        protected override void HandleUpdate(ParticleEmitter emitter, int elapsedTime)
        {
            _timeout -= elapsedTime;

            // Store the original value
            _emitterReleaseAmount = emitter.ReleaseAmount;

            // If bursting, set the release amount to 0 (it will be restored later in HandleRestore)
            if (!_isBursting)
                emitter.ReleaseAmount = 0;

            // After enough time has elapsed, flip between bursting and not bursting
            if (_timeout <= 0)
            {
                if (_isBursting)
                    _timeout = RestPeriod;
                else
                    _timeout = EmitPeriod;

                _isBursting = !_isBursting;
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParticleEmitter"/> class.
        /// </summary>
        /// <param name="owner">The <see cref="IParticleEffect"/> that owns this <see cref="IParticleEmitter"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="owner"/> is null.</exception>
        protected ParticleEmitter(IParticleEffect owner)
        {
            if (owner == null)
                throw new ArgumentNullException("owner");

            _owner = owner;

            ((ParticleEffect)owner).AddParticleEmitter(this);

            _budget = DefaultBudget;
            _particles = new Particle[_initialParticleArraySize];

            // Set some default values
            BlendMode = _defaultBlendMode;
            ParticleLife = new VariableInt(2000);
            ReleaseAmount = new VariableUShort(1);
            ReleaseColor = new VariableColor(Color.White);
            ReleaseRate = new VariableUShort(100);
            ReleaseRotation = new VariableFloat(0);
            ReleaseScale = new VariableFloat(1);
            ReleaseSpeed = new VariableFloat(50);
            Name = DefaultName;
        }