public SLaserBurnParticleSystem(int particleCapacity)
            : base(particleCapacity)
        {
            this.simulationStep = 0.05f;

            // global flame/smoke effector to dim smoke particles of already-released laser hit spots
            _globalSmokeDimmerEffector = new SSColorKeyframesEffector();
            _globalSmokeDimmerEffector.effectorMask      = 1;
            _globalSmokeDimmerEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
            _globalSmokeDimmerEffector.particleLifetime  = 0f;
            _globalSmokeDimmerEffector.colorMask         = Color4.LightGray;
            _globalSmokeDimmerEffector.keyframes.Clear();
            _globalSmokeDimmerEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
            _globalSmokeDimmerEffector.keyframes.Add(0.4f, new Color4(0f, 0f, 0f, 1f));
            _globalSmokeDimmerEffector.keyframes.Add(1f, new Color4(0f, 0f, 0f, 0f));
            addEffector(_globalSmokeDimmerEffector);

            _globalSmokeScaleEffector = new SSMasterScaleKeyframesEffector();
            _globalSmokeScaleEffector.effectorMask      = 0x1;                                  // all smoke
            _globalSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.And; // all smoke
            _globalSmokeScaleEffector.keyframes.Clear();
            _globalSmokeScaleEffector.keyframes.Add(0f, 0.1f);
            _globalSmokeScaleEffector.keyframes.Add(0.15f, 1f);
            _globalSmokeScaleEffector.keyframes.Add(1f, 1.2f);
            addEffector(_globalSmokeScaleEffector);
        }
        public SLaserBurnParticleSystem(int particleCapacity)
            : base(particleCapacity)
        {
            this.simulationStep = 0.1f;

            // global flame/smoke effector to dim smoke particles of already-released laser hit spots
            _globalSmokeDimmerEffector = new SSColorKeyframesEffector ();
            _globalSmokeDimmerEffector.effectorMask = 1;
            _globalSmokeDimmerEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
            _globalSmokeDimmerEffector.particleLifetime = 0f;
            _globalSmokeDimmerEffector.colorMask = Color4.LightGray;
            _globalSmokeDimmerEffector.keyframes.Clear();
            _globalSmokeDimmerEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
            _globalSmokeDimmerEffector.keyframes.Add(0.4f, new Color4 (0f, 0f, 0f, 1f));
            _globalSmokeDimmerEffector.keyframes.Add(1f, new Color4 (0f, 0f, 0f, 0f));
            addEffector(_globalSmokeDimmerEffector);

            _globalSmokeScaleEffector = new SSMasterScaleKeyframesEffector ();
            _globalSmokeScaleEffector.effectorMask = 0x1; // all smoke
            _globalSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.And; // all smoke
            _globalSmokeScaleEffector.keyframes.Clear ();
            _globalSmokeScaleEffector.keyframes.Add (0f, 0.1f);
            _globalSmokeScaleEffector.keyframes.Add (0.25f, 1f);
            _globalSmokeScaleEffector.keyframes.Add (1f, 1.2f);
            addEffector(_globalSmokeScaleEffector);
        }
Пример #3
0
            protected void configureFlameSmoke()
            {
                if (_doFlameSmoke)
                {
                    if (_flameSmokeEmitter == null)
                    {
                        _flameSmokeEmitter        = new SSRadialEmitter();
                        _flamesSmokeColorEffector = new SSColorKeyframesEffector();
                        _flameSmokeScaleEffector  = new SSMasterScaleKeyframesEffector();
                        addEmitter(_flameSmokeEmitter);
                        addEffector(_flamesSmokeColorEffector);
                        addEffector(_flameSmokeScaleEffector);
                        _flameSmokeEmitter.effectorMask             = _flameSmokeScaleEffector.effectorMask
                                                                    = _flamesSmokeColorEffector.effectorMask = (ushort)ComponentMask.FlameSmoke;
                    }

                    _flameSmokeEmitter.spriteRectangles     = _flameSmokeSprites;
                    _flameSmokeEmitter.particlesPerEmission = 2;
                    _flameSmokeEmitter.emissionInterval     = 0.03f * _flameSmokeDuration;
                    _flameSmokeEmitter.totalEmissionsLeft   = 0; // Control this in ShowExplosion()
                    _flameSmokeEmitter.life               = _flameSmokeDuration;
                    _flameSmokeEmitter.orientationMin     = new Vector3(0f, 0f, 0f);
                    _flameSmokeEmitter.orientationMax     = new Vector3(0f, 0f, 2f * (float)Math.PI);
                    _flameSmokeEmitter.billboardXY        = true;
                    _flameSmokeEmitter.angularVelocityMin = new Vector3(0f, 0f, -0.5f);
                    _flameSmokeEmitter.angularVelocityMax = new Vector3(0f, 0f, +0.5f);
                    _flameSmokeEmitter.radiusOffsetMin    = 0f;
                    _flameSmokeEmitter.radiusOffsetMax    = 0.5f;

                    _flamesSmokeColorEffector.colorMask        = _flameColor;
                    _flamesSmokeColorEffector.particleLifetime = _flameSmokeDuration;
                    _flamesSmokeColorEffector.keyframes.Clear();
                    _flamesSmokeColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4(0f, 0f, 0f, 0.5f));
                    _flamesSmokeColorEffector.keyframes.Add(1f, new Color4(0f, 0f, 0f, 0f));

                    _flameSmokeScaleEffector.particleLifetime = _flameSmokeDuration;
                    _flameSmokeScaleEffector.keyframes.Clear();
                    _flameSmokeScaleEffector.keyframes.Add(0f, 0.1f);
                    _flameSmokeScaleEffector.keyframes.Add(0.25f, 1f);
                    _flameSmokeScaleEffector.keyframes.Add(1f, 1.2f);
                }
                else if (_flameSmokeEmitter != null)
                {
                    removeEmitter(_flameSmokeEmitter);
                    removeEffector(_flamesSmokeColorEffector);
                    removeEffector(_flameSmokeScaleEffector);
                    _flameSmokeEmitter        = null;
                    _flamesSmokeColorEffector = null;
                    _flameSmokeScaleEffector  = null;
                }
            }
Пример #4
0
            protected void configureRoundSparks()
            {
                if (_doRoundSparks)
                {
                    _roundSparksEmitter       = new SSRadialEmitter();
                    _roundSparksColorEffector = new SSColorKeyframesEffector();
                    _roundSparksScaleEffector = new SSMasterScaleKeyframesEffector();
                    addEmitter(_roundSparksEmitter);
                    addEffector(_roundSparksColorEffector);
                    addEffector(_roundSparksScaleEffector);
                    _roundSparksEmitter.effectorMask             = _roundSparksScaleEffector.effectorMask
                                                                 = _roundSparksColorEffector.effectorMask = (ushort)ComponentMask.RoundSparks;

                    _roundSparksEmitter.spriteRectangles     = _roundSparksSprites;
                    _roundSparksEmitter.particlesPerEmission = 6;
                    _roundSparksEmitter.emissionIntervalMin  = 0f;
                    _roundSparksEmitter.emissionIntervalMax  = 0.05f * _roundSparksDuration;
                    _roundSparksEmitter.totalEmissionsLeft   = 0; // Control this in ShowExplosion()
                    _roundSparksEmitter.life               = _roundSparksDuration;
                    _roundSparksEmitter.billboardXY        = true;
                    _roundSparksEmitter.orientationMin     = new Vector3(0f, 0f, 0f);
                    _roundSparksEmitter.orientationMax     = new Vector3(0f, 0f, 2f * (float)Math.PI);
                    _roundSparksEmitter.angularVelocityMin = new Vector3(0f, 0f, -0.25f);
                    _roundSparksEmitter.angularVelocityMax = new Vector3(0f, 0f, +0.25f);
                    _roundSparksEmitter.radiusOffsetMin    = 0f;
                    _roundSparksEmitter.radiusOffsetMax    = 1f;

                    _roundSparksColorEffector.particleLifetime = _roundSparksDuration;
                    _roundSparksColorEffector.colorMask        = _roundSparksColor;
                    _roundSparksColorEffector.keyframes.Clear();
                    _roundSparksColorEffector.keyframes.Add(0.1f, new Color4(1f, 1f, 1f, 1f));
                    _roundSparksColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f));

                    _roundSparksScaleEffector.particleLifetime = _roundSparksDuration;
                    _roundSparksScaleEffector.keyframes.Clear();
                    _roundSparksScaleEffector.keyframes.Add(0f, 1f);
                    _roundSparksScaleEffector.keyframes.Add(0.25f, 3f);
                    _roundSparksScaleEffector.keyframes.Add(1f, 6f);
                }
                else if (_roundSparksEmitter != null)
                {
                    removeEmitter(_roundSparksEmitter);
                    removeEffector(_roundSparksColorEffector);
                    removeEffector(_roundSparksScaleEffector);
                    _roundSparksEmitter       = null;
                    _roundSparksColorEffector = null;
                    _roundSparksScaleEffector = null;
                }
            }
Пример #5
0
            protected void configureFlash()
            {
                if (_doFlash)
                {
                    if (_flashEmitter == null)
                    {
                        _flashEmitter       = new SSParticlesFieldEmitter(new ParticlesSphereGenerator());
                        _flashColorEffector = new SSColorKeyframesEffector();
                        _flashScaleEffector = new SSMasterScaleKeyframesEffector();
                        addEmitter(_flashEmitter);
                        addEffector(_flashColorEffector);
                        addEffector(_flashScaleEffector);
                        _flashEmitter.effectorMask             = _flashColorEffector.effectorMask
                                                               = _flashScaleEffector.effectorMask = (ushort)ComponentMask.Flash;
                    }

                    _flashEmitter.spriteRectangles        = _flashSprites;
                    _flashEmitter.particlesPerEmissionMin = 1;
                    _flashEmitter.particlesPerEmissionMax = 2;
                    _flashEmitter.emissionIntervalMin     = 0f;
                    _flashEmitter.emissionIntervalMax     = 0.2f * _flashDuration;
                    _flashEmitter.life               = _flashDuration;
                    _flashEmitter.velocity           = Vector3.Zero;
                    _flashEmitter.orientationMin     = new Vector3(0f, 0f, 0f);
                    _flashEmitter.orientationMax     = new Vector3(0f, 0f, 2f * (float)Math.PI);
                    _flashEmitter.billboardXY        = true;
                    _flashEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()

                    _flashColorEffector.particleLifetime = _flashDuration;
                    _flashColorEffector.colorMask        = _flashColor;
                    _flashColorEffector.keyframes.Clear();
                    _flashColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _flashColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f));

                    _flashScaleEffector.particleLifetime = _flashDuration;
                    _flashScaleEffector.keyframes.Clear();
                    _flashScaleEffector.keyframes.Add(0f, 1f);
                    _flashScaleEffector.keyframes.Add(1f, 1.5f);
                }
                else if (_flashEmitter != null)
                {
                    removeEmitter(_flashEmitter);
                    removeEffector(_flashColorEffector);
                    removeEffector(_flashScaleEffector);
                    _flashEmitter       = null;
                    _flashColorEffector = null;
                    _flashScaleEffector = null;
                }
            }
Пример #6
0
            protected void configureSmokeTrails()
            {
                if (_doSmokeTrails)
                {
                    if (_smokeTrailsEmitter == null)
                    {
                        _smokeTrailsEmitter       = new SSRadialEmitter();
                        _smokeTrailsColorEffector = new SSColorKeyframesEffector();
                        _smokeTrailsScaleEffector = new SSComponentScaleKeyframeEffector();
                        addEmitter(_smokeTrailsEmitter);
                        addEffector(_smokeTrailsColorEffector);
                        addEffector(_smokeTrailsScaleEffector);
                        _smokeTrailsEmitter.effectorMask             = _smokeTrailsColorEffector.effectorMask
                                                                     = _smokeTrailsScaleEffector.effectorMask = (ushort)ComponentMask.SmokeTrails;
                    }

                    _smokeTrailsEmitter.radiusOffset         = 3f;
                    _smokeTrailsEmitter.spriteRectangles     = _smokeTrailsSprites;
                    _smokeTrailsEmitter.particlesPerEmission = 16;
                    _smokeTrailsEmitter.emissionIntervalMin  = 0f;
                    _smokeTrailsEmitter.emissionIntervalMax  = 0.1f * _smokeTrailsDuration;
                    _smokeTrailsEmitter.life = _smokeTrailsDuration;
                    _smokeTrailsEmitter.totalEmissionsLeft = 0; // control this in ShowExplosion()
                    _smokeTrailsEmitter.color = _smokeTrailsColor;

                    _smokeTrailsColorEffector.particleLifetime = _smokeTrailsDuration;
                    _smokeTrailsColorEffector.colorMask        = _smokeTrailsColor;
                    _smokeTrailsColorEffector.keyframes.Clear();
                    _smokeTrailsColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _smokeTrailsColorEffector.keyframes.Add(1f, new Color4(0.3f, 0.3f, 0.3f, 0f));

                    _smokeTrailsScaleEffector.particleLifetime = _smokeTrailsDuration;
                    _smokeTrailsScaleEffector.baseOffset       = new Vector3(1f, 1f, 1f);
                    _smokeTrailsScaleEffector.keyframes.Clear();
                    _smokeTrailsScaleEffector.keyframes.Add(0f, new Vector3(0f));
                    _smokeTrailsScaleEffector.keyframes.Add(0.5f, new Vector3(12f, 1.5f, 0f));
                    _smokeTrailsScaleEffector.keyframes.Add(1f, new Vector3(7f, 2f, 0f));
                }
                else if (_smokeTrailsEmitter != null)
                {
                    removeEmitter(_smokeTrailsEmitter);
                    removeEffector(_smokeTrailsColorEffector);
                    removeEffector(_smokeTrailsScaleEffector);
                    _smokeTrailsEmitter       = null;
                    _smokeTrailsColorEffector = null;
                    _smokeTrailsScaleEffector = null;
                }
            }
Пример #7
0
            protected void configureShockwave()
            {
                if (_doShockwave)
                {
                    if (_shockwaveEmitter == null)
                    {
                        _shockwaveEmitter       = new ShockwaveEmitter();
                        _shockwaveColorEffector = new SSColorKeyframesEffector();
                        _shockwaveScaleEffector = new SSMasterScaleKeyframesEffector();
                        addEmitter(_shockwaveEmitter);
                        addEffector(_shockwaveScaleEffector);
                        addEffector(_shockwaveColorEffector);
                        _shockwaveEmitter.effectorMask             = _shockwaveScaleEffector.effectorMask
                                                                   = _shockwaveColorEffector.effectorMask = (ushort)ComponentMask.Shockwave;
                    }
                    _shockwaveEmitter.spriteRectangles     = _shockwaveSprites;
                    _shockwaveEmitter.particlesPerEmission = 1;
                    _shockwaveEmitter.totalEmissionsLeft   = 0; // Control this in ShowExplosion()
                    _shockwaveEmitter.life     = _shockwaveDuration;
                    _shockwaveEmitter.velocity = Vector3.Zero;

                    _shockwaveScaleEffector.particleLifetime = _shockwaveDuration;
                    _shockwaveScaleEffector.keyframes.Clear();
                    _shockwaveScaleEffector.keyframes.Add(0f, 0f);
                    _shockwaveScaleEffector.keyframes.Add(_shockwaveDuration, 7f);

                    _shockwaveColorEffector.colorMask        = _shockwaveColor;
                    _shockwaveColorEffector.particleLifetime = _shockwaveDuration;
                    _shockwaveColorEffector.keyframes.Clear();
                    _shockwaveColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _shockwaveColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f));
                }
                else if (_shockwaveEmitter != null)
                {
                    removeEmitter(_shockwaveEmitter);
                    removeEffector(_shockwaveColorEffector);
                    removeEffector(_shockwaveScaleEffector);
                    _shockwaveEmitter       = null;
                    _shockwaveColorEffector = null;
                    _shockwaveScaleEffector = null;
                }
            }
Пример #8
0
            protected void configureDebris()
            {
                if (_eParams.doDebris)
                {
                    if (_debrisEmitter == null)
                    {
                        _debrisEmitter       = new SSRadialEmitter();
                        _debrisColorEffector = new SSColorKeyframesEffector();
                        addEmitter(_debrisEmitter);
                        addEffector(_debrisColorEffector);
                        _debrisEmitter.effectorMask             = _debrisColorEffector.effectorMask
                                                                = (ushort)ComponentMask.Debris;
                    }
                    _debrisEmitter.spriteRectangles        = _eParams.debrisSprites;
                    _debrisEmitter.particlesPerEmissionMin = 7;
                    _debrisEmitter.particlesPerEmissionMax = 10;
                    _debrisEmitter.totalEmissionsLeft      = 0; // Control this in ShowExplosion()
                    _debrisEmitter.life               = _eParams.debrisDuration;
                    _debrisEmitter.orientationMin     = new Vector3(0f, 0f, 0f);
                    _debrisEmitter.orientationMax     = new Vector3(0f, 0f, 2f * (float)Math.PI);
                    _debrisEmitter.billboardXY        = true;
                    _debrisEmitter.angularVelocityMin = new Vector3(0f, 0f, -0.5f);
                    _debrisEmitter.angularVelocityMax = new Vector3(0f, 0f, +0.5f);
                    _debrisEmitter.radiusOffsetMin    = 0f;
                    _debrisEmitter.radiusOffsetMax    = 1f;

                    var debrisColorFinal = new Color4(_eParams.debrisColorEnd.R,
                                                      _eParams.debrisColorEnd.G, _eParams.debrisColorEnd.B, 0f);
                    _debrisColorEffector.particleLifetime = _eParams.debrisDuration;
                    _debrisColorEffector.keyframes.Clear();
                    _debrisColorEffector.keyframes.Add(0f, _eParams.debrisColorStart);
                    _debrisColorEffector.keyframes.Add(0.3f, _eParams.debrisColorEnd);
                    _debrisColorEffector.keyframes.Add(1f, debrisColorFinal);
                }
                else if (_debrisEmitter != null)
                {
                    removeEmitter(_debrisEmitter);
                    removeEffector(_debrisColorEffector);
                    _debrisEmitter       = null;
                    _debrisColorEffector = null;
                }
            }
Пример #9
0
            protected void configureFlyingSparks()
            {
                if (_doFlyingSparks)
                {
                    if (_flyingSparksEmitter == null)
                    {
                        _flyingSparksEmitter       = new SSRadialEmitter();
                        _flyingSparksColorEffector = new SSColorKeyframesEffector();
                        addEmitter(_flyingSparksEmitter);
                        addEffector(_flyingSparksColorEffector);
                        _flyingSparksEmitter.effectorMask             = _flyingSparksColorEffector.effectorMask
                                                                      = (ushort)ComponentMask.FlyingSparks;
                    }

                    _flyingSparksEmitter.spriteRectangles    = _flyingSparksSprites;
                    _flyingSparksEmitter.emissionIntervalMin = 0f;
                    _flyingSparksEmitter.emissionIntervalMax = 0.1f * _flyingSparksDuration;
                    _flyingSparksEmitter.life = _flyingSparksDuration;
                    _flyingSparksEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()
                    _flyingSparksEmitter.componentScale     = new Vector3(5f, 1f, 1f);
                    _flyingSparksEmitter.color = _flyingSparksColor;

                    _flyingSparksColorEffector.colorMask = _flashColor;
                    _flyingSparksColorEffector.keyframes.Clear();
                    _flyingSparksColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _flyingSparksColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f));
                    _flyingSparksColorEffector.particleLifetime = _flyingSparksDuration;
                }
                else if (_flyingSparksEmitter != null)
                {
                    removeEmitter(_flyingSparksEmitter);
                    removeEffector(_flyingSparksColorEffector);
                    _flyingSparksEmitter       = null;
                    _flyingSparksColorEffector = null;
                }
            }
        protected void _initParamsSpecific(SSpaceMissileParameters mParams)
        {
            // smoke effectors
            if (_particleRenderer.textureMaterial == null) {
                _particleRenderer.textureMaterial = new SSTextureMaterial (mParams.smokeParticlesTexture);
            }
            if (_flameSmokeColorEffector == null) {
                _flameSmokeColorEffector = new SSColorKeyframesEffector ();
                _flameSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _flameSmokeColorEffector.effectorMask = (ushort)ParticleEffectorMasks.FlameToSmoke;
                _flameSmokeColorEffector.particleLifetime = mParams.flameSmokeDuration;
                //_smokeColorEffector.colorMask = ;
                _flameSmokeColorEffector.keyframes.Clear();
                var flameColor = mParams.innerFlameColor;
                flameColor.A = 0.9f;
                _flameSmokeColorEffector.keyframes.Add(0f, flameColor);
                flameColor = mParams.outerFlameColor;
                flameColor.A = 0.7f;
                _flameSmokeColorEffector.keyframes.Add(0.1f, flameColor);
                var smokeColor = mParams.smokeColor;
                smokeColor.A = 0.2f;
                _flameSmokeColorEffector.keyframes.Add(0.2f, smokeColor);
                smokeColor.A = 0f;
                _flameSmokeColorEffector.keyframes.Add(1f, smokeColor);

                _particlesData.addEffector(_flameSmokeColorEffector);
            }
            if (_ejectionSmokeColorEffector == null) {
                _ejectionSmokeColorEffector = new SSColorKeyframesEffector ();
                _ejectionSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _ejectionSmokeColorEffector.effectorMask = (ushort)ParticleEffectorMasks.EjectionSmoke;
                _ejectionSmokeColorEffector.particleLifetime = mParams.flameSmokeDuration;
                _ejectionSmokeColorEffector.keyframes.Clear();
                var smokeColor = mParams.smokeColor;
                smokeColor.A = 0.3f;
                _ejectionSmokeColorEffector.keyframes.Add(0f, smokeColor);
                smokeColor.A = 0.14f;
                _ejectionSmokeColorEffector.keyframes.Add(0.2f, smokeColor);
                smokeColor.A = 0f;
                _ejectionSmokeColorEffector.keyframes.Add(1f, smokeColor);

                _particlesData.addEffector(_ejectionSmokeColorEffector);
            }
            if (_flameSmokeScaleEffector == null) {
                _flameSmokeScaleEffector = new SSMasterScaleKeyframesEffector ();
                _flameSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _flameSmokeScaleEffector.effectorMask = (ushort)ParticleEffectorMasks.FlameToSmoke;
                _flameSmokeScaleEffector.particleLifetime = mParams.flameSmokeDuration;
                _flameSmokeScaleEffector.keyframes.Clear();
                _flameSmokeScaleEffector.keyframes.Add(0f, 0.3f);
                _flameSmokeScaleEffector.keyframes.Add(0.1f, 1f);
                _flameSmokeScaleEffector.keyframes.Add(1f, 2f);

                _particlesData.addEffector(_flameSmokeScaleEffector);
            }
            if (_ejectionSmokeScaleEffector == null) {
                _ejectionSmokeScaleEffector = new SSMasterScaleKeyframesEffector ();
                _ejectionSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _ejectionSmokeScaleEffector.effectorMask = (ushort)ParticleEffectorMasks.EjectionSmoke;
                _ejectionSmokeScaleEffector.particleLifetime = mParams.ejectionSmokeDuration;
                _ejectionSmokeScaleEffector.keyframes.Clear();
                _ejectionSmokeScaleEffector.keyframes.Add(0f, 0.1f);
                _ejectionSmokeScaleEffector.keyframes.Add(0.35f, 0.8f);
                _ejectionSmokeScaleEffector.keyframes.Add(1f, 1.35f);

                _particlesData.addEffector(_ejectionSmokeScaleEffector);
            }
        }
Пример #11
0
            protected void configureRoundSparks()
            {
                if (_eParams.doRoundSparks) {
                    _roundSparksEmitter = new SSRadialEmitter ();
                    _roundSparksColorEffector = new SSColorKeyframesEffector ();
                    _roundSparksScaleEffector = new SSMasterScaleKeyframesEffector ();
                    addEmitter (_roundSparksEmitter);
                    addEffector (_roundSparksColorEffector);
                    addEffector (_roundSparksScaleEffector);
                    _roundSparksEmitter.effectorMask = _roundSparksScaleEffector.effectorMask
                        = _roundSparksColorEffector.effectorMask = (ushort)ComponentMask.RoundSparks;

                    _roundSparksEmitter.spriteRectangles = _eParams.roundSparksSprites;
                    _roundSparksEmitter.particlesPerEmission = 6;
                    _roundSparksEmitter.emissionIntervalMin = 0f;
                    _roundSparksEmitter.emissionIntervalMax = 0.05f * _eParams.roundSparksDuration;
                    _roundSparksEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()
                    _roundSparksEmitter.life = _eParams.roundSparksDuration;
                    _roundSparksEmitter.billboardXY = true;
                    _roundSparksEmitter.orientationMin = new Vector3 (0f, 0f, 0f);
                    _roundSparksEmitter.orientationMax = new Vector3 (0f, 0f, 2f * (float)Math.PI);
                    _roundSparksEmitter.angularVelocityMin = new Vector3 (0f, 0f, -0.25f);
                    _roundSparksEmitter.angularVelocityMax = new Vector3 (0f, 0f, +0.25f);
                    _roundSparksEmitter.radiusOffsetMin = 0f;
                    _roundSparksEmitter.radiusOffsetMax = 1f;

                    _roundSparksColorEffector.particleLifetime = _eParams.roundSparksDuration;
                    _roundSparksColorEffector.colorMask = _eParams.roundSparksColor;
                    _roundSparksColorEffector.keyframes.Clear();
                    _roundSparksColorEffector.keyframes.Add(0.1f, new Color4 (1f, 1f, 1f, 1f));
                    _roundSparksColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f));

                    _roundSparksScaleEffector.particleLifetime = _eParams.roundSparksDuration;
                    _roundSparksScaleEffector.keyframes.Clear();
                    _roundSparksScaleEffector.keyframes.Add(0f, 1f);
                    _roundSparksScaleEffector.keyframes.Add(0.25f, 3f);
                    _roundSparksScaleEffector.keyframes.Add(1f, 6f);
                } else if (_roundSparksEmitter != null) {
                    removeEmitter(_roundSparksEmitter);
                    removeEffector(_roundSparksColorEffector);
                    removeEffector(_roundSparksScaleEffector);
                    _roundSparksEmitter = null;
                    _roundSparksColorEffector = null;
                    _roundSparksScaleEffector = null;
                }
            }
Пример #12
0
            protected void configureFlash()
            {
                if (_eParams.doFlash) {
                    if (_flashEmitter == null) {
                        _flashEmitter = new SSParticlesFieldEmitter (new ParticlesSphereGenerator ());
                        _flashColorEffector = new SSColorKeyframesEffector ();
                        _flashScaleEffector = new SSMasterScaleKeyframesEffector ();
                        addEmitter(_flashEmitter);
                        addEffector(_flashColorEffector);
                        addEffector(_flashScaleEffector);
                        _flashEmitter.effectorMask = _flashColorEffector.effectorMask
                            = _flashScaleEffector.effectorMask = (ushort)ComponentMask.Flash;
                    }

                    _flashEmitter.spriteRectangles = _eParams.flashSprites;
                    _flashEmitter.particlesPerEmissionMin = 1;
                    _flashEmitter.particlesPerEmissionMax = 2;
                    _flashEmitter.emissionIntervalMin = 0f;
                    _flashEmitter.emissionIntervalMax = 0.2f * _eParams.flashDuration;
                    _flashEmitter.life = _eParams.flashDuration;
                    _flashEmitter.velocity = Vector3.Zero;
                    _flashEmitter.orientationMin = new Vector3 (0f, 0f, 0f);
                    _flashEmitter.orientationMax = new Vector3 (0f, 0f, 2f * (float)Math.PI);
                    _flashEmitter.billboardXY = true;
                    _flashEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()

                    _flashColorEffector.particleLifetime = _eParams.flashDuration;
                    _flashColorEffector.colorMask = _eParams.flashColor;
                    _flashColorEffector.keyframes.Clear();
                    _flashColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _flashColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f));

                    _flashScaleEffector.particleLifetime = _eParams.flashDuration;
                    _flashScaleEffector.keyframes.Clear();
                    _flashScaleEffector.keyframes.Add(0f, 1f);
                    _flashScaleEffector.keyframes.Add(1f, 1.5f);
                } else if (_flashEmitter != null) {
                    removeEmitter(_flashEmitter);
                    removeEffector(_flashColorEffector);
                    removeEffector(_flashScaleEffector);
                    _flashEmitter = null;
                    _flashColorEffector = null;
                    _flashScaleEffector = null;
                }
            }
Пример #13
0
            protected void configureFlyingSparks()
            {
                if (_eParams.doFlyingSparks) {
                    if (_flyingSparksEmitter == null) {
                        _flyingSparksEmitter = new SSRadialEmitter ();
                        _flyingSparksColorEffector = new SSColorKeyframesEffector ();
                        addEmitter(_flyingSparksEmitter);
                        addEffector(_flyingSparksColorEffector);
                        _flyingSparksEmitter.effectorMask = _flyingSparksColorEffector.effectorMask
                            = (ushort)ComponentMask.FlyingSparks;
                    }

                    _flyingSparksEmitter.spriteRectangles = _eParams.flyingSparksSprites;
                    _flyingSparksEmitter.emissionIntervalMin = 0f;
                    _flyingSparksEmitter.emissionIntervalMax = 0.1f * _eParams.flyingSparksDuration;
                    _flyingSparksEmitter.life = _eParams.flyingSparksDuration;
                    _flyingSparksEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()
                    _flyingSparksEmitter.componentScale = new Vector3 (5f, 1f, 1f);
                    _flyingSparksEmitter.color = _eParams.flyingSparksColor;

                    _flyingSparksColorEffector.colorMask = _eParams.flashColor;
                    _flyingSparksColorEffector.keyframes.Clear();
                    _flyingSparksColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _flyingSparksColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f));
                    _flyingSparksColorEffector.particleLifetime = _eParams.flyingSparksDuration;
                } else if (_flyingSparksEmitter != null) {
                    removeEmitter(_flyingSparksEmitter);
                    removeEffector(_flyingSparksColorEffector);
                    _flyingSparksEmitter = null;
                    _flyingSparksColorEffector = null;
                }
            }
Пример #14
0
            protected void configureFlameSmoke()
            {
                if (_eParams.doFlameSmoke) {
                    if (_flameSmokeEmitter == null) {
                        _flameSmokeEmitter = new SSRadialEmitter ();
                        _flamesSmokeColorEffector = new SSColorKeyframesEffector ();
                        _flameSmokeScaleEffector = new SSMasterScaleKeyframesEffector ();
                        addEmitter(_flameSmokeEmitter);
                        addEffector(_flamesSmokeColorEffector);
                        addEffector(_flameSmokeScaleEffector);
                        _flameSmokeEmitter.effectorMask = _flameSmokeScaleEffector.effectorMask
                            = _flamesSmokeColorEffector.effectorMask = (ushort)ComponentMask.FlameSmoke;
                    }

                    _flameSmokeEmitter.spriteRectangles = _eParams.flameSmokeSprites;
                    _flameSmokeEmitter.particlesPerEmission = 2;
                    _flameSmokeEmitter.emissionInterval = 0.03f * _eParams.flameSmokeDuration;
                    _flameSmokeEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()
                    _flameSmokeEmitter.life = _eParams.flameSmokeDuration;
                    _flameSmokeEmitter.orientationMin = new Vector3 (0f, 0f, 0f);
                    _flameSmokeEmitter.orientationMax = new Vector3 (0f, 0f, 2f * (float)Math.PI);
                    _flameSmokeEmitter.billboardXY = true;
                    _flameSmokeEmitter.angularVelocityMin = new Vector3 (0f, 0f, -0.5f);
                    _flameSmokeEmitter.angularVelocityMax = new Vector3 (0f, 0f, +0.5f);
                    _flameSmokeEmitter.radiusOffsetMin = 0f;
                    _flameSmokeEmitter.radiusOffsetMax = 0.5f;

                    _flamesSmokeColorEffector.colorMask = _eParams.flameColor;
                    _flamesSmokeColorEffector.particleLifetime = _eParams.flameSmokeDuration;
                    _flamesSmokeColorEffector.keyframes.Clear();
                    _flamesSmokeColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4 (0f, 0f, 0f, 0.5f));
                    _flamesSmokeColorEffector.keyframes.Add(1f, new Color4 (0f, 0f, 0f, 0f));

                    _flameSmokeScaleEffector.particleLifetime = _eParams.flameSmokeDuration;
                    _flameSmokeScaleEffector.keyframes.Clear();
                    _flameSmokeScaleEffector.keyframes.Add(0f, 0.1f);
                    _flameSmokeScaleEffector.keyframes.Add(0.25f, 1f);
                    _flameSmokeScaleEffector.keyframes.Add(1f, 1.2f);
                } else if (_flameSmokeEmitter != null) {
                    removeEmitter(_flameSmokeEmitter);
                    removeEffector(_flamesSmokeColorEffector);
                    removeEffector(_flameSmokeScaleEffector);
                    _flameSmokeEmitter = null;
                    _flamesSmokeColorEffector = null;
                    _flameSmokeScaleEffector = null;
                }
            }
Пример #15
0
            protected void configureDebris()
            {
                if (_eParams.doDebris) {
                    if (_debrisEmitter == null) {
                        _debrisEmitter = new SSRadialEmitter ();
                        _debrisColorEffector = new SSColorKeyframesEffector ();
                        addEmitter (_debrisEmitter);
                        addEffector (_debrisColorEffector);
                        _debrisEmitter.effectorMask = _debrisColorEffector.effectorMask
                            = (ushort)ComponentMask.Debris;
                    }
                    _debrisEmitter.spriteRectangles = _eParams.debrisSprites;
                    _debrisEmitter.particlesPerEmissionMin = 7;
                    _debrisEmitter.particlesPerEmissionMax = 10;
                    _debrisEmitter.totalEmissionsLeft = 0; // Control this in ShowExplosion()
                    _debrisEmitter.life = _eParams.debrisDuration;
                    _debrisEmitter.orientationMin = new Vector3 (0f, 0f, 0f);
                    _debrisEmitter.orientationMax = new Vector3 (0f, 0f, 2f * (float)Math.PI);
                    _debrisEmitter.billboardXY = true;
                    _debrisEmitter.angularVelocityMin = new Vector3 (0f, 0f, -0.5f);
                    _debrisEmitter.angularVelocityMax = new Vector3 (0f, 0f, +0.5f);
                    _debrisEmitter.radiusOffsetMin = 0f;
                    _debrisEmitter.radiusOffsetMax = 1f;

                    var debrisColorFinal = new Color4 (_eParams.debrisColorEnd.R,
                        _eParams.debrisColorEnd.G, _eParams.debrisColorEnd.B, 0f);
                    _debrisColorEffector.particleLifetime = _eParams.debrisDuration;
                    _debrisColorEffector.keyframes.Clear();
                    _debrisColorEffector.keyframes.Add(0f, _eParams.debrisColorStart);
                    _debrisColorEffector.keyframes.Add(0.3f, _eParams.debrisColorEnd);
                    _debrisColorEffector.keyframes.Add(1f, debrisColorFinal);
                } else if (_debrisEmitter != null) {
                    removeEmitter(_debrisEmitter);
                    removeEffector(_debrisColorEffector);
                    _debrisEmitter = null;
                    _debrisColorEffector = null;
                }
            }
Пример #16
0
        protected void _initParamsSpecific(SSpaceMissileVisualParameters mParams)
        {
            // smoke effectors
            if (_particleRenderer.textureMaterial == null)
            {
                _particleRenderer.textureMaterial = new SSTextureMaterial(mParams.smokeParticlesTexture());
            }
            if (_flameSmokeColorEffector == null)
            {
                _flameSmokeColorEffector = new SSColorKeyframesEffector();
                _flameSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _flameSmokeColorEffector.effectorMask      = (ushort)ParticleEffectorMasks.FlameToSmoke;
                _flameSmokeColorEffector.particleLifetime  = mParams.flameSmokeDuration;
                //_smokeColorEffector.colorMask = ;
                _flameSmokeColorEffector.keyframes.Clear();
                var flameColor = mParams.innerFlameColor;
                flameColor.A = 0.9f;
                _flameSmokeColorEffector.keyframes.Add(0f, flameColor);
                flameColor   = mParams.outerFlameColor;
                flameColor.A = 0.7f;
                _flameSmokeColorEffector.keyframes.Add(0.1f, flameColor);
                var smokeColor = mParams.smokeColor;
                smokeColor.A = 0.2f;
                _flameSmokeColorEffector.keyframes.Add(0.2f, smokeColor);
                smokeColor.A = 0f;
                _flameSmokeColorEffector.keyframes.Add(1f, smokeColor);

                _particlesData.addEffector(_flameSmokeColorEffector);
            }
            if (_ejectionSmokeColorEffector == null)
            {
                _ejectionSmokeColorEffector = new SSColorKeyframesEffector();
                _ejectionSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _ejectionSmokeColorEffector.effectorMask      = (ushort)ParticleEffectorMasks.EjectionSmoke;
                _ejectionSmokeColorEffector.particleLifetime  = mParams.flameSmokeDuration;
                _ejectionSmokeColorEffector.keyframes.Clear();
                var smokeColor = mParams.smokeColor;
                smokeColor.A = 0.3f;
                _ejectionSmokeColorEffector.keyframes.Add(0f, smokeColor);
                smokeColor.A = 0.14f;
                _ejectionSmokeColorEffector.keyframes.Add(0.2f, smokeColor);
                smokeColor.A = 0f;
                _ejectionSmokeColorEffector.keyframes.Add(1f, smokeColor);

                _particlesData.addEffector(_ejectionSmokeColorEffector);
            }
            if (_flameSmokeScaleEffector == null)
            {
                _flameSmokeScaleEffector = new SSMasterScaleKeyframesEffector();
                _flameSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _flameSmokeScaleEffector.effectorMask      = (ushort)ParticleEffectorMasks.FlameToSmoke;
                _flameSmokeScaleEffector.particleLifetime  = mParams.flameSmokeDuration;
                _flameSmokeScaleEffector.keyframes.Clear();
                _flameSmokeScaleEffector.keyframes.Add(0f, 0.3f);
                _flameSmokeScaleEffector.keyframes.Add(0.1f, 1f);
                _flameSmokeScaleEffector.keyframes.Add(1f, 2f);

                _particlesData.addEffector(_flameSmokeScaleEffector);
            }
            if (_ejectionSmokeScaleEffector == null)
            {
                _ejectionSmokeScaleEffector = new SSMasterScaleKeyframesEffector();
                _ejectionSmokeScaleEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                _ejectionSmokeScaleEffector.effectorMask      = (ushort)ParticleEffectorMasks.EjectionSmoke;
                _ejectionSmokeScaleEffector.particleLifetime  = mParams.ejectionSmokeDuration;
                _ejectionSmokeScaleEffector.keyframes.Clear();
                _ejectionSmokeScaleEffector.keyframes.Add(0f, 0.1f);
                _ejectionSmokeScaleEffector.keyframes.Add(0.35f, 0.8f);
                _ejectionSmokeScaleEffector.keyframes.Add(1f, 1.35f);

                _particlesData.addEffector(_ejectionSmokeScaleEffector);
            }
        }
Пример #17
0
            public HitSpotData(SLaser laser, ushort flameEffectorMask, ushort flashEffectorMask)
            {
                _laser = laser;
                int numBeams = _laser.parameters.numBeams;

                // initialize emitters
                _flashEmitters = new SSRadialEmitter[numBeams];
                _smokeEmitters = new SSRadialEmitter[numBeams];
                var laserParams = _laser.parameters;

                for (int i = 0; i < numBeams; ++i)
                {
                    // hit spot flame/smoke
                    {
                        var newFlameSmokeEmitter = new SSRadialEmitter();
                        newFlameSmokeEmitter.effectorMask         = flameEffectorMask;
                        newFlameSmokeEmitter.billboardXY          = true;
                        newFlameSmokeEmitter.phiMin               = (float)Math.PI / 3f;
                        newFlameSmokeEmitter.phiMax               = (float)Math.PI / 2f;
                        newFlameSmokeEmitter.spriteRectangles     = laserParams.flameSmokeSpriteRects;
                        newFlameSmokeEmitter.emissionInterval     = 1f / laserParams.flameSmokeEmitFrequency;
                        newFlameSmokeEmitter.componentScaleMin    = new Vector3(laserParams.flameSmokeScaleMin);
                        newFlameSmokeEmitter.componentScaleMax    = new Vector3(laserParams.flameSmokeScaleMax);
                        newFlameSmokeEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated
                        newFlameSmokeEmitter.life = laserParams.flameSmokeLifetime;
                        newFlameSmokeEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin;
                        newFlameSmokeEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax;
                        newFlameSmokeEmitter.thetaMin = 0f;
                        newFlameSmokeEmitter.thetaMax = (float)Math.PI * 2f;
                        newFlameSmokeEmitter.phiMin   = (float)Math.PI / 2f - 0.1f;
                        newFlameSmokeEmitter.phiMax   = (float)Math.PI / 2f + 0.1f;
                        _smokeEmitters[i]             = newFlameSmokeEmitter;
                    }
                    // hit spot flash
                    {
                        var newFlashEmitter = new SSRadialEmitter();
                        newFlashEmitter.effectorMask         = flashEffectorMask;
                        newFlashEmitter.billboardXY          = true;
                        newFlashEmitter.spriteRectangles     = laserParams.flashSpriteRects;
                        newFlashEmitter.emissionInterval     = 1f / laserParams.flashEmitFrequency;
                        newFlashEmitter.masterScaleMin       = laserParams.flashScaleMin;
                        newFlashEmitter.masterScaleMax       = laserParams.flashScaleMax;
                        newFlashEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated
                        newFlashEmitter.life = laserParams.flashLifetime;
                        //newFlashEmitter.colorPresets = Color4Helper.DebugPresets;
                        newFlashEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin;
                        newFlashEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax;
                        newFlashEmitter.thetaMin = 0f;
                        newFlashEmitter.thetaMax = (float)Math.PI * 2f;
                        newFlashEmitter.phiMin   = (float)Math.PI / 2f - 0.1f;
                        newFlashEmitter.phiMax   = (float)Math.PI / 2f + 0.1f;
                        _flashEmitters[i]        = newFlashEmitter;
                    }
                }

                {
                    // laser-specific flame/smoke effector
                    _flamesSmokeColorEffector = new SSColorKeyframesEffector();
                    _flamesSmokeColorEffector.effectorMask      = flameEffectorMask;
                    _flamesSmokeColorEffector.preRemoveHook     = _releaseSmokeParticle;
                    _flamesSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                    _flamesSmokeColorEffector.keyframes.Clear();
                    _flamesSmokeColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4(0f, 0f, 0f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(1f, new Color4(0f, 0f, 0f, 0f));
                    _flamesSmokeColorEffector.particleLifetime = laserParams.flameSmokeLifetime;
                }

                {
                    // laser-specific flash effector
                    _flashColorEffector = new SSColorKeyframesEffector();
                    _flashColorEffector.effectorMask      = flashEffectorMask;
                    _flashColorEffector.preRemoveHook     = _releaseFlashParticle;
                    _flashColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                    _flashColorEffector.keyframes.Clear();
                    _flashColorEffector.keyframes.Add(0f, new Color4(1f, 1f, 1f, 0.5f));
                    _flashColorEffector.keyframes.Add(1f, new Color4(1f, 1f, 1f, 0f));
                    _flashColorEffector.particleLifetime = laserParams.flashLifetime;
                }
            }
Пример #18
0
            protected void configureSmokeTrails()
            {
                if (_eParams.doSmokeTrails) {
                    if (_smokeTrailsEmitter == null) {
                        _smokeTrailsEmitter = new SSRadialEmitter ();
                        _smokeTrailsColorEffector = new SSColorKeyframesEffector ();
                        _smokeTrailsScaleEffector = new SSComponentScaleKeyframeEffector ();
                        addEmitter(_smokeTrailsEmitter);
                        addEffector(_smokeTrailsColorEffector);
                        addEffector(_smokeTrailsScaleEffector);
                        _smokeTrailsEmitter.effectorMask = _smokeTrailsColorEffector.effectorMask
                            = _smokeTrailsScaleEffector.effectorMask = (ushort)ComponentMask.SmokeTrails;
                    }

                    _smokeTrailsEmitter.radiusOffset = 3f;
                    _smokeTrailsEmitter.spriteRectangles = _eParams.smokeTrailsSprites;
                    _smokeTrailsEmitter.particlesPerEmission = 16;
                    _smokeTrailsEmitter.emissionIntervalMin = 0f;
                    _smokeTrailsEmitter.emissionIntervalMax = 0.1f * _eParams.smokeTrailsDuration;
                    _smokeTrailsEmitter.life = _eParams.smokeTrailsDuration;
                    _smokeTrailsEmitter.totalEmissionsLeft = 0; // control this in ShowExplosion()
                    _smokeTrailsEmitter.color = _eParams.smokeTrailsColor;

                    _smokeTrailsColorEffector.particleLifetime = _eParams.smokeTrailsDuration;
                    _smokeTrailsColorEffector.colorMask = _eParams.smokeTrailsColor;
                    _smokeTrailsColorEffector.keyframes.Clear();
                    _smokeTrailsColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _smokeTrailsColorEffector.keyframes.Add(1f, new Color4 (0.3f, 0.3f, 0.3f, 0f));

                    _smokeTrailsScaleEffector.particleLifetime = _eParams.smokeTrailsDuration;
                    _smokeTrailsScaleEffector.baseOffset = new Vector3 (1f, 1f, 1f);
                    _smokeTrailsScaleEffector.keyframes.Clear();
                    _smokeTrailsScaleEffector.keyframes.Add(0f, new Vector3 (0f));
                    _smokeTrailsScaleEffector.keyframes.Add(0.5f, new Vector3 (12f, 1.5f, 0f));
                    _smokeTrailsScaleEffector.keyframes.Add(1f, new Vector3 (7f, 2f, 0f));
                } else if (_smokeTrailsEmitter != null) {
                    removeEmitter(_smokeTrailsEmitter);
                    removeEffector(_smokeTrailsColorEffector);
                    removeEffector(_smokeTrailsScaleEffector);
                    _smokeTrailsEmitter = null;
                    _smokeTrailsColorEffector = null;
                    _smokeTrailsScaleEffector = null;
                }
            }
Пример #19
0
            protected void configureShockwave()
            {
                if (_eParams.doShockwave) {
                    if (_shockwaveEmitter == null) {
                        _shockwaveEmitter = new ShockwaveEmitter ();
                        _shockwaveColorEffector = new SSColorKeyframesEffector ();
                        _shockwaveScaleEffector = new SSMasterScaleKeyframesEffector ();
                        addEmitter(_shockwaveEmitter);
                        addEffector(_shockwaveScaleEffector);
                        addEffector(_shockwaveColorEffector);
                        _shockwaveEmitter.effectorMask = _shockwaveScaleEffector.effectorMask
                            = _shockwaveColorEffector.effectorMask = (ushort)ComponentMask.Shockwave;
                    }
                    _shockwaveEmitter.spriteRectangles = _eParams.shockwaveSprites;
                    _shockwaveEmitter.particlesPerEmission = 1;
                    _shockwaveEmitter.totalEmissionsLeft = 0;   // Control this in ShowExplosion()
                    _shockwaveEmitter.life = _eParams.shockwaveDuration;
                    _shockwaveEmitter.velocity = Vector3.Zero;

                    _shockwaveScaleEffector.particleLifetime = _eParams.shockwaveDuration;
                    _shockwaveScaleEffector.keyframes.Clear();
                    _shockwaveScaleEffector.keyframes.Add(0f, 0f);
                    _shockwaveScaleEffector.keyframes.Add(_eParams.shockwaveDuration, 7f);

                    _shockwaveColorEffector.colorMask = _eParams.shockwaveColor;
                    _shockwaveColorEffector.particleLifetime = _eParams.shockwaveDuration;
                    _shockwaveColorEffector.keyframes.Clear();
                    _shockwaveColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _shockwaveColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f));
                } else if (_shockwaveEmitter != null) {
                    removeEmitter(_shockwaveEmitter);
                    removeEffector(_shockwaveColorEffector);
                    removeEffector(_shockwaveScaleEffector);
                    _shockwaveEmitter = null;
                    _shockwaveColorEffector = null;
                    _shockwaveScaleEffector = null;
                }
            }
Пример #20
0
            public HitSpotData(SLaser laser, ushort flameEffectorMask, ushort flashEffectorMask)
            {
                _laser = laser;
                int numBeams = _laser.parameters.numBeams;

                // initialize emitters
                _flashEmitters = new SSRadialEmitter[numBeams];
                _smokeEmitters = new SSRadialEmitter[numBeams];
                var laserParams = _laser.parameters;

                for (int i = 0; i < numBeams; ++i) {
                    // hit spot flame/smoke
                    {
                        var newFlameSmokeEmitter = new SSRadialEmitter();
                        newFlameSmokeEmitter.effectorMask = flameEffectorMask;
                        newFlameSmokeEmitter.billboardXY = true;
                        newFlameSmokeEmitter.phiMin = (float)Math.PI/3f;
                        newFlameSmokeEmitter.phiMax = (float)Math.PI/2f;
                        newFlameSmokeEmitter.spriteRectangles = laserParams.flameSmokeSpriteRects;
                        newFlameSmokeEmitter.emissionInterval = 1f / laserParams.flameSmokeEmitFrequency;
                        newFlameSmokeEmitter.componentScaleMin = new Vector3(laserParams.flameSmokeScaleMin);
                        newFlameSmokeEmitter.componentScaleMax = new Vector3(laserParams.flameSmokeScaleMax);
                        newFlameSmokeEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated
                        newFlameSmokeEmitter.life = laserParams.flameSmokeLifetime;
                        newFlameSmokeEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin;
                        newFlameSmokeEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax;
                        newFlameSmokeEmitter.thetaMin = 0f;
                        newFlameSmokeEmitter.thetaMax = (float)Math.PI * 2f;
                        newFlameSmokeEmitter.phiMin = (float)Math.PI/2f-0.1f;
                        newFlameSmokeEmitter.phiMax = (float)Math.PI/2f+0.1f;
                        _smokeEmitters[i] = newFlameSmokeEmitter;
                    }
                    // hit spot flash
                    {
                        var newFlashEmitter = new SSRadialEmitter();
                        newFlashEmitter.effectorMask = flashEffectorMask;
                        newFlashEmitter.billboardXY = true;
                        newFlashEmitter.spriteRectangles = laserParams.flashSpriteRects;
                        newFlashEmitter.emissionInterval = 1f / laserParams.flashEmitFrequency;
                        newFlashEmitter.masterScaleMin = laserParams.flashScaleMin;
                        newFlashEmitter.masterScaleMax = laserParams.flashScaleMax;
                        newFlashEmitter.particlesPerEmission = 0; // init to 0 to not emit until updated
                        newFlashEmitter.life = laserParams.flashLifetime;
                        //newFlashEmitter.colorPresets = Color4Helper.DebugPresets;
                        newFlashEmitter.velocityFromCenterMagnitudeMin = laserParams.spriteVelocityTowardsCameraMin;
                        newFlashEmitter.velocityFromCenterMagnitudeMax = laserParams.spriteVelocityTowardsCameraMax;
                        newFlashEmitter.thetaMin = 0f;
                        newFlashEmitter.thetaMax = (float)Math.PI * 2f;
                        newFlashEmitter.phiMin = (float)Math.PI/2f-0.1f;
                        newFlashEmitter.phiMax = (float)Math.PI/2f+0.1f;
                        _flashEmitters[i] = newFlashEmitter;
                    }
                }

                {
                   // laser-specific flame/smoke effector
                    _flamesSmokeColorEffector = new SSColorKeyframesEffector ();
                    _flamesSmokeColorEffector.effectorMask = flameEffectorMask;
                    _flamesSmokeColorEffector.preRemoveHook = _releaseSmokeParticle;
                    _flamesSmokeColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                    _flamesSmokeColorEffector.keyframes.Clear();
                    _flamesSmokeColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(0.4f, new Color4 (0f, 0f, 0f, 1f));
                    _flamesSmokeColorEffector.keyframes.Add(1f, new Color4 (0f, 0f, 0f, 0f));
                    _flamesSmokeColorEffector.particleLifetime = laserParams.flameSmokeLifetime;
                }

                {
                    // laser-specific flash effector
                    _flashColorEffector = new SSColorKeyframesEffector ();
                    _flashColorEffector.effectorMask = flashEffectorMask;
                    _flashColorEffector.preRemoveHook = _releaseFlashParticle;
                    _flashColorEffector.maskMatchFunction = SSParticleEffector.MatchFunction.Equals;
                    _flashColorEffector.keyframes.Clear();
                    _flashColorEffector.keyframes.Add(0f, new Color4 (1f, 1f, 1f, 0.5f));
                    _flashColorEffector.keyframes.Add(1f, new Color4 (1f, 1f, 1f, 0f));
                    _flashColorEffector.particleLifetime = laserParams.flashLifetime;
                }
            }