Пример #1
0
    protected virtual void GetParticleSystem()
    {
        _particleSystem  = GetComponentInChildren <ParticleSystem>();
        particleRenderer = GetComponentInChildren <ParticleSystemRenderer>();

        // Modules - for ease of access
        mainModule                  = _particleSystem.main;
        collisionModule             = _particleSystem.collision;
        colorBySpeedModule          = _particleSystem.colorBySpeed;
        colorOverTimeModule         = _particleSystem.colorOverLifetime;
        customDataModule            = _particleSystem.customData;
        emissionModule              = _particleSystem.emission;
        externalForcesModule        = _particleSystem.externalForces;
        forceOverTimeModule         = _particleSystem.forceOverLifetime;
        inheritVelocityModule       = _particleSystem.inheritVelocity;
        lightsModule                = _particleSystem.lights;
        limitVelocityOverTimeModule = _particleSystem.limitVelocityOverLifetime;
        noiseModule                 = _particleSystem.noise;
        rotationBySpeedModule       = _particleSystem.rotationBySpeed;
        sizeBySpeedModule           = _particleSystem.sizeBySpeed;
        sizeOverTimeModule          = _particleSystem.sizeOverLifetime;
        trailModule                 = _particleSystem.trails;
        triggerModule               = _particleSystem.trigger;
        shapeModule                 = _particleSystem.shape;
        velOverTimeModule           = _particleSystem.velocityOverLifetime;
    }
        // Use this for initialization
        void Start()
        {
            string[] bandNames =
            {
                "Sub Base",
                "Bass",
                "Low Midrange",
                "Midrange",
                "Upper Midrange",
                "Low Presence",
                "Presence",
                "Brilliance"
            };
            _emissionModules    = new ParticleSystem.EmissionModule[_numberOfParticleGenerators];
            _shapeModules       = new ParticleSystem.ShapeModule[_numberOfParticleGenerators];
            _mainModules        = new ParticleSystem.MainModule[_numberOfParticleGenerators];
            _particleGenerators = new GameObject[_numberOfParticleGenerators];
            _noiseModules       = new ParticleSystem.NoiseModule[_numberOfParticleGenerators];
            float offset = -14;

            for (int i = 0; i < _numberOfParticleGenerators; i++)
            {
                GameObject             go = new GameObject(bandNames[i]);
                ParticleSystem         particleGenerator = go.AddComponent <ParticleSystem>();
                ParticleSystemRenderer particleRenderer  =
                    (ParticleSystemRenderer)particleGenerator.GetComponent <Renderer>();

                ExtractModules(i, particleGenerator);

                ParticleSystem.LightsModule lm = particleGenerator.lights;
                lm.enabled          = true;
                lm.light            = ParticleLight;
                lm.ratio            = 1;
                lm.useParticleColor = true;

                ParticleSystem.TrailModule trm = particleGenerator.trails;
                trm.enabled  = true;
                trm.lifetime = 0.1f;

                ParticleSystem.ExternalForcesModule em = particleGenerator.externalForces;
                em.enabled    = true;
                em.multiplier = 0.5f;

                particleRenderer.renderMode    = ParticleSystemRenderMode.Mesh;
                particleRenderer.mesh          = Resources.GetBuiltinResource <Mesh>("Sphere.fbx");
                particleRenderer.material      = ParticleMaterial;
                particleRenderer.trailMaterial = TrailMaterial;

                Vector3 pos = new Vector3(offset + 4 * i, 0, 0);
                go.transform.position  = transform.TransformPoint(transform.position + pos);
                go.transform.parent    = transform;
                _particleGenerators[i] = go;
            }

            InitializeMainModules();
            InitializeEmissionModules();
            InitializeNoiseModules();
            InitializeShapeModules();
        }
Пример #3
0
 protected override void ReadFromImpl(object obj)
 {
     base.ReadFromImpl(obj);
     ParticleSystem.ExternalForcesModule uo = (ParticleSystem.ExternalForcesModule)obj;
     enabled         = uo.enabled;
     multiplier      = uo.multiplier;
     influenceFilter = uo.influenceFilter;
 }
Пример #4
0
 protected override object WriteToImpl(object obj)
 {
     obj = base.WriteToImpl(obj);
     ParticleSystem.ExternalForcesModule uo = (ParticleSystem.ExternalForcesModule)obj;
     uo.enabled         = enabled;
     uo.multiplier      = multiplier;
     uo.influenceFilter = influenceFilter;
     return(uo);
 }
Пример #5
0
    //private ParchingRice[] rice;

    public override void Start()
    {
        base.Start();

        //rice = FindObjectsOfType<ParchingRice>();

        riceWind        = rice.externalForces;
        parchedEmmision = parchedRice.emission;
    }
Пример #6
0
 public void Set(float t, GameObject obj)
 {
     psef = GetComponent <ParticleSystem>().externalForces;
     em   = GetComponent <ParticleSystem>().emission;
     psef.RemoveAllInfluences();
     psef.AddInfluence(obj.GetComponent <ParticleSystemForceField>());
     evokeTime = t;
     em.rateOverTimeMultiplier = 15F;
     StartCoroutine(EffectCoroutine());
 }
Пример #7
0
    static void WriteParticleSystemExternalForces(ParticleSystem.ExternalForcesModule module)
    {
        m_writer.Write(module.enabled);
        if (!module.enabled)
        {
            return;
        }

        m_writer.Write(module.multiplier);
    }
Пример #8
0
    void Start()
    {
        _ps = GetComponent <ParticleSystem>();

        _emission       = _ps.emission;
        _externalForces = _ps.externalForces;
        _noise          = _ps.noise;
        _shape          = _ps.shape;

        _shape.texture         = textures[_textureIndex];
        _emission.rateOverTime = 0;
    }
Пример #9
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag(StringConstants.Tags.Player))
        {
            ParticleSystem.ExternalForcesModule efm = crystalParticles.externalForces;
            efm.enabled = true;

            ParticleSystem.ColorOverLifetimeModule colm = crystalParticles.colorOverLifetime;
            colm.enabled = true;

            DisableParticleSystems();
        }
    }
        public override void GetDepsFrom(object obj, GetDepsFromContext context)
        {
            base.GetDepsFrom(obj, context);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.ExternalForcesModule o = (ParticleSystem.ExternalForcesModule)obj;
            for (int i = 0; i < o.influenceCount; ++i)
            {
                AddDep(o.GetInfluence(i), context);
            }
        }
Пример #11
0
        private void MapExternalForcesParameters(ParticleSystem pSystem, int i)
        {
            ParticleSystem.ExternalForcesModule externalForcesModule = pSystem.externalForces;

            try {
                externalForcesModule.enabled = GetBoolParam(i, "externalForces_enabled");
            }
            catch (NullReferenceException) {
                externalForcesModule.enabled = false;
                return;
            }

            externalForcesModule.multiplier = GetFloatParam(i, "externalForces_multiplier");
        }
Пример #12
0
    void Start()
    {
        var ps = GetComponent <ParticleSystem>();

        _emission         = ps.emission;
        _originalEmission = _emission.rateOverTime.constant;

        _shape          = ps.shape;
        _originalRadius = _shape.radius;

        _noise         = ps.noise;
        _originalNoise = _noise.strength.constant;

        _force = ps.externalForces;
    }
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.ExternalForcesModule o = (ParticleSystem.ExternalForcesModule)obj;
            m_influences = new long[o.influenceCount];
            for (int i = 0; i < m_influences.Length; ++i)
            {
                ParticleSystemForceField forceField = o.GetInfluence(i);
                m_influences[i] = ToID(forceField);
            }
        }
        public override object WriteTo(object obj)
        {
            obj = base.WriteTo(obj);
            if (obj == null)
            {
                return(null);
            }

            ParticleSystem.ExternalForcesModule o = (ParticleSystem.ExternalForcesModule)obj;
            if (m_influences != null)
            {
                for (int i = 0; i < m_influences.Length; ++i)
                {
                    ParticleSystemForceField forceField = FromID <ParticleSystemForceField>(m_influences[i]);
                    if (forceField != null)
                    {
                        o.AddInfluence(forceField);
                    }
                }
            }

            return(obj);
        }
Пример #15
0
        internal static GameObject CreateSmallAmmoTracer(Material mainMat, Material trailMat)
        {
            GameObject obj = PrefabsCore.CreatePrefab("Standard Tracer", false);

            Transform tracerHead = new GameObject("TracerHead").transform;

            tracerHead.parent        = obj.transform;
            tracerHead.localPosition = Vector3.zero;
            tracerHead.localRotation = Quaternion.identity;
            //tracerHead.localEulerAngles = new Vector3( 0f, 90f, 0f );
            tracerHead.localScale = Vector3.one;

            Transform tracerTail = new GameObject("TracerTail").transform;

            tracerTail.parent        = obj.transform;
            tracerTail.localPosition = Vector3.zero;
            tracerTail.localRotation = Quaternion.identity;
            tracerTail.localScale    = Vector3.one;



            Transform trail = new GameObject("trail").transform;

            trail.parent        = tracerTail;
            trail.localPosition = Vector3.zero;
            trail.localRotation = Quaternion.identity;
            trail.localScale    = Vector3.one;


            Transform headBeam = new GameObject("HeadBeam").transform;

            headBeam.parent           = tracerTail;
            headBeam.localPosition    = Vector3.zero;
            headBeam.localEulerAngles = new Vector3(0f, 90f, 0f);
            headBeam.localScale       = Vector3.one;

            EffectComponent effectComp = obj.AddComponent <EffectComponent>();

            Tracer tracer = obj.AddComponent <Tracer>();

            VFXAttributes vfxAtrib = obj.AddComponent <VFXAttributes>();

            Rigidbody headRb = tracerHead.AddComponent <Rigidbody>();

            Rigidbody tailRb = tracerTail.AddComponent <Rigidbody>();

            ParticleSystem mainPs = headBeam.AddComponent <ParticleSystem>();

            ParticleSystemRenderer mainPsr = headBeam.AddOrGetComponent <ParticleSystemRenderer>();

            ParticleSystem trailPs = trail.AddComponent <ParticleSystem>();

            ParticleSystemRenderer trailPsr = trail.AddOrGetComponent <ParticleSystemRenderer>();

            DestroyTracerOnDelay cleanup = obj.AddComponent <DestroyTracerOnDelay>();

            cleanup.delay  = 2f;
            cleanup.tracer = tracer;

            ZeroTracerLengthOverDuration zeroLength = obj.AddComponent <ZeroTracerLengthOverDuration>();

            zeroLength.tracer = tracer;

            DestroyOnTimer timer = obj.AddComponent <DestroyOnTimer>();

            timer.duration = 10f;


            effectComp.effectIndex = EffectIndex.Invalid;
            effectComp.positionAtReferencedTransform = false;
            effectComp.parentToReferencedTransform   = false;
            effectComp.applyScale      = false;
            effectComp.soundName       = null;
            effectComp.disregardZScale = false;


            tracer.startTransform = null;
            tracer.beamObject     = null;
            tracer.beamDensity    = 0f;
            tracer.speed          = 600f;
            tracer.headTransform  = tracerHead;
            tracer.tailTransform  = tracerTail;
            tracer.length         = 20f;
            tracer.reverse        = false;

            headRb.isKinematic = true;
            headRb.useGravity  = false;

            tailRb.isKinematic = true;
            tailRb.useGravity  = false;

            vfxAtrib.optionalLights          = null;
            vfxAtrib.secondaryParticleSystem = null;
            vfxAtrib.vfxIntensity            = VFXAttributes.VFXIntensity.Low;
            vfxAtrib.vfxPriority             = VFXAttributes.VFXPriority.Always;

            mainPs.PlayOnStart();
            mainPs.SetupSmallTracerMain();
            mainPs.SetupSmallTracerEmission();
            mainPs.SetupSmallTracerShape();
            mainPs.SetupSmallTracerColorOverLifetime();
            mainPs.SetupSmallTracerSizeOverLifetime();
            mainPsr.SetupSmallTracerRenderer(mainMat);

            ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime;
            mainPsVol.enabled = false;
            ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime;
            mainPsLvol.enabled = false;
            ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity;
            mainPsIvel.enabled = false;
            ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime;
            mainPsFol.enabled = false;
            ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed;
            mainPsCbs.enabled = false;
            ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed;
            mainPsSbs.enabled = false;
            ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime;
            mainPsRol.enabled = false;
            ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed;
            mainPsRbs.enabled = false;
            ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces;
            mainPsExt.enabled = false;
            ParticleSystem.NoiseModule mainPsNoise = mainPs.noise;
            mainPsNoise.enabled = false;
            ParticleSystem.CollisionModule mainPsColl = mainPs.collision;
            mainPsColl.enabled = false;
            ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger;
            mainPsTrig.enabled = false;
            ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters;
            mainPsSub.enabled = false;
            ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation;
            mainPsTex.enabled = false;
            ParticleSystem.LightsModule mainPsLight = mainPs.lights;
            mainPsLight.enabled = false;
            ParticleSystem.TrailModule mainPsTrail = mainPs.trails;
            mainPsTrail.enabled = false;
            ParticleSystem.CustomDataModule mainPsData = mainPs.customData;
            mainPsData.enabled = false;


            trailPs.PlayOnStart();

            trailPs.SetupSmallTracerTrailMain();
            trailPs.SetupSmallTracerTrailEmission();
            trailPs.SetupSmallTracerTrailNoise();
            trailPs.SetupSmallTracerTrailTrail();
            trailPsr.SetupSmallTracerTrailRenderer(trailMat);

            ParticleSystem.ShapeModule trailPsShape = trailPs.shape;
            trailPsShape.enabled = false;
            ParticleSystem.VelocityOverLifetimeModule trailPsVol = trailPs.velocityOverLifetime;
            trailPsVol.enabled = false;
            ParticleSystem.LimitVelocityOverLifetimeModule trailPsLvol = trailPs.limitVelocityOverLifetime;
            trailPsLvol.enabled = false;
            ParticleSystem.InheritVelocityModule trailPsIvel = trailPs.inheritVelocity;
            trailPsIvel.enabled = false;
            ParticleSystem.ForceOverLifetimeModule trailPsFol = trailPs.forceOverLifetime;
            trailPsFol.enabled = false;
            ParticleSystem.ColorOverLifetimeModule trailPsCol = trailPs.colorOverLifetime;
            trailPsCol.enabled = false;
            ParticleSystem.ColorBySpeedModule trailPsCbs = trailPs.colorBySpeed;
            trailPsCbs.enabled = false;
            ParticleSystem.SizeOverLifetimeModule trailPsSol = trailPs.sizeOverLifetime;
            trailPsSol.enabled = false;
            ParticleSystem.SizeBySpeedModule trailPsSbs = trailPs.sizeBySpeed;
            trailPsSbs.enabled = false;
            ParticleSystem.RotationOverLifetimeModule trailPsRol = trailPs.rotationOverLifetime;
            trailPsRol.enabled = false;
            ParticleSystem.RotationBySpeedModule trailPsRbs = trailPs.rotationBySpeed;
            trailPsRbs.enabled = false;
            ParticleSystem.ExternalForcesModule trailPsExt = trailPs.externalForces;
            trailPsExt.enabled = false;
            ParticleSystem.NoiseModule trailPsNoise = trailPs.noise;
            trailPsNoise.enabled = true;
            ParticleSystem.CollisionModule trailPsColl = trailPs.collision;
            trailPsColl.enabled = false;
            ParticleSystem.TriggerModule trailPsTrig = trailPs.trigger;
            trailPsTrig.enabled = false;
            ParticleSystem.SubEmittersModule trailPsSub = trailPs.subEmitters;
            trailPsSub.enabled = false;
            ParticleSystem.TextureSheetAnimationModule trailPsTex = trailPs.textureSheetAnimation;
            trailPsTex.enabled = false;
            ParticleSystem.LightsModule trailPsLigh = trailPs.lights;
            trailPsLigh.enabled = false;
            ParticleSystem.CustomDataModule trailPsData = trailPs.customData;
            trailPsData.enabled = false;

            return(obj);
        }
Пример #16
0
        internal ParticleElementTemplate(ParticleElement element)
        {
            this.element  = element;
            this.partSys  = element.partSys;
            this.partRend = element.partRend;


            this.main = this.partSys.main;


            this.collision         = this.partSys.collision;
            this.collision.enabled = false;

            this.colorBySpeed         = this.partSys.colorBySpeed;
            this.colorBySpeed.enabled = false;

            this.colorOverLifetime         = this.partSys.colorOverLifetime;
            this.colorOverLifetime.enabled = false;

            this.customData         = this.partSys.customData;
            this.customData.enabled = false;

            this.emission         = this.partSys.emission;
            this.emission.enabled = false;

            this.externalForces         = this.partSys.externalForces;
            this.externalForces.enabled = false;

            this.forceOverLifetime         = this.partSys.forceOverLifetime;
            this.forceOverLifetime.enabled = false;

            this.inheritVelocity         = this.partSys.inheritVelocity;
            this.inheritVelocity.enabled = false;

            this.lights         = this.partSys.lights;
            this.lights.enabled = false;

            this.limitVelocityOverLifetime         = this.partSys.limitVelocityOverLifetime;
            this.limitVelocityOverLifetime.enabled = false;

            this.noise         = this.partSys.noise;
            this.noise.enabled = false;

            this.rotationBySpeed         = this.partSys.rotationBySpeed;
            this.rotationBySpeed.enabled = false;

            this.rotationOverLifetime         = this.partSys.rotationOverLifetime;
            this.rotationOverLifetime.enabled = false;

            this.shape         = this.partSys.shape;
            this.shape.enabled = false;

            this.sizeBySpeed         = this.partSys.sizeBySpeed;
            this.sizeBySpeed.enabled = false;

            this.sizeOverLifetime         = this.partSys.sizeOverLifetime;
            this.sizeOverLifetime.enabled = false;

            this.subEmitters         = this.partSys.subEmitters;
            this.subEmitters.enabled = false;

            this.textureSheetAnimation         = this.partSys.textureSheetAnimation;
            this.textureSheetAnimation.enabled = false;

            this.trails         = this.partSys.trails;
            this.trails.enabled = false;

            this.trigger         = this.partSys.trigger;
            this.trigger.enabled = false;

            this.velocityOverLifetime         = this.partSys.velocityOverLifetime;
            this.velocityOverLifetime.enabled = false;
        }
    void Setup()
    {
        if (ObjetMesh == null)
        {
            ObjetMesh = transform.parent.gameObject;
        }

        MeshToCopy             = ObjetMesh.GetComponent <MeshFilter>().sharedMesh;
        MeshRendererToCopy     = ObjetMesh.GetComponent <MeshRenderer>();
        ParticleSystemRenderer = GetComponent <ParticleSystemRenderer>();

        Particules = GetComponent <ParticleSystem>();
        ParticleSystem.MinMaxCurve minMax = new ParticleSystem.MinMaxCurve(startLifetime.x, startLifetime.y);

        //
        //MAIN MODULE
        ModuleMain               = Particules.main;
        ModuleMain.startSpeed    = startSpeed;
        ModuleMain.startLifetime = minMax;
        ModuleMain.maxParticles  = LimitMax;
        ParticleSystem.MinMaxGradient minMaxGradient = new ParticleSystem.MinMaxGradient(Couleur1, Couleur2);
        ModuleMain.startColor      = minMaxGradient;
        ModuleMain.simulationSpace = ParticleSystemSimulationSpace.World;
        //ModuleMain.customSimulationSpace = transform;
        ModuleMain.startSize = startSize;

        //
        // EMISSION MODULE
        ModuleEmission = Particules.emission;
        ModuleEmission.rateOverTime = RateOverTIme;

        //
        // SIZE OVER LIFETIME MODULE
        ModuleSizeOverLifetime         = Particules.sizeOverLifetime;
        ModuleSizeOverLifetime.enabled = true;
        Keyframe[]     KeysMin = { new Keyframe(0, 0), new Keyframe(0.2f, 0.3f), new Keyframe(0.8f, 0.3f), new Keyframe(1, 0) };
        Keyframe[]     KeysMax = { new Keyframe(0, 0), new Keyframe(0.2f, 1), new Keyframe(0.8f, 1), new Keyframe(1, 0) };
        AnimationCurve min     = new AnimationCurve(KeysMin);
        AnimationCurve max     = new AnimationCurve(KeysMax);

        ParticleSystem.MinMaxCurve minMaxCurve = new ParticleSystem.MinMaxCurve(1, min, max);
        ModuleSizeOverLifetime.size = minMaxCurve;

        //
        // SHAPE MODULE
        ModuleShape               = Particules.shape;
        ModuleShape.shapeType     = ParticleSystemShapeType.MeshRenderer;
        ModuleShape.meshShapeType = ParticleSystemMeshShapeType.Vertex;
        ModuleShape.useMeshColors = false;
        ModuleShape.meshRenderer  = MeshRendererToCopy;
        ModuleShape.meshShapeType = MeshShapeType;
        //
        // RENDERER MODULE
        ParticleSystemRenderer.material = ParticuleMaterial;

        //
        // EXTERNAL FORCE MODULE
        ModuleExternalForce                 = Particules.externalForces;
        ModuleExternalForce.enabled         = true;
        ModuleExternalForce.influenceFilter = ParticleSystemGameObjectFilter.LayerMask;
        ModuleExternalForce.multiplier      = WindZoneMultiplier;
    }
    protected void InitializeParticleSystem(ParticleSystem ps, ParticleSystemRenderer renderer, int max_particles)
    {
        ParticleSystem.MainModule main = ps.main;
        main.loop         = false;
        main.playOnAwake  = false;
        main.maxParticles = max_particles;
        main.startColor   = new ParticleSystem.MinMaxGradient(new Color(1.0f, 1.0f, 1.0f, 0.0f));

        renderer.sortMode            = ParticleSystemSortMode.Distance;
        renderer.shadowCastingMode   = UnityEngine.Rendering.ShadowCastingMode.Off;
        renderer.receiveShadows      = false;
        renderer.enableGPUInstancing = true;

        Material particleMaterial = new Material(Shader.Find(shader));

        renderer.material = particleMaterial;

        PrepareMaterial(particleMaterial);

        particleMaterial.SetColor("_Color", new Color(1.0f, 1.0f, 1.0f, 1.0f));
        particleMaterial.SetColor("_EmissionColor", new Color(0.8f, 0.8f, 0.8f, 1.0f));

        ParticleSystem.EmissionModule em = ps.emission;
        em.enabled = false;
        ParticleSystem.ShapeModule sh = ps.shape;
        sh.enabled = false;
        ParticleSystem.VelocityOverLifetimeModule vol = ps.velocityOverLifetime;
        vol.enabled = false;
        ParticleSystem.LimitVelocityOverLifetimeModule lvol = ps.limitVelocityOverLifetime;
        lvol.enabled = false;
        ParticleSystem.InheritVelocityModule ivm = ps.inheritVelocity;
        ivm.enabled = false;
        ParticleSystem.ForceOverLifetimeModule fol = ps.forceOverLifetime;
        fol.enabled = false;
        ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime;
        col.enabled = false;
        ParticleSystem.ColorBySpeedModule cbs = ps.colorBySpeed;
        cbs.enabled = false;
        ParticleSystem.SizeOverLifetimeModule sol = ps.sizeOverLifetime;
        sol.enabled = false;
        ParticleSystem.SizeBySpeedModule sbs = ps.sizeBySpeed;
        sbs.enabled = false;
        ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime;
        rol.enabled = false;
        ParticleSystem.RotationBySpeedModule rbs = ps.rotationBySpeed;
        rbs.enabled = false;
        ParticleSystem.ExternalForcesModule extf = ps.externalForces;
        extf.enabled = false;
        ParticleSystem.NoiseModule noise = ps.noise;
        noise.enabled = false;
        ParticleSystem.CollisionModule collision = ps.collision;
        collision.enabled = false;
        ParticleSystem.TriggerModule triggers = ps.trigger;
        triggers.enabled = false;
        ParticleSystem.SubEmittersModule subem = ps.subEmitters;
        subem.enabled = false;
        ParticleSystem.TextureSheetAnimationModule tsa = ps.textureSheetAnimation;
        tsa.enabled = false;
        ParticleSystem.LightsModule lights = ps.lights;
        lights.enabled = false;
        ParticleSystem.CustomDataModule cd = ps.customData;
        cd.enabled = false;
    }
Пример #19
0
        internal static GameObject CreatePlasmaBurnPrefab()
        {
            var obj = PrefabsCore.CreatePrefab("PlasmaBurn", false);

            var holder = new GameObject("Particles");

            holder.transform.parent = obj.transform;

            var mainPs  = holder.AddComponent <ParticleSystem>();
            var mainPsr = holder.AddOrGetComponent <ParticleSystemRenderer>();

            mainPs
            .BurnMain()
            .BurnEmission()
            .BurnShape()
            .BurnCOL()
            .BurnSOL();

            mainPsr
            .BurnRenderer();


            ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime;
            mainPsVol.enabled = false;
            ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime;
            mainPsLvol.enabled = false;
            ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity;
            mainPsIvel.enabled = false;
            ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime;
            mainPsFol.enabled = false;
            ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed;
            mainPsCbs.enabled = false;
            ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed;
            mainPsSbs.enabled = false;
            ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime;
            mainPsRol.enabled = false;
            ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed;
            mainPsRbs.enabled = false;
            ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces;
            mainPsExt.enabled = false;
            ParticleSystem.NoiseModule mainPsNoise = mainPs.noise;
            mainPsNoise.enabled = false;
            ParticleSystem.CollisionModule mainPsColl = mainPs.collision;
            mainPsColl.enabled = false;
            ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger;
            mainPsTrig.enabled = false;
            ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters;
            mainPsSub.enabled = false;
            ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation;
            mainPsTex.enabled = false;
            ParticleSystem.LightsModule mainPsLigh = mainPs.lights;
            mainPsLigh.enabled = false;
            ParticleSystem.TrailModule mainPsTrail = mainPs.trails;
            mainPsTrail.enabled = false;
            ParticleSystem.CustomDataModule mainPsData = mainPs.customData;
            mainPsData.enabled = false;



            return(obj);
        }
Пример #20
0
        private void SetupFlameParticleSystem(ParticleSystem ps, Int32 skinIndex, FlamePSInfo psi)
        {
            ParticleSystem.MainModule main = ps.main;
            main.duration      = 1f;
            main.loop          = true;
            main.prewarm       = false;
            main.startDelay    = 0f;
            main.startLifetime = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = 0.65f
            };
            main.startSpeed = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = psi.startSpeed
            };
            main.startSize3D = false;
            main.startSize   = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = psi.startSize * 0.75f
            };
            main.startRotation3D = false;
            main.startRotation   = new ParticleSystem.MinMaxCurve
            {
                mode        = ParticleSystemCurveMode.TwoConstants,
                constantMin = 0f,
                constantMax = 360f
            };
            main.flipRotation = 0f;
            main.startColor   = new ParticleSystem.MinMaxGradient
            {
                mode  = ParticleSystemGradientMode.Color,
                color = new Color(1f, 1f, 1f, 1f)
            };
            main.gravityModifier = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = psi.gravity
            };
            main.simulationSpace     = ParticleSystemSimulationSpace.Local;
            main.simulationSpeed     = 1f;
            main.useUnscaledTime     = false;
            main.scalingMode         = ParticleSystemScalingMode.Local;
            main.playOnAwake         = true;
            main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            main.maxParticles        = 1000;
            main.stopAction          = ParticleSystemStopAction.None;
            main.cullingMode         = ParticleSystemCullingMode.AlwaysSimulate;
            main.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            ParticleSystem.EmissionModule emission = ps.emission;
            emission.enabled      = true;
            emission.rateOverTime = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = 10f
            };
            emission.rateOverDistance = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = 0f
            };
            emission.rateOverDistanceMultiplier = 0f;
            emission.rateOverTimeMultiplier     = psi.rate;

            ParticleSystem.ShapeModule shape = ps.shape;
            shape.enabled          = true;
            shape.shapeType        = ParticleSystemShapeType.Cone;
            shape.angle            = 38.26f;
            shape.radius           = psi.radius * 0.75f;
            shape.radiusThickness  = 1f;
            shape.arc              = 360f;
            shape.arcMode          = ParticleSystemShapeMultiModeValue.Random;
            shape.arcSpread        = 0f;
            shape.position         = psi.position;
            shape.rotation         = psi.rotation;
            shape.scale            = psi.scale;
            shape.alignToDirection = false;

            ParticleSystem.VelocityOverLifetimeModule velOverLife = ps.velocityOverLifetime;
            velOverLife.enabled = false;

            ParticleSystem.LimitVelocityOverLifetimeModule limVelOverLife = ps.limitVelocityOverLifetime;
            limVelOverLife.enabled = false;

            ParticleSystem.InheritVelocityModule inheritVel = ps.inheritVelocity;
            inheritVel.enabled = false;

            ParticleSystem.ForceOverLifetimeModule forceOverLife = ps.forceOverLifetime;
            forceOverLife.enabled = false;

            ParticleSystem.ColorOverLifetimeModule colorOverLife = ps.colorOverLifetime;
            colorOverLife.enabled = true;
            colorOverLife.color   = new ParticleSystem.MinMaxGradient
            {
                mode     = ParticleSystemGradientMode.Gradient,
                gradient = new Gradient
                {
                    mode      = GradientMode.Blend,
                    colorKeys = new GradientColorKey[1]
                    {
                        new GradientColorKey(new Color(1f, 1f, 1f), 0f)
                    },
                    alphaKeys = new GradientAlphaKey[4]
                    {
                        new GradientAlphaKey(0f, 0f),
                        new GradientAlphaKey(0.9f, 0.1f),
                        new GradientAlphaKey(0.6f, 0.6f),
                        new GradientAlphaKey(0f, 1f)
                    }
                }
            };

            ParticleSystem.ColorBySpeedModule colorBySpeed = ps.colorBySpeed;
            colorBySpeed.enabled = false;

            ParticleSystem.SizeOverLifetimeModule sizeOverLife = ps.sizeOverLifetime;
            sizeOverLife.enabled = true;
            sizeOverLife.size    = new ParticleSystem.MinMaxCurve
            {
                mode  = ParticleSystemCurveMode.Curve,
                curve = new AnimationCurve
                {
                    postWrapMode = WrapMode.Clamp,
                    preWrapMode  = WrapMode.Clamp,
                    keys         = new Keyframe[3]
                    {
                        new Keyframe(0f, 0.2f),
                        new Keyframe(0.47f, 0.71f),
                        new Keyframe(1f, 0.025f)
                    }
                }
            };
            sizeOverLife.sizeMultiplier = 1f;

            ParticleSystem.SizeBySpeedModule sizeBySpeed = ps.sizeBySpeed;
            sizeBySpeed.enabled = false;

            ParticleSystem.RotationOverLifetimeModule rotOverLife = ps.rotationOverLifetime;
            rotOverLife.enabled      = true;
            rotOverLife.separateAxes = false;
            rotOverLife.z            = new ParticleSystem.MinMaxCurve
            {
                mode     = ParticleSystemCurveMode.Constant,
                constant = 3f
            };

            ParticleSystem.RotationBySpeedModule rotBySpeed = ps.rotationBySpeed;
            rotBySpeed.enabled = false;

            ParticleSystem.ExternalForcesModule extForce = ps.externalForces;
            extForce.enabled = false;

            ParticleSystem.NoiseModule noise = ps.noise;
            noise.enabled = false;

            ParticleSystem.CollisionModule col = ps.collision;
            col.enabled = false;

            ParticleSystem.TriggerModule trig = ps.trigger;
            trig.enabled = false;

            ParticleSystem.SubEmittersModule subEmit = ps.subEmitters;
            subEmit.enabled = false;

            ParticleSystem.TextureSheetAnimationModule texSheet = ps.textureSheetAnimation;
            texSheet.enabled = false;

            ParticleSystem.LightsModule light = ps.lights;
            light.enabled = false;

            ParticleSystem.TrailModule trails = ps.trails;
            trails.enabled = false;

            ParticleSystem.CustomDataModule custData = ps.customData;
            custData.enabled = false;
        }
Пример #21
0
    private void Update()
    {
        // get average hand velocities
        var average = BodyManager.GetAverageVelocity(new JointType[] { JointType.HandLeft, JointType.HandRight });

        if (average.magnitude > 5)
        {
            // rotate the wind around it's own X axis
            var direction = average.normalized.x;
            wind.transform.Rotate(Vector3.right * direction * Time.deltaTime * 10000);

            /*
             * }
             *
             * var average = new Vector2();
             *
             * foreach (var body in BodyManager.Bodies)
             * {
             * var directionLeft = body.Position(JointType.SpineMid) - body.Position(JointType.HandLeft);
             * var directionRight = body.Position(JointType.SpineMid) - body.Position(JointType.HandRight);
             *
             * average += directionLeft + directionRight;
             * }
             *
             * average /= BodyManager.Bodies.Count * 2f;
             *
             * var amount = Vector2.ClampMagnitude(new Vector2(average.x, average.y) * force, 16);
             * amount.y = Mathf.Abs(amount.y); // only up force, not down
             * amount = Vector2.ClampMagnitude(amount * force, 10);
             *
             * //if (amount.magnitude > 5f)
             * if (average.magnitude > 2f)
             * {
             */
            // we are stirring!
            //wind.transform.rotation = Quaternion.LookRotation(average);
            notStirringTime = 0f;
            stirringTime   += Time.deltaTime;
            //wind.transform.rotation = Quaternion.Lerp(wind.transform.rotation, Quaternion.LookRotation(average * -1), Time.deltaTime * 6f);
            riceWind.multiplier = Mathf.Lerp(riceWind.multiplier, 1, 1);

            if (stirringTime > parchedSpawnTimeThreshold)
            {
                parchedEmmision.rateOverTime = Mathf.Lerp(parchedEmmision.rateOverTime.constant, 5, 10);
            }

            // audio
            SoundEffect.volume = Mathf.Lerp(SoundEffect.volume, 1, Time.deltaTime);
        }
        else
        {
            notStirringTime += Time.deltaTime;

            if (notStirringTime > notStirringTimeThreshold)
            {
                stirringTime = 0f;
            }

            riceWind                     = rice.externalForces;
            riceWind.multiplier          = Mathf.Lerp(riceWind.multiplier, 0, 1);
            parchedEmmision.rateOverTime = Mathf.Lerp(parchedEmmision.rateOverTime.constant, 0, 5);

            SoundEffect.volume = Mathf.Lerp(SoundEffect.volume, 0, Time.deltaTime);
        }


        // move the rice in the average velocity

        /*
         * foreach (var grain in rice)
         * {
         *  var rb = grain.GetComponent<Rigidbody2D>();
         *  var amount = Vector2.ClampMagnitude(new Vector2(average.x, average.y) * force, 16);
         *  amount.y = Mathf.Abs(amount.y); // only up force, not down
         *  rb.AddForce(Vector3.ClampMagnitude(average * force, 10));
         * }
         */
    }
Пример #22
0
        private static void BasicSetup(ParticleSystem ps)
        {
            ParticleSystem.EmissionModule ps1Emission = ps.emission;
            ps1Emission.enabled = false;

            ParticleSystem.ShapeModule ps1Shape = ps.shape;
            ps1Shape.enabled = false;

            ParticleSystem.VelocityOverLifetimeModule ps1VOL = ps.velocityOverLifetime;
            ps1VOL.enabled = false;

            ParticleSystem.LimitVelocityOverLifetimeModule ps1LimVOL = ps.limitVelocityOverLifetime;
            ps1LimVOL.enabled = false;

            ParticleSystem.InheritVelocityModule ps1InhVel = ps.inheritVelocity;
            ps1InhVel.enabled = false;

            ParticleSystem.ForceOverLifetimeModule ps1FOL = ps.forceOverLifetime;
            ps1FOL.enabled = false;

            ParticleSystem.ColorOverLifetimeModule ps1COL = ps.colorOverLifetime;
            ps1COL.enabled = false;

            ParticleSystem.ColorBySpeedModule ps1CBS = ps.colorBySpeed;
            ps1CBS.enabled = false;

            ParticleSystem.SizeOverLifetimeModule ps1SOL = ps.sizeOverLifetime;
            ps1SOL.enabled = false;

            ParticleSystem.SizeBySpeedModule ps1SBS = ps.sizeBySpeed;
            ps1SBS.enabled = false;

            ParticleSystem.RotationOverLifetimeModule ps1ROL = ps.rotationOverLifetime;
            ps1ROL.enabled = false;

            ParticleSystem.RotationBySpeedModule ps1RBS = ps.rotationBySpeed;
            ps1RBS.enabled = false;

            ParticleSystem.ExternalForcesModule ps1ExtFor = ps.externalForces;
            ps1ExtFor.enabled = false;

            ParticleSystem.NoiseModule ps1Noise = ps.noise;
            ps1Noise.enabled = false;

            ParticleSystem.CollisionModule ps1Collis = ps.collision;
            ps1Collis.enabled = false;

            ParticleSystem.TriggerModule ps1Trig = ps.trigger;
            ps1Trig.enabled = false;

            ParticleSystem.SubEmittersModule ps1SubEmit = ps.subEmitters;
            ps1SubEmit.enabled = false;

            ParticleSystem.TextureSheetAnimationModule ps1TexAnim = ps.textureSheetAnimation;
            ps1TexAnim.enabled = false;

            ParticleSystem.LightsModule ps1Light = ps.lights;
            ps1Light.enabled = false;

            ParticleSystem.TrailModule ps1Trails = ps.trails;
            ps1Trails.enabled = false;

            ParticleSystem.CustomDataModule ps1Cust = ps.customData;
            ps1Cust.enabled = false;
        }
Пример #23
0
        public static void Create(Vector3 pos, float rootDuration)
        {
            if (ChainInstance == null)
            {
                ChainInstance = new GameObject();
                ChainInstance.AddComponent <RootSpell>();
                ParticleSystem            ps   = ChainInstance.AddComponent <ParticleSystem>();
                ParticleSystem.MainModule main = ps.main;
                main.startLifetime   = 30;
                main.startSpeed      = 0;
                main.startSize       = 2.5f;
                main.scalingMode     = ParticleSystemScalingMode.Hierarchy;
                main.startRotationX  = 90;
                main.startRotationY  = 90;
                main.startRotationZ  = new ParticleSystem.MinMaxCurve(0, 90);
                main.simulationSpace = ParticleSystemSimulationSpace.World;

                ParticleSystem.EmissionModule e = ps.emission;
                e.rateOverDistance = 4;
                e.rateOverTime     = 0;

                ParticleSystem.ShapeModule s = ps.shape;
                s.shapeType        = ParticleSystemShapeType.SingleSidedEdge;
                s.alignToDirection = true;

                s.radius = 0.0001f;
                s.length = 0.0001f;

                ParticleSystem.ExternalForcesModule ef = ps.externalForces;
                ef.enabled    = true;
                ef.multiplier = 2;

                ParticleSystemRenderer r = ps.GetComponent <ParticleSystemRenderer>();

                var mat = new Material(Shader.Find("Particles/Additive"));
                mat.SetColor("_TintColor", new Color(0.2431373f, 0.2051491f, 0, 0.10f));
                r.material          = mat;
                r.renderMode        = ParticleSystemRenderMode.Mesh;
                r.mesh              = Res.ResourceLoader.instance.LoadedMeshes[69];
                r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
                r.alignment         = ParticleSystemRenderSpace.World;
                ChainInstance.SetActive(false);

                RepulsionEffectInstance = new GameObject();
                WindZone wz = RepulsionEffectInstance.AddComponent <WindZone>();
                wz.windMain       = -10;
                wz.windTurbulence = 5;
                wz.mode           = WindZoneMode.Spherical;
                wz.radius         = 15;
                RepulsionEffectInstance.SetActive(false);
            }
            ChainInstance.SetActive(true);
            for (int i = 0; i < ChainCount; i++)
            {
                Vector3 rand = new Vector3(Random.value * 2 - 1, Random.value, Random.value * 2 - 1);
                rand *= 10;
                rand += pos;

                GameObject go = Instantiate(ChainInstance, rand, Quaternion.LookRotation(pos - rand));
                go.transform.LookAt(pos);
                RootSpell spell = go.GetComponent <RootSpell>();
                spell.targetPos = pos;
                spell.Duration  = rootDuration;
            }
            ChainInstance.SetActive(false);
        }
Пример #24
0
    protected void InitializeParticleSystem(ParticleSystem ps, ParticleSystemRenderer renderer, int max_particles)
    {
        ParticleSystem.MainModule main = ps.main;
        main.loop         = false;
        main.playOnAwake  = false;
        main.maxParticles = max_particles;
        main.startColor   = new ParticleSystem.MinMaxGradient(new Color(1.0f, 1.0f, 1.0f, 0.0f));

        renderer.sortMode          = ParticleSystemSortMode.Distance;
        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        renderer.receiveShadows    = false;

        renderer.renderMode = ParticleSystemRenderMode.Billboard;

        //GameObject gameObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        //renderer.mesh = gameObj.GetComponent<MeshFilter>().mesh;
        //Destroy(gameObj);
        renderer.enableGPUInstancing = true;

        renderer.alignment = ParticleSystemRenderSpace.Facing;

        ps_material       = new Material(Shader.Find(shader));
        renderer.material = ps_material;

        PrepareMaterial(ps_material, m_Particle);

        SetDefaultColor(new Color(1.0f, 1.0f, 1.0f, 1.0f));
        SetDefaultEmission(new Color(1f, 1f, 1f, 1f));

        ParticleSystem.EmissionModule em = ps.emission;
        em.enabled = false;
        ParticleSystem.ShapeModule sh = ps.shape;
        sh.enabled = false;
        ParticleSystem.VelocityOverLifetimeModule vol = ps.velocityOverLifetime;
        vol.enabled = false;
        ParticleSystem.LimitVelocityOverLifetimeModule lvol = ps.limitVelocityOverLifetime;
        lvol.enabled = false;
        ParticleSystem.InheritVelocityModule ivm = ps.inheritVelocity;
        ivm.enabled = false;
        ParticleSystem.ForceOverLifetimeModule fol = ps.forceOverLifetime;
        fol.enabled = false;
        ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime;
        col.enabled = false;
        ParticleSystem.ColorBySpeedModule cbs = ps.colorBySpeed;
        cbs.enabled = false;
        ParticleSystem.SizeOverLifetimeModule sol = ps.sizeOverLifetime;
        sol.enabled = false;
        ParticleSystem.SizeBySpeedModule sbs = ps.sizeBySpeed;
        sbs.enabled = false;
        ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime;
        rol.enabled = false;
        ParticleSystem.RotationBySpeedModule rbs = ps.rotationBySpeed;
        rbs.enabled = false;
        ParticleSystem.ExternalForcesModule extf = ps.externalForces;
        extf.enabled = false;
        ParticleSystem.NoiseModule noise = ps.noise;
        noise.enabled = false;
        ParticleSystem.CollisionModule collision = ps.collision;
        collision.enabled = false;
        ParticleSystem.TriggerModule triggers = ps.trigger;
        triggers.enabled = false;
        ParticleSystem.SubEmittersModule subem = ps.subEmitters;
        subem.enabled = false;
        ParticleSystem.TextureSheetAnimationModule tsa = ps.textureSheetAnimation;
        tsa.enabled = false;
        ParticleSystem.LightsModule lights = ps.lights;
        lights.enabled = false;
        ParticleSystem.CustomDataModule cd = ps.customData;
        cd.enabled = false;
    }