Пример #1
0
        private bool HasParticlesToEmit(ParticleSystem pEmitter, AtmoParticleSetting pSetting)
        {
            if (pEmitter.particleCount < pSetting.Density * pSetting.MaxParticles * GlobalDensityMultiplier)
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        public AtmoParticleSetting GetAtmoParticleSetting(string settingName)
        {
            // Is particle setting already instantiated?
            if (!particleSettingDict.ContainsKey(settingName))
            {
                particleSettingDict[settingName] = new AtmoParticleSetting();
            }

            return(particleSettingDict[settingName]);
        }
Пример #3
0
        public void ChangeAtmoSettingDensity(string atmoType, float atmoDensity)
        {
            // Updates to Density are Lerped by a set speed
            AtmoParticleSetting pSetting = GetAtmoParticleSetting(atmoType);

            pSetting.TargetDensity = atmoDensity;

            // Initializes Emitter
            if (GetParticleSystem(atmoType) == null)
            {
                // Used for debuging, make sure to remove all Debug.Logs before release
                Debug.Log("AtmoParticleManager couldn't find prefab " + atmoType +
                          ". Emitter couldn't be created and no particles will be shown");
            }
        }
Пример #4
0
        // Used for accessing ParticleSystems directly, and also instantiates only when they are used
        private ParticleSystem GetParticleSystem(string emitterName)
        {
            // Is particle emitter already instantiated?
            if (emitterDict.ContainsKey(emitterName))
            {
                return(emitterDict[emitterName]);
            }

            // Find Particle Emitter that matches the same name
            // Add to dictionary, return newly instantiated emitter
            for (int i = 0; i < particleSettings.Length; i++)
            {
                //foreach (ParticleSystemSetting pEmitterSetting in particleSettings) {
                pEmitterSetting = particleSettings[i];
                if (pEmitterSetting.particlePrefab.transform.name == emitterName)
                {
                    GameObject newParticleSystem = Instantiate(pEmitterSetting.particlePrefab) as GameObject;
                    newParticleSystem.transform.name = pEmitterSetting.particlePrefab.transform.name;
                    ParticleSystem particleSystem = newParticleSystem.GetComponent <ParticleSystem>();
                    emitterDict[emitterName] = particleSystem;

                    // Save position offset into AtmoParticleSetting, add any other additional initialization
                    AtmoParticleSetting newParticleSetting = GetAtmoParticleSetting(emitterName);
                    newParticleSetting.Offset    = pEmitterSetting.particleOffset;
                    newParticleSetting.BaseColor = particleSystem.startColor;
                    SetAtmoSetting(emitterName, newParticleSetting);

                    return(emitterDict[emitterName]);
                }
            }

            // Can either return a null, empty object, or halt the code
            // Returning a null would require the receiving to do a null check, an empty object would have no effect except for
            // taking up space
            return(null);
        }
Пример #5
0
 public void SetAtmoSetting(string atmoType, AtmoParticleSetting pSetting)
 {
     // Used for getting saved state, or updating atmoparticlesettings
     particleSettingDict[atmoType] = pSetting;
 }