Exemplo n.º 1
0
 private void LoadItemRandomOption()
 {
     ItemRandomOptionList = new List <EntityItemRandomOption>();
     string[] urls = { GenerateDataFile.fileListItems[3], GenerateDataFile.fileListItems[4] };
     //{ DataFilePath + "\\Items\\client_item_random_option.xml", DataFilePath + "\\Items\\polish_bonus_setlist.xml" };
     for (int i = 0; i < urls.Length; i++)
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(GenerateDataFile.dataPath + "\\" + urls[i]);
         XmlElement  root = xml.DocumentElement;
         XmlNodeList list = root.ChildNodes;
         foreach (XmlNode node in list)
         {
             string optionName = node["name"].InnerText;
             if (this.ItemListKeyIsRandomOption.ContainsKey(optionName))
             {
                 List <EntityItem> il = this.ItemListKeyIsRandomOption[optionName];
                 foreach (EntityItem ii in il)
                 {
                     EntityItemRandomOption set = new EntityItemRandomOption(this, node, ii);
                     if (set.ViewName == null)
                     {
                         continue;
                     }
                     //if (i == 1) continue; //이디안은 안보이게 할때
                     if (set.Name.Contains("test") == false)
                     {
                         this.ItemRandomOptionList.Add(set);
                     }
                 }
             }
         }
         XMLEventHandler(this, new XMLEventArgs(XMLEvent.랜덤옵션, urls[i]));
     }
 }
Exemplo n.º 2
0
        public EntityOption(EntityItemRandomOption parent, XmlNode root)
        {
            this.parent      = parent;
            this.xml         = root.InnerXml;
            AttrList         = new Dictionary <string, string>();
            AfterCalAttrList = new Dictionary <string, string>();
            GroupId          = Int32.Parse(root["attr_group_id"].InnerText);
            Prob             = Int32.Parse(root["prob"].InnerText);
            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.Name.StartsWith("random_attr"))
                {
                    string[] tmp = node.InnerText.Split(' ');
                    AttrList.Add(tmp[0].ToLower(), tmp[1]);
                }
            }

            // 계산후 옵션
            if (this.parent.Item != null)
            {
                IDictionaryEnumerator e1 = this.parent.Item.BonusOption.GetEnumerator();
                while (e1.MoveNext())
                {
                    AfterCalAttrList.Add((string)e1.Key, (string)e1.Value);
                }
                IDictionaryEnumerator e2 = this.AttrList.GetEnumerator();
                while (e2.MoveNext())
                {
                    if (AfterCalAttrList.ContainsKey((string)e2.Key))
                    {
                        string v1   = (string)AfterCalAttrList[(string)e2.Key];
                        string v2   = (string)e2.Value;
                        int    idx1 = v1.IndexOf('%');
                        int    idx2 = v2.IndexOf('%');
                        v1 = (idx1 == -1) ? v1 : v1.Substring(0, idx1);
                        v2 = (idx2 == -1) ? v2 : v2.Substring(0, idx2);
                        int i1 = 0;
                        int i2 = 0;
                        try { i1 = Int32.Parse(v1); }
                        catch { }
                        try { i2 = Int32.Parse(v2); }
                        catch { }
                        if (idx1 != -1 && idx2 != -1)
                        {
                            AfterCalAttrList[(string)e2.Key] = (i1 + i2) + "%";
                        }
                        else
                        {
                            AfterCalAttrList[(string)e2.Key] = (i1 + i2) + "";
                        }
                    }
                    else
                    {
                        AfterCalAttrList.Add((string)e2.Key, (string)e2.Value);
                    }
                }
            }
            else
            {
            }
        }