Exemplo n.º 1
0
        public ContinuousEmitter(EmitterTypes type, Vector2 position) :
            base(type)
        {
            Position = position;

            // setting the duration to zero makes the timer trigger immediately, and its duration is changed every emit anyway
            timer = new Timer(0, Emit, true);
        }
Exemplo n.º 2
0
        public ParticleEmitter(int numberOfParticles, List <Texture2D> textures, Vector2 position, EmitterTypes emitterType = EmitterTypes.None)
        {
            _Random = new Random();

            EmitterType = emitterType;
            Position    = position;

            _NumberOfParticles = numberOfParticles;
            _IsInUse           = true;
            _Textures          = textures;
            _FreeParticles     = new LinkedList <Particle>();
            _UsedParticles     = new LinkedList <Particle>();

            if (_FreeParticles.Count > 0 && _UsedParticles.Count < _NumberOfParticles)
            {
                _NumberOfParticles -= _FreeParticles.Count;

                foreach (var particle in _FreeParticles)
                {
                    if (_NumberOfParticles > 0)
                    {
                        _FreeParticles.Remove(particle);
                        particle.IsInUse = false;
                        _UsedParticles.AddLast(particle);

                        _NumberOfParticles--;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (numberOfParticles > 0)
            {
                GenerateParticleList(_NumberOfParticles);
            }
        }
Exemplo n.º 3
0
        static Emitter()
        {
            AttributeList = new EmitterAttributes[Enum.GetNames(typeof(EmitterTypes)).Length - 1];

            foreach (XElement emitterElement in XDocument.Load(Constants.XML_FILEPATH + "Emitters.xml").Root.Elements("Emitter"))
            {
                EmitterTypes  emitterType  = ConvertToEmitterType(emitterElement.Attribute("Type").Value);
                ParticleTypes particleType = Particle.ConvertToParticleType(emitterElement.Element("ParticleType").Value);

                int minDelay          = int.Parse(emitterElement.Element("MinDelay").Value);
                int maxDelay          = int.Parse(emitterElement.Element("MaxDelay").Value);
                int minParticles      = int.Parse(emitterElement.Element("MinParticles").Value);
                int maxParticles      = int.Parse(emitterElement.Element("MaxParticles").Value);
                int minParticleSpeedX = int.Parse(emitterElement.Element("MinParticleSpeedX").Value);
                int maxParticleSpeedX = int.Parse(emitterElement.Element("MaxParticleSpeedX").Value);
                int minParticleSpeedY = int.Parse(emitterElement.Element("MinParticleSpeedY").Value);
                int maxParticleSpeedY = int.Parse(emitterElement.Element("MaxParticleSpeedY").Value);

                AttributeList[(int)emitterType] = new EmitterAttributes(particleType, minDelay, maxDelay, minParticles, maxParticles,
                                                                        minParticleSpeedX, maxParticleSpeedX, minParticleSpeedY, maxParticleSpeedY);
            }
        }
Exemplo n.º 4
0
 public Emitter(EmitterTypes type)
 {
     Attributes = AttributeList[(int)type];
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets TAS Emitter Emitter Type
 /// </summary>
 /// <param name="Emitter">Emitter</param>
 /// <param name="EmitterType">Emitter Type</param>
 /// <returns name="Emitter">Emitter</returns>
 /// <search>
 /// TAS, Emitter, emitter, Name, name, SetEmitterType
 /// </search>
 public static Emitter SetEmitterType(Emitter Emitter, EmitterTypes EmitterType)
 {
     Emitter.pEmitter.emitterType = (TBD.EmitterTypes)(int) EmitterType;
     return(Emitter);
 }