public static void DrawNameTag(Graphics g, Wz_Node resNode, string tagName, int picW, ref int picH) { if (g == null || resNode == null) { return; } //加载资源和文本颜色 var wce = new[] { "w", "c", "e" }.Select(n => { var node = resNode.FindNodeByPath(n); if (node == null) { return(new BitmapOrigin()); } return(BitmapOrigin.CreateFromNode(node, PluginBase.PluginManager.FindWz)); }).ToArray(); Color color = Color.FromArgb(resNode.FindNodeByPath("clr").GetValueEx(-1)); //测试y轴大小 int offsetY = wce.Min(bmp => bmp.OpOrigin.Y); int height = wce.Max(bmp => bmp.Rectangle.Bottom); //测试宽度 var font = GearGraphics.ItemDetailFont2; var fmt = StringFormat.GenericTypographic; int width = string.IsNullOrEmpty(tagName) ? 0 : (int)Math.Ceiling(g.MeasureString(tagName, font, 261, fmt).Width); int left = picW / 2 - width / 2; int right = left + width; //开始绘制背景 picH -= offsetY; if (wce[0].Bitmap != null) { g.DrawImage(wce[0].Bitmap, left - wce[0].Origin.X, picH - wce[0].Origin.Y); } if (wce[1].Bitmap != null) //不用拉伸 用纹理平铺 看运气 { var brush = new TextureBrush(wce[1].Bitmap); Rectangle rect = new Rectangle(left, picH - wce[1].Origin.Y, right - left, brush.Image.Height); brush.TranslateTransform(rect.X, rect.Y); g.FillRectangle(brush, rect); brush.Dispose(); } if (wce[2].Bitmap != null) { g.DrawImage(wce[2].Bitmap, right - wce[2].Origin.X, picH - wce[2].Origin.Y); } //绘制文字 if (!string.IsNullOrEmpty(tagName)) { var brush = new SolidBrush(color); g.DrawString(tagName, font, brush, left, picH, fmt); brush.Dispose(); } picH += height; }
private void LoadInfo() { var m = Regex.Match(Node.Text, @"^(\d+)\.img$"); if (m.Success) { this.ID = Convert.ToInt32(m.Result("$1")); } Wz_Node infoNode = this.Node.FindNodeByPath("info"); if (infoNode == null) { return; } foreach (var node in infoNode.Nodes) { switch (node.Text) { case "islot": this.ISlot = node.GetValue <string>(); break; case "icon": this.Icon = BitmapOrigin.CreateFromNode(node, PluginBase.PluginManager.FindWz); break; } } }
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); }
private void CreateBone(Bone root, Wz_Node[] frameNodes, bool?bodyFace = null) { bool face = true; foreach (Wz_Node partNode in frameNodes) { Wz_Node linkPartNode = partNode; if (linkPartNode.Value is Wz_Uol) { linkPartNode = linkPartNode.GetValue <Wz_Uol>().HandleUol(linkPartNode); } foreach (Wz_Node childNode in linkPartNode.Nodes) //分析部件 { Wz_Node linkNode = childNode; if (childNode.Value is Wz_Uol) { linkNode = ((Wz_Uol)childNode.Value).HandleUol(linkNode); if (linkNode == null) { continue; } } if (childNode.Text == "hairShade") { linkNode = childNode.FindNodeByPath("0"); if (linkNode == null) { continue; } } if (linkNode.Value is Wz_Png) { //过滤纹理 switch (childNode.Text) { case "face": if (!(bodyFace ?? face)) { continue; } break; case "ear": if (!ShowEar) { continue; } break; case "hairOverHead": case "backHairOverCape": case "backHair": if (HairCover) { continue; } break; case "hair": case "backHairBelowCap": if (!HairCover) { continue; } break; case "hairShade": if (!ShowHairShade) { continue; } break; default: if (childNode.Text.StartsWith("weapon")) { //检查是否多武器颜色 if (linkNode.ParentNode.FindNodeByPath("weapon1") != null) { //只追加限定武器 string weaponName = "weapon" + (this.WeaponIndex == 0 ? "" : this.WeaponIndex.ToString()); if (childNode.Text != weaponName) { continue; } } } break; } //读取纹理 Skin skin = new Skin(); skin.Name = childNode.Text; skin.Image = BitmapOrigin.CreateFromNode(linkNode, PluginBase.PluginManager.FindWz); skin.Z = linkNode.FindNodeByPath("z").GetValueEx <string>(null); //读取骨骼 Wz_Node mapNode = linkNode.FindNodeByPath("map"); if (mapNode != null) { Bone parentBone = null; foreach (var map in mapNode.Nodes) { string mapName = map.Text; Point mapOrigin = map.GetValue <Wz_Vector>(); if (mapName == "muzzle") //特殊处理 忽略 { continue; } if (parentBone == null) //主骨骼 { parentBone = AppendBone(root, null, skin, mapName, mapOrigin); } else //级联骨骼 { AppendBone(root, parentBone, skin, mapName, mapOrigin); } } } else { root.Skins.Add(skin); } } else { switch (childNode.Text) { case "face": face = Convert.ToInt32(childNode.Value) != 0; break; } } } } }
public static Item CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { Item item = new Item(); int value; if (node == null || !Int32.TryParse(node.Text, out value) && !((value = node.Text.IndexOf(".img")) > -1 && Int32.TryParse(node.Text.Substring(0, value), out value))) { return(null); } item.ItemID = value; Wz_Node infoNode = node.FindNodeByPath("info"); if (infoNode != null) { Wz_Node pngNode; foreach (Wz_Node subNode in infoNode.Nodes) { switch (subNode.Text) { case "icon": pngNode = subNode; while (pngNode.Value is Wz_Uol) { Wz_Uol uol = pngNode.Value as Wz_Uol; Wz_Node uolNode = uol.HandleUol(subNode); if (uolNode != null) { pngNode = uolNode; } } if (pngNode.Value is Wz_Png) { item.Icon = BitmapOrigin.CreateFromNode(pngNode, findNode); } break; case "iconRaw": pngNode = subNode; while (pngNode.Value is Wz_Uol) { Wz_Uol uol = pngNode.Value as Wz_Uol; Wz_Node uolNode = uol.HandleUol(subNode); if (uolNode != null) { pngNode = uolNode; } } if (pngNode.Value is Wz_Png) { item.IconRaw = BitmapOrigin.CreateFromNode(pngNode, findNode); } break; case "sample": if (subNode.Value is Wz_Png) { item.Sample = BitmapOrigin.CreateFromNode(subNode, findNode); } break; case "lv": item.Level = Convert.ToInt32(subNode.Value); break; default: ItemPropType type; if (Enum.TryParse(subNode.Text, out type)) { try { item.Props.Add(type, Convert.ToInt32(subNode.Value)); } finally { } } break; } } } Wz_Node specNode = node.FindNodeByPath("spec"); if (specNode != null) { foreach (Wz_Node subNode in specNode.Nodes) { ItemSpecType type; if (Enum.TryParse(subNode.Text, out type)) { try { item.Specs.Add(type, Convert.ToInt32(subNode.Value)); } finally { } } } } return(item); }
public static Skill CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { Skill skill = new Skill(); int skillID; if (!Int32.TryParse(node.Text, out skillID)) { return(null); } skill.SkillID = skillID; foreach (Wz_Node childNode in node.Nodes) { switch (childNode.Text) { case "icon": skill.Icon = BitmapOrigin.CreateFromNode(childNode, findNode); break; case "iconMouseOver": skill.IconMouseOver = BitmapOrigin.CreateFromNode(childNode, findNode); break; case "iconDisabled": skill.IconDisabled = BitmapOrigin.CreateFromNode(childNode, findNode); break; case "common": foreach (Wz_Node commonNode in childNode.Nodes) { if (commonNode.Value != null && !(commonNode.Value is Wz_Vector)) { skill.common[commonNode.Text] = commonNode.Value.ToString(); } } break; case "PVPcommon": foreach (Wz_Node commonNode in childNode.Nodes) { if (commonNode.Value != null && !(commonNode.Value is Wz_Vector)) { skill.PVPcommon[commonNode.Text] = commonNode.Value.ToString(); } } break; case "level": for (int i = 1; ; i++) { Wz_Node levelNode = childNode.FindNodeByPath(i.ToString()); if (levelNode == null) { break; } Dictionary <string, string> levelInfo = new Dictionary <string, string>(); foreach (Wz_Node commonNode in levelNode.Nodes) { if (commonNode.Value != null && !(commonNode.Value is Wz_Vector)) { levelInfo[commonNode.Text] = commonNode.Value.ToString(); } } skill.levelCommon.Add(levelInfo); } break; case "hyper": skill.Hyper = (HyperSkillType)childNode.GetValue <int>(); break; case "invisible": skill.Invisible = childNode.GetValue <int>() != 0; break; case "combatOrders": skill.CombatOrders = childNode.GetValue <int>() != 0; break; case "notRemoved": skill.NotRemoved = childNode.GetValue <int>() != 0; break; case "masterLevel": skill.MasterLevel = childNode.GetValue <int>(); break; case "reqLev": skill.ReqLevel = childNode.GetValue <int>(); break; case "req": foreach (Wz_Node reqNode in childNode.Nodes) { if (reqNode.Text == "level") { skill.ReqLevel = reqNode.GetValue <int>(); } else if (reqNode.Text == "reqAmount") { skill.ReqAmount = reqNode.GetValue <int>(); } else { int reqSkill; if (Int32.TryParse(reqNode.Text, out reqSkill)) { skill.ReqSkill[reqSkill] = reqNode.GetValue <int>(); } } } break; case "action": for (int i = 0; ; i++) { Wz_Node idxNode = childNode.FindNodeByPath(i.ToString()); if (idxNode == null) { break; } skill.Action.Add(idxNode.GetValue <string>()); } break; } } //判定技能声明版本 skill.PreBBSkill = false; if (skill.levelCommon.Count > 0) { if (skill.common.Count <= 0 || (skill.common.Count == 1 && skill.common.ContainsKey("maxLevel"))) { skill.PreBBSkill = true; } } return(skill); }
//public LifeAnimateCollection Animates { get; private set; } public static Mob CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { int mobID; Match m = Regex.Match(node.Text, @"^(\d{7})\.img$"); if (!(m.Success && Int32.TryParse(m.Result("$1"), out mobID))) { return(null); } Mob mobInfo = new Mob(); mobInfo.ID = mobID; Wz_Node infoNode = node.FindNodeByPath("info"); //加载基础属性 if (infoNode != null) { foreach (var propNode in infoNode.Nodes) { switch (propNode.Text) { case "level": mobInfo.Level = propNode.GetValueEx <int>(0); break; case "defaultHP": mobInfo.DefaultHP = propNode.GetValueEx <string>(null); break; case "defaultMP": mobInfo.DefaultMP = propNode.GetValueEx <string>(null); break; case "finalmaxHP": mobInfo.FinalMaxHP = propNode.GetValueEx <string>(null); break; case "finalmaxMP": mobInfo.FinalMaxMP = propNode.GetValueEx <string>(null); break; case "maxHP": mobInfo.MaxHP = propNode.GetValueEx <long>(0); break; case "maxMP": mobInfo.MaxMP = propNode.GetValueEx <long>(0); break; case "hpRecovery": mobInfo.HPRecovery = propNode.GetValueEx <int>(0); break; case "mpRecovery": mobInfo.MPRecovery = propNode.GetValueEx <int>(0); break; case "speed": mobInfo.Speed = propNode.GetValueEx <int>(0); break; case "flySpeed": mobInfo.FlySpeed = propNode.GetValueEx <int>(0); break; case "PADamage": mobInfo.PADamage = propNode.GetValueEx <int>(0); break; case "MADamage": mobInfo.MADamage = propNode.GetValueEx <int>(0); break; case "PDRate": mobInfo.PDRate = propNode.GetValueEx <int>(0); break; case "MDRate": mobInfo.MDRate = propNode.GetValueEx <int>(0); break; case "acc": mobInfo.Acc = propNode.GetValueEx <int>(0); break; case "eva": mobInfo.Eva = propNode.GetValueEx <int>(0); break; case "pushed": mobInfo.Pushed = propNode.GetValueEx <int>(0); break; case "exp": mobInfo.Exp = propNode.GetValueEx <int>(0); break; case "boss": mobInfo.Boss = propNode.GetValueEx <int>(0) != 0; break; case "undead": mobInfo.Undead = propNode.GetValueEx <int>(0) != 0; break; case "firstAttack": mobInfo.FirstAttack = propNode.GetValueEx <int>(0) != 0; break; case "bodyAttack": mobInfo.BodyAttack = propNode.GetValueEx <int>(0) != 0; break; case "category": mobInfo.Category = propNode.GetValueEx <int>(0); break; case "removeAfter": mobInfo.RemoveAfter = propNode.GetValueEx <int>(0); break; case "damagedByMob": mobInfo.DamagedByMob = propNode.GetValueEx <int>(0) != 0; break; case "invincible": mobInfo.Invincible = propNode.GetValueEx <int>(0) != 0; break; case "notAttack": mobInfo.NotAttack = propNode.GetValueEx <int>(0) != 0; break; case "fixedDamage": mobInfo.FixedDamage = propNode.GetValueEx <int>(0); break; case "elemAttr": mobInfo.ElemAttr = new MobElemAttr(propNode.GetValueEx <string>(null)); break; case "link": mobInfo.Link = propNode.GetValueEx <int>(0); break; case "skeleton": mobInfo.Skeleton = propNode.GetValueEx <int>(0) != 0; break; case "jsonLoad": mobInfo.JsonLoad = propNode.GetValueEx <int>(0) != 0; break; //case "skill": LoadSkill(mobInfo, propNode); break; //case "attack": LoadAttack(mobInfo, propNode); break; //case "buff": LoadBuff(mobInfo, propNode); break; case "revive": for (int i = 0; ; i++) { var reviveNode = propNode.FindNodeByPath(i.ToString()); if (reviveNode == null) { break; } mobInfo.Revive.Add(reviveNode.GetValue <int>()); } break; } } } //读取怪物默认动作 { Wz_Node linkNode = null; if (mobInfo.Link != null && findNode != null) { linkNode = findNode(string.Format("Mob\\{0:d7}.img", mobInfo.Link)); } if (linkNode == null) { linkNode = node; } var imageFrame = new BitmapOrigin(); foreach (var action in new[] { "stand", "move", "fly" }) { var actNode = linkNode.FindNodeByPath(action + @"\0"); if (actNode != null) { imageFrame = BitmapOrigin.CreateFromNode(actNode, findNode); if (imageFrame.Bitmap != null) { break; } } } mobInfo.Default = imageFrame; } return(mobInfo); }
//public LifeAnimateCollection Animates { get; private set; } public static Npc CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { int npcID; Match m = Regex.Match(node.Text, @"^(\d{7})\.img$"); if (!(m.Success && Int32.TryParse(m.Result("$1"), out npcID))) { return(null); } Npc npcInfo = new Npc(); npcInfo.ID = npcID; Wz_Node infoNode = node.FindNodeByPath("info"); //加载基础属性 if (infoNode != null) { foreach (var propNode in infoNode.Nodes) { switch (propNode.Text) { case "shop": npcInfo.Shop = propNode.GetValueEx <int>(0) != 0; break; case "link": npcInfo.Link = propNode.GetValueEx <int>(0); break; case "default": npcInfo.Default = BitmapOrigin.CreateFromNode(propNode, null); break; } } } //读取默认图片 if (npcInfo.Default.Bitmap == null) { Wz_Node linkNode = null; if (npcInfo.Link != null && findNode != null) { linkNode = findNode(string.Format("Npc\\{0:d7}.img", npcInfo.Link)); } if (linkNode == null) { linkNode = node; } var imageFrame = new BitmapOrigin(); foreach (var action in new[] { "stand", "move", "fly" }) { var actNode = linkNode.FindNodeByPath(action + @"\0"); if (actNode != null) { imageFrame = BitmapOrigin.CreateFromNode(actNode, findNode); if (imageFrame.Bitmap != null) { break; } } } npcInfo.Default = imageFrame; } return(npcInfo); }