Esempio n. 1
0
        void AddXmlChild(XmlDocument doc, XmlElement parent, string elementName, ParticleEmitterType emitterType)
        {
            int value = 0;

            if (emitterType == ParticleEmitterType.Radial)
            {
                value = 1;
            }
            AddXmlChild(doc, parent, elementName, value, "F0");
        }
Esempio n. 2
0
 public DustParticleEmitterComponent(TimeSpan timeToLive,
                                     GameObject gameObject,
                                     Vector2 particleOffset,
                                     ushort numberOfParticles,
                                     float initialVelocityFactor,
                                     ParticleEmitterType particleEmitterType)
 {
     TimeToLive            = timeToLive;
     GameObject            = gameObject;
     ParticleOffset        = particleOffset;
     NumberOfParticles     = numberOfParticles;
     InitialVelocityFactor = initialVelocityFactor;
     ParticleEmitterType   = particleEmitterType;
     DustParticleEmitterComponentManager.Instance.AddComponent(this);
 }
        void MakeEmitterDropdown(Table table, Skin skin, string label)
        {
            ParticleEmitterType value = _particleEmitterConfig.EmitterType;

            var dropdown     = new SelectBox <string>(skin);
            var dropdownList = new List <string>()
            {
                "Gravity",
                "Radial"
            };

            dropdown.SetItems(dropdownList);

            if (_particleEmitterConfig.EmitterType == ParticleEmitterType.Gravity)
            {
                dropdown.SetSelectedIndex(0);
            }
            else
            {
                dropdown.SetSelectedIndex(1);
            }

            dropdown.OnChanged += (str) =>
            {
                if (str == "Gravity")
                {
                    _particleEmitterConfig.EmitterType = ParticleEmitterType.Gravity;
                }
                else
                {
                    _particleEmitterConfig.EmitterType = ParticleEmitterType.Radial;
                }
                ResetEmitter();
                ResetUi();
            };

            table.Add(label).Left().Width(140);
            table.Add("").Width(1);             // This is a 3 column table
            table.Add(dropdown);
        }
        /// <summary>
        /// Spawns a ParticleEmitter of the specified type at the specified 
        /// location.
        /// </summary>
        /// <param name="type">The type ParticleEmitter to spawn</param>
        /// <param name="location">The location to spawn the ParticleEmitter 
        /// at</param>
        /// <returns>Returns a reference to the spawned ParticleEmitter
        /// </returns>
        public static ParticleEmitter spawnParticleEmitter(ParticleEmitterType type, Vector3 location)
        {
            checkIfInitialized();
            ParticleEmitter spawnedParticleEmitter = null;

            switch (type)
            {
                case ParticleEmitterType.explosion:
                    spawnedParticleEmitter = new ExplosionParticleEmitter(ContentLoader.ExplosionParticleTexture, location, Settings.EXPLOSION_PARTICLE_ACCELERATION,
                        Settings.EXPLOSION_PARTICLES, Settings.EXPLOSION_PARTICLE_SIZE, Settings.EXPLOSION_PARTICLE_GROWTH_RATE, Settings.EXPLOSION_PARTICLE_LIFESPAN);
                    break;
                case ParticleEmitterType.stream:
                    spawnedParticleEmitter = new StreamParticleEmitter(ContentLoader.CloudParticleTexture, location, Settings.SMOKE_PARTICLE_ACCELERATION,
                        Settings.SMOKE_PARTICLE_SIZE, Settings.SMOKE_PARTICLE_GROWTH_RATE, Settings.SMOKE_PARTICLE_LIFESPAN, Settings.SMOKE_PARTICLE_PARTICLES_PER_SECOND);
                    break;
            }

            if (spawnedParticleEmitter != null)
            {
                managedParticleEmitters.Add(spawnedParticleEmitter);
            }

            return spawnedParticleEmitter;
        }