示例#1
0
 public static int getLifeById(int charaId, int type)
 {
     for (int index = 0; index < CharaXML._charas.Count; ++index)
     {
         CharaModel chara = CharaXML._charas[index];
         if (chara.Id == charaId && chara.Type == type)
         {
             return(chara.Life);
         }
     }
     return(100);
 }
 public static int getLifeById(int charaId, int type)
 {
     for (int i = 0; i < _charas.Count; i++)
     {
         CharaModel chara = _charas[i];
         if (chara.Id == charaId && chara.Type == type)
         {
             return(chara.Life);
         }
     }
     return(100);
 }
示例#3
0
        private static void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                if (fileStream.Length > 0L)
                {
                    try
                    {
                        xmlDocument.Load((Stream)fileStream);
                        for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                        {
                            if ("list".Equals(xmlNode1.Name))
                            {
                                for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                                {
                                    if ("Chara".Equals(xmlNode2.Name))
                                    {
                                        XmlNamedNodeMap attributes = (XmlNamedNodeMap)xmlNode2.Attributes;
                                        CharaModel      charaModel = new CharaModel()
                                        {
                                            Id   = int.Parse(attributes.GetNamedItem("Id").Value),
                                            Type = int.Parse(attributes.GetNamedItem("Type").Value),
                                            Life = int.Parse(attributes.GetNamedItem("Life").Value)
                                        };
                                        CharaXML._charas.Add(charaModel);
                                    }
                                }
                            }
                        }
                    }
                    catch (XmlException ex)
                    {
                        Logger.warning(ex.ToString(), false);
                    }
                }
                fileStream.Dispose();
                fileStream.Close();
            }
            Logger.warning("[Aviso] Loaded " + (object)CharaXML._charas.Count + " charas information", false);
        }
        private static void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                if (fileStream.Length > 0)
                {
                    try
                    {
                        xmlDocument.Load(fileStream);
                        for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                        {
                            if ("list".Equals(xmlNode1.Name))
                            {
                                for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                                {
                                    if ("Chara".Equals(xmlNode2.Name))
                                    {
                                        XmlNamedNodeMap xml   = xmlNode2.Attributes;
                                        CharaModel      chara = new CharaModel
                                        {
                                            Id   = int.Parse(xml.GetNamedItem("Id").Value),
                                            Type = int.Parse(xml.GetNamedItem("Type").Value),
                                            Life = int.Parse(xml.GetNamedItem("Life").Value)
                                        };
                                        _charas.Add(chara);
                                    }
                                }
                            }
                        }
                    }
                    catch (XmlException ex)
                    {
                        SaveLog.fatal(ex.ToString());
                        Printf.b_danger("[CharaXML.parse] Erro fatal!");
                    }
                }
                fileStream.Dispose();
                fileStream.Close();
            }
        }