Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 public virtual void AddAttribute(int line, XMLAttribute a)
 {
     if (a != null)
     {
         XMLElement ele = a.GetElement();
         if (flag_source.ToUpper() == a.GetName().ToUpper())
         {
             _read._source = a.GetValue();
         }
         else if (flag_type.ToUpper() == a.GetName().ToUpper())
         {
             _read._classType = a.GetValue();
         }
         else if (ele != null)
         {
             _read._classType = ele.GetName();
         }
     }
 }
Exemplo n.º 3
0
 public virtual void EndElement(int line, XMLElement e)
 {
     _read.StopElement(e != null ? e.GetName() : _read._classType);
 }
Exemplo n.º 4
0
        private static NSObject ParseObject(XMLElement n)
        {
            String type = n.GetName();

            if (type.Equals("dict", StringComparison.InvariantCultureIgnoreCase))
            {
                NSDictionary      dict     = new NSDictionary();
                List <XMLElement> children = n.List();
                for (int i = 0; i < children.Count; i += 2)
                {
                    XMLElement key = (XMLElement)children[i + 0];
                    XMLElement val = (XMLElement)children[i + 1];
                    dict.Put(key.GetContents(), ParseObject(val));
                }
                return(dict);
            }
            else if (type.Equals("array", StringComparison.InvariantCultureIgnoreCase))
            {
                List <XMLElement> children = n.List();
                NSArray           array    = new NSArray(children.Count);
                for (int i = 0; i < children.Count; i++)
                {
                    array.SetValue(i, ParseObject((XMLElement)children[i]));
                }
                return(array);
            }
            else if (type.Equals("true", StringComparison.InvariantCultureIgnoreCase) ||
                     type.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(true));
            }
            else if (type.Equals("false", StringComparison.InvariantCultureIgnoreCase) ||
                     type.Equals("no", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(false));
            }
            else if (type.Equals("integer", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(n.GetContents()));
            }
            else if (type.Equals("real", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(n.GetContents()));
            }
            else if (type.Equals("string", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSString(n.GetContents()));
            }
            else if (type.Equals("data", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSData(n.GetContents()));
            }
            else if (type.Equals("range", StringComparison.InvariantCultureIgnoreCase))
            {
                List <XMLElement> children = n.List();
                if (children.Count == 2)
                {
                    XMLElement key = (XMLElement)children[0];
                    XMLElement val = (XMLElement)children[1];
                    return(new NSRange(Int32.Parse(key.GetContents()),
                                       Int32.Parse(val.GetContents())));
                }
            }
            return(null);
        }