Exemplo n.º 1
0
        public static ConfigEmitter LoadEmitter(InputStream refs,
                                                ConfigEmitterFactory factory)
        {
            if (factory == null)
            {
                factory = new NewConfigEmitterFactory();
            }
            try {
                XMLDocument document = XMLParser.Parse(refs);

                if (!document.GetRoot().GetName().Equals("emitter"))
                {
                    throw new IOException("Not a particle emitter file");
                }

                ConfigEmitter emitter = factory.CreateEmitter("new");
                ElementToEmitter(document.GetRoot(), emitter);

                return(emitter);
            } catch (IOException e) {
                Log.Exception(e);
                throw e;
            } catch (Exception e) {
                Log.Exception(e);
                throw new IOException("Unable to load emitter");
            }
        }
Exemplo n.º 2
0
        public static ParticleSystem LoadConfiguredSystem(InputStream refs,
                                                          ConfigEmitterFactory factory, ParticleSystem system,
                                                          LColor mask)
        {
            if (factory == null)
            {
                factory = new NewConfigEmitterFactory();
            }
            try {
                XMLDocument document = XMLParser.Parse(refs);

                XMLElement element = document.GetRoot();
                if (!element.GetName().Equals("system", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    Log.DebugWrite("Not a particle system file");
                }

                if (system == null)
                {
                    system = new ParticleSystem("assets/particle.tga", 2000, mask);
                }
                bool additive = "true".Equals(element.GetAttribute("additive"));
                if (additive)
                {
                    system.SetBlendingMode(ParticleSystem.BLEND_ADDITIVE);
                }
                else
                {
                    system.SetBlendingMode(ParticleSystem.BLEND_COMBINE);
                }
                bool points = "true".Equals(element.GetAttribute("points"));
                system.SetUsePoints(points);

                List <XMLElement> List = element.List("emitter");
                for (int i = 0; i < List.Count; i++)
                {
                    XMLElement    em      = (XMLElement)List[i];
                    ConfigEmitter emitter = factory.CreateEmitter("new");

                    ElementToEmitter(em, emitter);

                    system.AddEmitter(emitter);
                }

                system.SetRemoveCompletedEmitters(false);
                return(system);
            } catch (IOException e) {
                Log.Exception(e);
            } catch (Exception e) {
                Log.Exception(e);
                throw new IOException("Unable to load particle system config");
            }
            return(system);
        }