public static GearSealedInfo CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { GearSealedInfo info = new GearSealedInfo(); foreach (Wz_Node child in node.Nodes) { switch (child.Text) { case "exp": info.Exp = child.GetValue(0); break; case "icon": info.Icon = BitmapOrigin.CreateFromNode(child, findNode); info.HasIcon = true; break; case "iconRaw": info.IconRaw = BitmapOrigin.CreateFromNode(child, findNode); info.HasIcon = true; break; default: try { GearPropType propType = (GearPropType)Enum.Parse(typeof(GearPropType), child.Text, true); info.BonusProps[propType] = child.GetValue(0); } finally { } break; } } return(info); }
public static Gear CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { int gearID; Match m = Regex.Match(node.Text, @"^(\d{8})\.img$"); if (!(m.Success && Int32.TryParse(m.Result("$1"), out gearID))) { return(null); } Gear gear = new Gear(); gear.ItemID = gearID; gear.type = Gear.GetGearType(gear.ItemID); Wz_Node infoNode = node.FindNodeByPath("info"); if (infoNode != null) { foreach (Wz_Node subNode in infoNode.Nodes) { switch (subNode.Text) { case "icon": if (subNode.Value is Wz_Png) { gear.Icon = BitmapOrigin.CreateFromNode(subNode, findNode); } break; case "iconRaw": if (subNode.Value is Wz_Png) { gear.IconRaw = BitmapOrigin.CreateFromNode(subNode, findNode); } break; case "sample": if (subNode.Value is Wz_Png) { gear.Sample = BitmapOrigin.CreateFromNode(subNode, findNode); } break; case "addition": //附加属性信息 foreach (Wz_Node addiNode in subNode.Nodes) { Addition addi = Addition.CreateFromNode(addiNode); if (addi != null) { gear.Additions.Add(addi); } } gear.Additions.Sort((add1, add2) => (int)add1.Type - (int)add2.Type); break; case "option": //附加潜能信息 Wz_Node itemWz = findNode != null?findNode("Item\\ItemOption.img") : null; if (itemWz == null) { break; } int optIdx = 0; foreach (Wz_Node optNode in subNode.Nodes) { int optId = 0, optLevel = 0; foreach (Wz_Node optArgNode in optNode.Nodes) { switch (optArgNode.Text) { case "option": optId = Convert.ToInt32(optArgNode.Value); break; case "level": optLevel = Convert.ToInt32(optArgNode.Value); break; } } Potential opt = Potential.CreateFromNode(itemWz.FindNodeByPath(optId.ToString("d6")), optLevel); if (opt != null) { gear.Options[optIdx++] = opt; } } break; case "level": //可升级信息 if (subNode.Nodes["fixLevel"].GetValueEx <int>(0) != 0) { gear.FixLevel = true; } Wz_Node levelInfo = subNode.Nodes["info"]; gear.Levels = new List <GearLevelInfo>(); if (levelInfo != null) { for (int i = 1; ; i++) { Wz_Node levelInfoNode = levelInfo.Nodes[i.ToString()]; if (levelInfoNode != null) { GearLevelInfo info = GearLevelInfo.CreateFromNode(levelInfoNode); int lv; Int32.TryParse(levelInfoNode.Text, out lv); info.Level = lv; gear.Levels.Add(info); } else { break; } } } Wz_Node levelCase = subNode.Nodes["case"]; if (levelCase != null) { int probTotal = 0; foreach (Wz_Node caseNode in levelCase.Nodes) { int prob = caseNode.Nodes["prob"].GetValueEx(0); probTotal += prob; for (int i = 0; i < gear.Levels.Count; i++) { GearLevelInfo info = gear.Levels[i]; Wz_Node caseLevel = caseNode.Nodes[info.Level.ToString()]; if (caseLevel != null) { //desc Wz_Node caseHS = caseLevel.Nodes["hs"]; if (caseHS != null) { info.HS = caseHS.GetValue <string>(); } //随机技能 Wz_Node caseSkill = caseLevel.Nodes["Skill"]; if (caseSkill != null) { foreach (Wz_Node skillNode in caseSkill.Nodes) { int id = skillNode.Nodes["id"].GetValueEx(-1); int level = skillNode.Nodes["level"].GetValueEx(-1); if (id >= 0 && level >= 0) { info.Skills[id] = level; } } } //装备技能 Wz_Node equipSkill = caseLevel.Nodes["EquipmentSkill"]; if (equipSkill != null) { foreach (Wz_Node skillNode in equipSkill.Nodes) { int id = skillNode.Nodes["id"].GetValueEx(-1); int level = skillNode.Nodes["level"].GetValueEx(-1); if (id >= 0 && level >= 0) { info.EquipmentSkills[id] = level; } } } info.Prob = prob; } } } foreach (var info in gear.Levels) { info.ProbTotal = probTotal; } } gear.Props.Add(GearPropType.level, 1); break; case "sealed": //封印解除信息 Wz_Node sealedInfo = subNode.Nodes["info"]; gear.Seals = new List <GearSealedInfo>(); if (sealedInfo != null) { foreach (Wz_Node levelInfoNode in sealedInfo.Nodes) { GearSealedInfo info = GearSealedInfo.CreateFromNode(levelInfoNode, findNode); int lv; Int32.TryParse(levelInfoNode.Text, out lv); info.Level = lv; gear.Seals.Add(info); } } gear.Props.Add(GearPropType.@sealed, 1); break; case "variableStat": //升级奖励属性 foreach (Wz_Node statNode in subNode.Nodes) { GearPropType type; if (Enum.TryParse(statNode.Text, out type)) { try { gear.VariableStat.Add(type, Convert.ToSingle(statNode.Value)); } finally { } } } break; case "abilityTimeLimited": //限时属性 foreach (Wz_Node statNode in subNode.Nodes) { GearPropType type; if (Enum.TryParse(statNode.Text, out type)) { try { gear.AbilityTimeLimited.Add(type, Convert.ToInt32(statNode.Value)); } finally { } } } break; default: { GearPropType type; if (!int.TryParse(subNode.Text, out _) && Enum.TryParse(subNode.Text, out type)) { try { gear.Props.Add(type, Convert.ToInt32(subNode.Value)); } finally { } } } break; } } } int value; //读取默认可升级状态 if (gear.Props.TryGetValue(GearPropType.tuc, out value) && value > 0) { gear.HasTuc = true; gear.CanPotential = true; } else if (Gear.SpecialCanPotential(gear.type)) { gear.CanPotential = true; } //读取默认gearGrade if (gear.Props.TryGetValue(GearPropType.fixedGrade, out value)) { gear.Grade = (GearGrade)(value - 1); } //自动填充Grade if (gear.Options.Any(opt => opt != null) && gear.Grade == GearGrade.C) { gear.Grade = GearGrade.B; } //添加默认装备要求 GearPropType[] types = new GearPropType[] { GearPropType.reqJob, GearPropType.reqLevel, GearPropType.reqSTR, GearPropType.reqDEX, GearPropType.reqINT, GearPropType.reqLUK }; foreach (GearPropType type in types) { if (!gear.Props.ContainsKey(type)) { gear.Props.Add(type, 0); } } //修复恶魔盾牌特殊属性 if (gear.type == GearType.demonShield) { if (gear.Props.TryGetValue(GearPropType.incMMP, out value)) { gear.Props.Remove(GearPropType.incMMP); gear.Props.Add(GearPropType.incMDF, value); } } //备份标准属性 gear.StandardProps = new Dictionary <GearPropType, int>(gear.Props); //追加限时属性 gear.MakeTimeLimitedPropAvailable(); return(gear); }