/// <summary> /// Emitter generator - send emitter for an enabled object to handle /// </summary> /// <param name="host">an object that is hosting the emitter</param> /// <param name="pos">emitter position in pixels</param> /// <param name="ptype">particle type being generated</param> /// <param name="random">are particles randomized?</param> /// <param name="emitter_life_duration">how long should this emitter exist</param> /// <param name="rate">number of ms between bursts</param> /// <param name="auto">is generation automatic?</param> /// <param name="ttype">particle trajectory type</param> /// <param name="particle_lifetime">how long should the particles exist - in ms?</param> /// <param name="number_of_particles_in_burst">number of particles generated at the same time</param> /// <param name="random_color">are colors randomized?</param> /// <param name="interpolate_color_flag">are colors interpolated?</param> /// <param name="area_radius">area of generation</param> public void create_emitter( IParticleCreating host, // emitter will be created inside this object Vector2[] pos, // create in these positions (allows creation of multiple emitters in one function call) particle_type ptype, // defines what shape the particle takes as well as multiple internal properties bool random, // int emitter_life_duration, // when is this emitter scheduled for deletion int rate, // number of milliseconds between particle bursts bool auto, // requires no manual input to create particles trajectory_type ttype, // trajectory type - defines particle movement after creation int particle_lifetime, // particle lifetime int number_of_particles_in_burst, // number of particles created in the same cycle bool random_color, // randomizes particle tint bool interpolate_color_flag, // change from current color to black int area_radius // all particles in one burst will be created in this radius (use 1 for point creation) ) { for (int i = 0; i < pos.Length; i++) { Emitter temp = new Emitter(pos[i], ptype, random, emitter_life_duration, particle_lifetime, rate, auto, ttype, number_of_particles_in_burst, random_color, interpolate_color_flag, area_radius); // call Emitter constructor using parameters supplied by Engine host.Add(temp); // function required by the interface } }
/// <summary> /// Unregister a particle enabled object /// </summary> /// <param name="instance">object to unregister - in case of deletion or expiration</param> public void delete_emitter(IParticleCreating instance) // and all its particles, or just the emitter but keep particles active { // remove element from the list when Emitter is no longer needed emitting_objects.Remove(instance); }
/// <summary> /// Remove a particle enabled object from the list of registered emitting objects /// </summary> /// <param name="instance">instance of the particle interface implementing class</param> public void unregister_emitter_enabled_object(IParticleCreating instance) { emitting_objects.Remove(instance); }
/// <summary> /// Register the object so it's emitters can be updated /// </summary> /// <param name="instance">An emitter hosting object</param> public void register_emitter_enabled_object(IParticleCreating instance) { emitting_objects.Add(instance); }