private void valueChangeLaplaceEvent() { bitmapResult = BitmapOrigin.Clone() as Bitmap; int[,,] color = new int[3, x, y]; int count = Model.Count; int start = count / 2; for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { int[] sumColor = new int[3] { 0, 0, 0 }; for (int w = 0; w < count; w++) { for (int h = 0; h < count; h++) { for (int c = 0; c < 3; c++) { sumColor[c] += Gray(bitmapResult.GetPixel(i + w - start, j + h - start), c) * Model[w][h]; } } } color[0, i, j] = sumColor[0]; color[1, i, j] = sumColor[1]; color[2, i, j] = sumColor[2]; } } // 标定 color = BDFunc(color); for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { bitmapResult.SetPixel(i, j, Color.FromArgb(color[0, i, j], color[1, i, j], color[2, i, j])); } } }
private void Math_Add() { x = BitmapO2.Width; y = BitmapO2.Height; int[,,] color = new int[3, x, y]; int start = 1; //叠加原图 for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { Color pixR = BitmapO2.GetPixel(i, j); Color pixO = BitmapOrigin.GetPixel(i, j); color[0, i, j] = (int)(pixR.R * c1 - pixO.R * c); color[1, i, j] = (int)(pixR.G * c1 - pixO.G * c); color[2, i, j] = (int)(pixR.B * c1 - pixO.B * c); } } for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { for (int c = 0; c < 3; c++) { color[c, i, j] = color[c, i, j] > 255 ? 255 : color[c, i, j]; color[c, i, j] = color[c, i, j] < 0 ? 0 : color[c, i, j]; } } } //color = RealBD(color); bitmapResult = new Bitmap(x, y); for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { bitmapResult.SetPixel(i, j, Color.FromArgb(color[0, i, j], color[1, i, j], color[2, i, j])); } } }
private void valueChangeEvent() { try { bitmapResult = BitmapOrigin.Clone() as Bitmap; int x = BitmapOrigin.Width / width; int y = BitmapOrigin.Height / height; int w = 0, h = 0; for (w = 0; w < x; w++) { for (h = 0; h < y; h++) { HE(w * width, h * height, (w + 1) * width, (h + 1) * height); } } HE((w + 1) * width, (h + 1) * height, bitmapResult.Width, BitmapOrigin.Height); } catch { MessageBox.Show("图片格式不支持"); } }
private void Math_MultiEvent() { if (BitmapOrigin.Size != BitmapO2.Size) { return; } x = BitmapO2.Width; y = BitmapO2.Height; bitmapResult = new Bitmap(x, y); for (int i = 0; i < bitmapResult.Width; i++) { for (int j = 0; j < bitmapResult.Height; j++) { var colorO = BitmapOrigin.GetPixel(i, j); var colorR = BitmapO2.GetPixel(i, j); int r = colorO.R * colorR.R / 255; int g = colorO.G * colorR.G / 255; int b = colorO.B * colorR.B / 255; bitmapResult.SetPixel(i, j, Color.FromArgb(r, g, b)); } } }
public void valueChangeBilateralEvent() { bitmapResult = BitmapOrigin.Clone() as Bitmap; double sum = 0; int count = Row; int start = count / 2; for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { if (IsRange(bitmapResult.GetPixel(i, j))) { double sumR = 0, sumG = 0, sumB = 0; double r = Gray(bitmapResult.GetPixel(i, j), 0) / 255.0; double g = Gray(bitmapResult.GetPixel(i, j), 1) / 255.0; double b = Gray(bitmapResult.GetPixel(i, j), 2) / 255.0; for (int w = 0; w < count; w++) { for (int h = 0; h < count; h++) { double c, p = Math.Pow(w - start, 2), q = Math.Pow(h - start, 2), w1; c = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 0) / 255.0; w1 = Math.Pow(Math.E, -(p + q) / (2 * sigma_d * sigma_d)) * Math.Pow(Math.E, -(Math.Pow(r - c, 2)) / (2 * sigma_r * sigma_r)); sumR += c * w1; c = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 1) / 255.0; sumG += c * w1; c = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 2) / 255.0; sumB += c * w1; sum += w1; } } bitmapResult.SetPixel(i, j, Color.FromArgb((int)(sumR * 255 / sum), (int)(sumG * 255 / sum), (int)(sumB * 255 / sum))); sum = 0; } } } }
private void valueChangeEvent() { bitmapResult = BitmapOrigin.Clone() as Bitmap; int x = BitmapOrigin.Width; int y = BitmapOrigin.Height; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { var color = bitmapResult.GetPixel(i, j); if (IsRange(color)) { double r = (double)(color.R) / 255; double g = (double)(color.G) / 255; double b = (double)(color.B) / 255; int sR = (int)(c * Math.Pow(r, gamma) * 255); int sG = (int)(c * Math.Pow(g, gamma) * 255); int sB = (int)(c * Math.Pow(b, gamma) * 255); bitmapResult.SetPixel(i, j, Color.FromArgb(sR, sG, sB)); } } } }
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); }
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); }
private void valueChangeUnsharp_MaskingEvent() { //Model = new List<int[]> { new int[3] { 1, 1, 1 }, new int[3] { 1, 1, 1 }, new int[3] { 1, 1, 1 } }; bitmapResult = BitmapOrigin.Clone() as Bitmap; int sum = 0; foreach (var item in Model) { foreach (var it in item) { sum += it; } } int count = Model.Count; int start = count / 2; for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { int sumR = 0, sumG = 0, sumB = 0; for (int w = 0; w < count; w++) { for (int h = 0; h < count; h++) { sumR += Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 0) * Model[w][h]; sumG += Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 1) * Model[w][h]; sumB += Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 2) * Model[w][h]; } } bitmapResult.SetPixel(i, j, Color.FromArgb(sumR / sum, sumG / sum, sumB / sum)); } } // 2 * BitmapOrigin - bitmapResult for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { int[] colorO = new int[3] { BitmapOrigin.GetPixel(i, j).R, BitmapOrigin.GetPixel(i, j).G, BitmapOrigin.GetPixel(i, j).B }; int[] colorR = new int[3] { bitmapResult.GetPixel(i, j).R, bitmapResult.GetPixel(i, j).G, bitmapResult.GetPixel(i, j).B }; int[] color = new int[3]; for (int c = 0; c < 3; c++) { color[c] = Range(2 * colorO[c] - colorR[c]); } bitmapResult.SetPixel(i, j, Color.FromArgb(color[0], color[1], color[2])); } } }
//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); }
public void AddCache(string key, BitmapOrigin bitmap) { this.bmpCache[key] = bitmap; }
private void valueChangeGradientEvent() { bitmapResult = BitmapOrigin.Clone() as Bitmap; int[,,] color = new int[3, x, y]; int[] max = new int[3] { 0, 0, 0 }; int[] min = new int[3] { 256, 256, 256 }; int[,,] M = new int[2, 3, 3] { { { -1, -2, -1 }, { 0, 0, 0 }, { 1, 2, 1 } }, { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } } }; int start = 1; int count = 3; for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { int[,] sumColor = new int[2, 3] { { 0, 0, 0 }, { 0, 0, 0 } }; for (int s = 0; s < 2; s++) { for (int w = 0; w < count; w++) { for (int h = 0; h < count; h++) { for (int c = 0; c < 3; c++) { sumColor[s, c] += Gray(bitmapResult.GetPixel(i + w - start, j + h - start), c) * M[s, w, h]; } } } sumColor[s, 0] = Math.Abs(sumColor[s, 0]); sumColor[s, 1] = Math.Abs(sumColor[s, 1]); sumColor[s, 2] = Math.Abs(sumColor[s, 2]); } color[0, i, j] = (sumColor[0, 0] + sumColor[1, 0]); color[1, i, j] = (sumColor[0, 1] + sumColor[1, 1]); color[2, i, j] = (sumColor[0, 2] + sumColor[1, 2]); } } color = BDFunc(color); //叠加原图 for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { bitmapResult.SetPixel(i, j, Color.FromArgb(color[0, i, j], color[1, i, j], color[2, i, j])); } } }
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 valueChangeMiddleEvent() { bitmapResult = BitmapOrigin.Clone() as Bitmap; int count = Model.Length; int start = count / 2; for (int i = start; i < x - start; i++) { for (int j = start; j < y - start; j++) { if (IsRange(bitmapResult.GetPixel(i, j))) { int[,] PixR = new int[count, count]; int[,] PixG = new int[count, count]; int[,] PixB = new int[count, count]; for (int w = 0; w < count; w++) { for (int h = 0; h < count; h++) { PixR[w, h] = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 0) * Model[w, h]; PixG[w, h] = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 1) * Model[w, h]; PixB[w, h] = Gray(bitmapResult.GetPixel(i + w - start, j + h - start), 2) * Model[w, h]; } } int middleR = PixR[0, 0], middleG = PixG[0, 0], middleB = PixB[0, 0]; int x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0; for (int m = 0; m < (count * count) / 2 + 1; m++) { middleR = 255; middleG = 255; middleB = 255; for (int n = 0; n < count; n++) { for (int l = 0; l < count; l++) { if (middleR > PixR[n, l]) { middleR = PixR[n, l]; x1 = n; x2 = l; } if (middleG > PixG[n, l]) { middleG = PixG[n, l]; x3 = n; x4 = l; } if (middleB > PixB[n, l]) { middleB = PixB[n, l]; x5 = n; x6 = l; } } } PixR[x1, x2] = 255; PixG[x3, x4] = 255; PixB[x5, x6] = 255; } bitmapResult.SetPixel(i, j, Color.FromArgb(middleR, middleG, middleB)); } } } }