示例#1
0
 private string GetDefaultString(Wz_Node node, string searchNodeText)
 {
     node = node.FindNodeByPath(searchNodeText);
     return(node == null ? null : Convert.ToString(node.Value));
 }
        public override Bitmap Render()
        {
            if (this.item == null)
            {
                return(null);
            }
            //绘制道具
            int    picHeight;
            Bitmap itemBmp       = RenderItem(out picHeight);
            Bitmap recipeInfoBmp = null;
            Bitmap recipeItemBmp = null;
            Bitmap setItemBmp    = null;

            //图纸相关
            int recipeID;

            if (this.item.Specs.TryGetValue(ItemSpecType.recipe, out recipeID))
            {
                int    recipeSkillID = recipeID / 10000;
                Recipe recipe        = null;
                //寻找配方
                Wz_Node recipeNode = PluginBase.PluginManager.FindWz(string.Format(@"Skill\Recipe_{0}.img\{1}", recipeSkillID, recipeID));
                if (recipeNode != null)
                {
                    recipe = Recipe.CreateFromNode(recipeNode);
                }
                //生成配方图像
                if (recipe != null)
                {
                    if (this.LinkRecipeInfo)
                    {
                        recipeInfoBmp = RenderLinkRecipeInfo(recipe);
                    }

                    if (this.LinkRecipeItem)
                    {
                        int itemID      = recipe.MainTargetItemID;
                        int itemIDClass = itemID / 1000000;
                        if (itemIDClass == 1) //通过ID寻找装备
                        {
                            Wz_Node charaWz = PluginManager.FindWz(Wz_Type.Character);
                            if (charaWz != null)
                            {
                                string imgName = itemID.ToString("d8") + ".img";
                                foreach (Wz_Node node0 in charaWz.Nodes)
                                {
                                    Wz_Node imgNode = node0.FindNodeByPath(imgName, true);
                                    if (imgNode != null)
                                    {
                                        Gear gear = Gear.CreateFromNode(imgNode, path => PluginManager.FindWz(path));
                                        if (gear != null)
                                        {
                                            recipeItemBmp = RenderLinkRecipeGear(gear);
                                        }

                                        break;
                                    }
                                }
                            }
                        }
                        else if (itemIDClass >= 2 && itemIDClass <= 5) //通过ID寻找道具
                        {
                            Wz_Node itemWz = PluginManager.FindWz(Wz_Type.Item);
                            if (itemWz != null)
                            {
                                string imgClass = (itemID / 10000).ToString("d4") + ".img\\" + itemID.ToString("d8");
                                foreach (Wz_Node node0 in itemWz.Nodes)
                                {
                                    Wz_Node imgNode = node0.FindNodeByPath(imgClass, true);
                                    if (imgNode != null)
                                    {
                                        Item item = Item.CreateFromNode(imgNode, PluginManager.FindWz);
                                        if (item != null)
                                        {
                                            recipeItemBmp = RenderLinkRecipeItem(item);
                                        }

                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            int setID;

            if (this.item.Props.TryGetValue(ItemPropType.setItemID, out setID))
            {
                SetItem setItem;
                if (CharaSimLoader.LoadedSetItems.TryGetValue(setID, out setItem))
                {
                    setItemBmp = RenderSetItem(setItem);
                }
            }

            //计算布局
            Size  totalSize        = new Size(itemBmp.Width, picHeight);
            Point recipeInfoOrigin = Point.Empty;
            Point recipeItemOrigin = Point.Empty;
            Point setItemOrigin    = Point.Empty;

            if (recipeItemBmp != null)
            {
                recipeItemOrigin.X = totalSize.Width;
                totalSize.Width   += recipeItemBmp.Width;

                if (recipeInfoBmp != null)
                {
                    recipeInfoOrigin.X = itemBmp.Width - recipeInfoBmp.Width;
                    recipeInfoOrigin.Y = picHeight;
                    totalSize.Height   = Math.Max(picHeight + recipeInfoBmp.Height, recipeItemBmp.Height);
                }
                else
                {
                    totalSize.Height = Math.Max(picHeight, recipeItemBmp.Height);
                }
            }
            else if (recipeInfoBmp != null)
            {
                totalSize.Width   += recipeInfoBmp.Width;
                totalSize.Height   = Math.Max(picHeight, recipeInfoBmp.Height);
                recipeInfoOrigin.X = itemBmp.Width;
            }
            if (setItemBmp != null)
            {
                setItemOrigin    = new Point(totalSize.Width, 0);
                totalSize.Width += setItemBmp.Width;
                totalSize.Height = Math.Max(totalSize.Height, setItemBmp.Height);
            }

            //开始绘制
            Bitmap   tooltip = new Bitmap(totalSize.Width, totalSize.Height);
            Graphics g       = Graphics.FromImage(tooltip);

            if (itemBmp != null)
            {
                //绘制背景区域
                GearGraphics.DrawNewTooltipBack(g, 0, 0, itemBmp.Width, picHeight);
                //复制图像
                g.DrawImage(itemBmp, 0, 0, new Rectangle(0, 0, itemBmp.Width, picHeight), GraphicsUnit.Pixel);
                //左上角
                g.DrawImage(Resource.UIToolTip_img_Item_Frame2_cover, 3, 3);

                if (this.ShowObjectID)
                {
                    GearGraphics.DrawGearDetailNumber(g, 3, 3, item.ItemID.ToString("d8"), true);
                }
            }

            //绘制配方
            if (recipeInfoBmp != null)
            {
                g.DrawImage(recipeInfoBmp, recipeInfoOrigin.X, recipeInfoOrigin.Y,
                            new Rectangle(Point.Empty, recipeInfoBmp.Size), GraphicsUnit.Pixel);
            }

            //绘制产出道具
            if (recipeItemBmp != null)
            {
                g.DrawImage(recipeItemBmp, recipeItemOrigin.X, recipeItemOrigin.Y,
                            new Rectangle(Point.Empty, recipeItemBmp.Size), GraphicsUnit.Pixel);
            }

            //绘制套装
            if (setItemBmp != null)
            {
                g.DrawImage(setItemBmp, setItemOrigin.X, setItemOrigin.Y,
                            new Rectangle(Point.Empty, setItemBmp.Size), GraphicsUnit.Pixel);
            }

            if (itemBmp != null)
            {
                itemBmp.Dispose();
            }
            if (recipeInfoBmp != null)
            {
                recipeInfoBmp.Dispose();
            }
            if (recipeItemBmp != null)
            {
                recipeItemBmp.Dispose();
            }
            if (setItemBmp != null)
            {
                setItemBmp.Dispose();
            }

            g.Dispose();
            return(tooltip);
        }
示例#3
0
        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 "vSkill":
                    skill.VSkill = 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);
        }
示例#4
0
        private void LoadCode(string code, int loadType)
        {
            //解析
            var matches = Regex.Matches(code, @"(\d+)([,\s]|$)");

            if (matches.Count <= 0)
            {
                MessageBoxEx.Show("아이템 코드에 해당되는 아이템이 없습니다.", "오류");
                return;
            }

            var characWz = PluginManager.FindWz(Wz_Type.Character);

            if (characWz == null)
            {
                MessageBoxEx.Show("Character.wz 파일을 열 수 없습니다.", "오류");
                return;
            }

            //试图初始化
            if (!this.inited && !this.AvatarInit())
            {
                MessageBoxEx.Show("코디네이션 플러그인을 초기화할 수 없습니다.", "오류");
                return;
            }

            if (loadType == 0) //先清空。。
            {
                Array.Clear(this.avatar.Parts, 0, this.avatar.Parts.Length);
            }

            List <int> failList = new List <int>();

            foreach (Match m in matches)
            {
                int gearID;
                if (Int32.TryParse(m.Result("$1"), out gearID))
                {
                    Wz_Node imgNode = FindNodeByGearID(characWz, gearID);
                    if (imgNode != null)
                    {
                        var part = this.avatar.AddPart(imgNode);
                        OnNewPartAdded(part);
                    }
                    else
                    {
                        failList.Add(gearID);
                    }
                }
            }

            //刷新
            this.FillAvatarParts();
            this.UpdateDisplay();

            //其他提示
            if (failList.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("해당 아이템 코드를 찾을 수 없습니다 : ");
                foreach (var gearID in failList)
                {
                    sb.Append("  ").AppendLine(gearID.ToString("D8"));
                }
                MessageBoxEx.Show(sb.ToString(), "오류");
            }
        }
示例#5
0
 private bool TryGetNickResource(int nickTag, out Wz_Node resNode)
 {
     resNode = PluginBase.PluginManager.FindWz("UI/NameTag.img/nick/" + nickTag);
     return(resNode != null);
 }
示例#6
0
        private Bitmap RenderSetItem(out int picHeight)
        {
            Bitmap       setBitmap = new Bitmap(261, DefaultPicHeight);
            Graphics     g         = Graphics.FromImage(setBitmap);
            StringFormat format    = new StringFormat();

            format.Alignment = StringAlignment.Center;

            picHeight = 10;
            g.DrawString(this.SetItem.SetItemName, GearGraphics.ItemDetailFont2, GearGraphics.GreenBrush2, 130, 10, format);
            picHeight += 25;

            format.Alignment = StringAlignment.Far;
            Wz_Node characterWz = PluginManager.FindWz(Wz_Type.Character);

            foreach (var setItemPart in this.SetItem.ItemIDs.Parts)
            {
                string itemName = setItemPart.Value.RepresentName;
                string typeName = setItemPart.Value.TypeName;

                if (string.IsNullOrEmpty(typeName) && SetItem.Parts)
                {
                    typeName = "特殊";
                }

                ItemBase itemBase    = null;
                bool     cash        = false;
                int      wonderGrade = 0;

                if (setItemPart.Value.ItemIDs.Count > 0)
                {
                    var itemID = setItemPart.Value.ItemIDs.First().Key;

                    switch (itemID / 1000000)
                    {
                    case 0:     //avatar
                    case 1:     //gear
                        if (characterWz != null)
                        {
                            foreach (Wz_Node typeNode in characterWz.Nodes)
                            {
                                Wz_Node itemNode = typeNode.FindNodeByPath(string.Format("{0:D8}.img", itemID), true);
                                if (itemNode != null)
                                {
                                    var gear = Gear.CreateFromNode(itemNode, PluginManager.FindWz);
                                    cash     = gear.Cash;
                                    itemBase = gear;
                                    break;
                                }
                            }
                        }
                        break;

                    case 5:     //Pet
                    {
                        Wz_Node itemNode = PluginBase.PluginManager.FindWz(string.Format(@"Item\Pet\{0:D7}.img", itemID));
                        if (itemNode != null)
                        {
                            var item = Item.CreateFromNode(itemNode, PluginManager.FindWz);
                            cash = item.Cash;
                            item.Props.TryGetValue(ItemPropType.wonderGrade, out wonderGrade);
                            itemBase = item;
                        }
                    }
                    break;
                    }
                }

                if (string.IsNullOrEmpty(itemName) || string.IsNullOrEmpty(typeName))
                {
                    if (setItemPart.Value.ItemIDs.Count > 0)
                    {
                        var          itemID = setItemPart.Value.ItemIDs.First().Key;
                        StringResult sr     = null;;
                        if (this.StringLinker != null)
                        {
                            if (this.StringLinker.StringEqp.TryGetValue(itemID, out sr))
                            {
                                itemName = sr.Name;
                                if (typeName == null)
                                {
                                    typeName = ItemStringHelper.GetSetItemGearTypeString(Gear.GetGearType(itemID));
                                }
                            }
                            else if (this.StringLinker.StringItem.TryGetValue(itemID, out sr)) //兼容宠物
                            {
                                itemName = sr.Name;
                                if (typeName == null)
                                {
                                    if (itemID / 10000 == 500)
                                    {
                                        typeName = "特殊";
                                    }
                                    else
                                    {
                                        typeName = "";
                                    }
                                }
                            }
                        }
                        if (sr == null)
                        {
                            itemName = "(null)";
                        }
                    }
                }

                itemName = itemName ?? string.Empty;
                typeName = typeName ?? "裝備";

                if (!Regex.IsMatch(typeName, @"^(\(.*\)|(.*))$"))
                {
                    typeName = "(" + typeName + ")";
                }

                Brush brush = setItemPart.Value.Enabled ? Brushes.White : GearGraphics.GrayBrush2;
                if (!cash)
                {
                    g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 8, picHeight);
                    g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format);
                    picHeight += 18;
                }
                else
                {
                    g.FillRectangle(GearGraphics.GearIconBackBrush2, 10, picHeight, 36, 36);
                    g.DrawImage(Resource.Item_shadow, 10 + 2 + 3, picHeight + 2 + 32 - 6);
                    if (itemBase?.IconRaw.Bitmap != null)
                    {
                        var icon = itemBase.IconRaw;
                        g.DrawImage(icon.Bitmap, 10 + 2 - icon.Origin.X, picHeight + 2 + 32 - icon.Origin.Y);
                    }

                    Bitmap cashImg = null;
                    if (wonderGrade > 0)
                    {
                        string resKey = $"CashShop_img_CashItem_label_{wonderGrade + 3}";
                        cashImg = Resource.ResourceManager.GetObject(resKey) as Bitmap;
                    }
                    if (cashImg == null) //default cashImg
                    {
                        cashImg = Resource.CashItem_0;
                    }
                    g.DrawImage(cashImg, 10 + 2 + 20, picHeight + 2 + 32 - 12);
                    g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 50, picHeight);
                    g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format);
                    picHeight += 40;
                }
            }

            if (!this.SetItem.ExpandToolTip)
            {
                picHeight += 5;
                g.DrawLine(Pens.White, 6, picHeight, 254, picHeight);//分割线
                picHeight += 9;
                RenderEffect(g, ref picHeight);
            }
            picHeight += 11;

            format.Dispose();
            g.Dispose();
            return(setBitmap);
        }
示例#7
0
        public DataSet GenerateSkillTable()
        {
            Wz_Node skillWz = PluginManager.FindWz(Wz_Type.Skill);

            if (skillWz == null)
            {
                return(null);
            }

            Regex r = new Regex(@"^(\d+)\.img", RegexOptions.Compiled);

            DataSet   ds       = new DataSet();
            DataTable jobTable = new DataTable("ms_job");

            jobTable.Columns.Add("jobID", typeof(string));
            jobTable.Columns.Add("jobName", typeof(string));

            DataTable skillTable = new DataTable("ms_skill");

            skillTable.Columns.Add("jobID", typeof(string));
            skillTable.Columns.Add("skillID", typeof(string));
            skillTable.Columns.Add("skillName", typeof(string));
            skillTable.Columns.Add("skillDesc", typeof(string));
            skillTable.Columns.Add("maxLevel", typeof(int));
            skillTable.Columns.Add("invisible", typeof(bool));
            skillTable.Columns.Add("hyper", typeof(int));
            skillTable.Columns.Add("reqSkill", typeof(string));
            skillTable.Columns.Add("reqSkillLevel", typeof(int));
            skillTable.Columns.Add("reqLevel", typeof(int));

            DataTable skillLevelTable = new DataTable("ms_skillLevel");

            skillLevelTable.Columns.Add("skillID", typeof(string));
            skillLevelTable.Columns.Add("level", typeof(int));
            skillLevelTable.Columns.Add("levelDesc", typeof(string));

            DataTable skillCommonTable = new DataTable("ms_skillCommon");

            skillCommonTable.Columns.Add("skillID", typeof(string));
            skillCommonTable.Columns.Add("commonName", typeof(string));
            skillCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillPVPCommonTable = new DataTable("ms_skillPVPCommon");

            skillPVPCommonTable.Columns.Add("skillID", typeof(string));
            skillPVPCommonTable.Columns.Add("commonName", typeof(string));
            skillPVPCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillHTable = new DataTable("ms_skillH");

            skillHTable.Columns.Add("skillID", typeof(string));
            skillHTable.Columns.Add("desc", typeof(string));
            skillHTable.Columns.Add("pdesc", typeof(string));
            skillHTable.Columns.Add("h", typeof(string));
            skillHTable.Columns.Add("ph", typeof(string));
            skillHTable.Columns.Add("hch", typeof(string));

            StringResult sr;

            foreach (Wz_Node node in skillWz.Nodes)
            {
                //获取职业
                Match    m   = r.Match(node.Text);
                Wz_Image img = node.GetValue <Wz_Image>(null);
                if (!m.Success)
                {
                    continue;
                }
                if (img == null || !img.TryExtract())
                {
                    continue;
                }
                //导入职业
                string jobID = m.Result("$1");
                sl.StringSkill2.TryGetValue(jobID, out sr);
                jobTable.Rows.Add(jobID, (sr != null ? sr["bookName"] : null));

                //获取技能
                Wz_Node skillListNode = img.Node.FindNodeByPath("skill");
                if (skillListNode == null || skillListNode.Nodes.Count <= 0)
                {
                    continue;
                }

                foreach (Wz_Node skillNode in skillListNode.Nodes)
                {
                    Skill skill = Skill.CreateFromNode(skillNode, PluginManager.FindWz);
                    if (skill == null)
                    {
                        continue;
                    }

                    // if (skill.Invisible) //过滤不可见技能
                    //     continue;

                    //导入技能
                    string skillID = skillNode.Text;
                    sl.StringSkill2.TryGetValue(skillID, out sr);

                    string reqSkill      = null;
                    int    reqSkillLevel = 0;
                    if (skill.ReqSkill.Count > 0)
                    {
                        foreach (var kv in skill.ReqSkill)
                        {
                            reqSkill      = kv.Key.ToString();
                            reqSkillLevel = kv.Value;
                        }
                    }

                    skillTable.Rows.Add(
                        jobID,
                        skillID,
                        sr != null ? sr.Name : null,
                        sr != null ? sr.Desc : null,
                        skill.MaxLevel,
                        skill.Invisible,
                        skill.Hyper,
                        reqSkill,
                        reqSkillLevel,
                        skill.ReqLevel
                        );


                    if (!skill.PreBBSkill)
                    {
                        //导入技能common
                        foreach (var kv in skill.Common)
                        {
                            skillCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        foreach (var kv in skill.PVPcommon)
                        {
                            skillPVPCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        //导入技能说明
                        skillHTable.Rows.Add(
                            skillID,
                            sr != null ? sr["desc"] : null,
                            sr != null ? sr["pdesc"] : null,
                            sr != null ? sr["h"] : null,
                            sr != null ? sr["ph"] : null,
                            sr != null ? sr["hch"] : null
                            );
                    }

                    //导入技能等级
                    for (int i = 1, j = skill.MaxLevel + (skill.CombatOrders ? 2 : 0); i <= j; i++)
                    {
                        skill.Level = i;
                        string levelDesc = SummaryParser.GetSkillSummary(skill, sr, SummaryParams.Default);
                        skillLevelTable.Rows.Add(
                            skillID,
                            i,
                            levelDesc);
                    }
                }

                img.Unextract();
            }

            ds.Tables.Add(jobTable);
            ds.Tables.Add(skillTable);
            ds.Tables.Add(skillLevelTable);
            ds.Tables.Add(skillCommonTable);
            ds.Tables.Add(skillPVPCommonTable);
            ds.Tables.Add(skillHTable);
            return(ds);
        }
示例#8
0
        private Wz_Node[] LinkPlayerParts(ActionFrame bodyAction, ActionFrame faceAction)
        {
            //寻找所有部件
            List <Wz_Node> partNode = new List <Wz_Node>();

            //链接人
            if (this.Body != null && this.Head != null && bodyAction != null &&
                this.Body.Visible && this.Head.Visible)
            {
                //身体
                Wz_Node bodyNode = FindBodyActionNode(bodyAction);
                partNode.Add(bodyNode);

                //头部
                bool?face = bodyAction.Face;          //扩展动作规定头部
                if (face == null && bodyNode != null) //链接的body内规定
                {
                    Wz_Node propNode = bodyNode.FindNodeByPath("face");
                    if (propNode != null)
                    {
                        face = propNode.GetValue <int>(0) != 0;
                    }
                }

                if (face ?? false)
                {
                    ActionFrame headAction = new ActionFrame()
                    {
                        Action = "front"
                    };
                    partNode.Add(FindActionFrameNode(this.Head.Node, headAction));
                }
                else
                {
                    partNode.Add(FindActionFrameNode(this.Head.Node, bodyAction));
                }

                //脸
                if (this.Face != null && this.Face.Visible && faceAction != null)
                {
                    partNode.Add(FindActionFrameNode(this.Face.Node, faceAction));
                }
                //毛
                if (this.Hair != null && this.Hair.Visible)
                {
                    if (face ?? false)
                    {
                        ActionFrame headAction = new ActionFrame()
                        {
                            Action = "default"
                        };
                        partNode.Add(FindActionFrameNode(this.Hair.Node, headAction));
                    }
                    else
                    {
                        partNode.Add(FindActionFrameNode(this.Hair.Node, bodyAction));
                    }
                }
                //其他部件
                for (int i = 4; i < 16; i++)
                {
                    var part = this.Parts[i];
                    if (part != null && part.Visible)
                    {
                        if (i == 12 && Gear.GetGearType(part.ID.Value) == GearType.cashWeapon) //点装武器
                        {
                            var wpNode = part.Node.FindNodeByPath(this.WeaponType.ToString());
                            partNode.Add(FindActionFrameNode(wpNode, bodyAction));
                        }
                        else if (i == 14) //脸
                        {
                            partNode.Add(FindActionFrameNode(part.Node, faceAction));
                        }
                        else //其他部件
                        {
                            partNode.Add(FindActionFrameNode(part.Node, bodyAction));
                        }
                    }
                }
            }

            partNode.RemoveAll(node => node == null);

            return(partNode.ToArray());
        }
示例#9
0
        public AvatarPart AddPart(Wz_Node imgNode)
        {
            Wz_Node infoNode = imgNode.FindNodeByPath("info");

            if (infoNode == null)
            {
                return(null);
            }
            AvatarPart part = new AvatarPart(imgNode);

            var gearType = Gear.GetGearType(part.ID.Value);

            switch (gearType)
            {
            case GearType.body: this.Body = part; break;

            case GearType.head: this.Head = part; break;

            case GearType.face: this.Face = part; break;

            case GearType.hair:
            case GearType.hair2: this.Hair = part; break;

            case GearType.cap: this.Cap = part; break;

            case GearType.coat: this.Coat = part; break;

            case GearType.longcoat: this.Longcoat = part; break;

            case GearType.pants: this.Pants = part; break;

            case GearType.shoes: this.Shoes = part; break;

            case GearType.glove: this.Glove = part; break;

            case GearType.shield:
            case GearType.demonShield:
            case GearType.soulShield:
            case GearType.katara: this.SubWeapon = part; break;

            case GearType.cape: this.Cape = part; break;

            case GearType.shovel:
            case GearType.pickaxe:
            case GearType.cashWeapon: this.Weapon = part; break;

            case GearType.earrings: this.Earrings = part; break;

            case GearType.faceAccessory: this.FaceAccessory = part; break;

            case GearType.eyeAccessory: this.EyeAccessory = part; break;

            case GearType.taming:
            case GearType.taming2:
            case GearType.taming3:
            case GearType.tamingChair: this.Taming = part; break;

            case GearType.saddle: this.Saddle = part; break;

            default:
                if (Gear.IsWeapon(gearType))
                {
                    this.Weapon = part;
                }
                break;
            }

            return(part);
        }
示例#10
0
        private void LoadBack()
        {
            Wz_Node mapWz = PluginManager.FindWz(Wz_Type.Map);
            Dictionary <string, RenderFrame>   loadedBackRes = new Dictionary <string, RenderFrame>();
            Dictionary <string, RenderFrame[]> loadedFrames  = new Dictionary <string, RenderFrame[]>();

            if (mapWz == null)
            {
                return;
            }
            Wz_Node backLstNode = mapImg.Node.FindNodeByPath("back");

            if (backLstNode != null)
            {
                string[] path = new string[4];

                foreach (Wz_Node node in backLstNode.Nodes)
                {
                    Wz_Node x               = node.FindNodeByPath("x"),
                                 y          = node.FindNodeByPath("y"),
                                 bs         = node.FindNodeByPath("bS"),
                                 ani        = node.FindNodeByPath("ani"),
                                 no         = node.FindNodeByPath("no"),
                                 f          = node.FindNodeByPath("f"),
                                 front      = node.FindNodeByPath("front"),
                                 type       = node.FindNodeByPath("type"),
                                 cx         = node.FindNodeByPath("cx"),
                                 cy         = node.FindNodeByPath("cy"),
                                 rx         = node.FindNodeByPath("rx"),
                                 ry         = node.FindNodeByPath("ry"),
                                 a          = node.FindNodeByPath("a"),
                                 screenMode = node.FindNodeByPath("screenMode");

                    if (bs != null && no != null)
                    {
                        bool _ani  = ani.GetValueEx <int>(0) != 0;
                        int  _type = type.GetValueEx <int>(0);

                        path[0] = "Back";
                        path[1] = bs.GetValue <string>() + ".img";
                        path[2] = _ani ? "ani" : "back";
                        path[3] = no.GetValue <string>();

                        string key = string.Join("\\", path);

                        RenderFrame[] frames;
                        if (!loadedFrames.TryGetValue(key, out frames))
                        {
                            Wz_Node objResNode = mapWz.FindNodeByPath(true, path);
                            if (objResNode == null)
                            {
                                continue;
                            }
                            frames            = LoadFrames(objResNode, loadedBackRes);
                            loadedFrames[key] = frames;
                        }

                        BackPatch patch = new BackPatch();
                        patch.ObjectType = front.GetValueEx <int>(0) != 0 ? RenderObjectType.Front : RenderObjectType.Back;
                        patch.Position   = new Vector2(x.GetValueEx <int>(0), y.GetValueEx <int>(0));
                        patch.Cx         = cx.GetValueEx <int>(0);
                        patch.Cy         = cy.GetValueEx <int>(0);
                        patch.Rx         = rx.GetValueEx <int>(0);
                        patch.Ry         = ry.GetValueEx <int>(0);
                        patch.Frames     = new RenderAnimate(frames);
                        patch.Flip       = f.GetValueEx <int>(0) != 0;
                        patch.TileMode   = GetBackTileMode(_type);
                        patch.Alpha      = a.GetValueEx <int>(255);
                        patch.ScreenMode = screenMode.GetValueEx <int>(0);

                        patch.ZIndex[0] = (int)patch.ObjectType;
                        Int32.TryParse(node.Text, out patch.ZIndex[1]);

                        patch.Name = string.Format("back_{0}", node.Text);

                        if (patch.ObjectType == RenderObjectType.Back)
                        {
                            this.Back.Nodes.Add(patch);
                        }
                        else if (patch.ObjectType == RenderObjectType.Front)
                        {
                            this.Front.Nodes.Add(patch);
                        }
                    }
                } // end foreach

                this.Back.Nodes.Sort();
                this.Front.Nodes.Sort();
            }
        }
示例#11
0
        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;
                        if (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;
                        if (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;

                    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);
        }
示例#12
0
        public void Load(Wz_Node mapImgNode, ResourceLoader resLoader)
        {
            var infoNode = mapImgNode.Nodes["info"];

            if (infoNode == null)
            {
                throw new Exception("Cannot find map info node.");
            }

            //试图读取ID
            LoadIDOrName(mapImgNode);
            //加载基本信息
            LoadInfo(infoNode);
            //读取link
            if (this.Link != null && !FindMapByID(this.Link.Value, out mapImgNode))
            {
                throw new Exception("Cannot find or extract map link node.");
            }

            //加载小地图
            Wz_Node node;

            if (!string.IsNullOrEmpty(this.MapMark))
            {
                node = PluginManager.FindWz("Map\\MapHelper.img\\mark\\" + this.MapMark);
                if (node != null)
                {
                    node = node.GetLinkedSourceNode(PluginManager.FindWz);
                    this.MiniMap.MapMark = resLoader.Load <Texture2D>(node);
                }
            }
            if ((node = mapImgNode.Nodes["miniMap"]) != null)
            {
                LoadMinimap(node, resLoader);
            }

            //加载地图元件
            if ((node = mapImgNode.Nodes["back"]) != null)
            {
                LoadBack(node);
            }
            for (int i = 0; i <= 7; i++)
            {
                if ((node = mapImgNode.Nodes[i.ToString()]) != null)
                {
                    LoadLayer(node, i);
                }
            }
            if ((node = mapImgNode.Nodes["foothold"]) != null)
            {
                for (int i = 0; i <= 7; i++)
                {
                    var fhLevel = node.Nodes[i.ToString()];
                    if (fhLevel != null)
                    {
                        LoadFoothold(fhLevel, i);
                    }
                }
            }
            if ((node = mapImgNode.Nodes["life"]) != null)
            {
                LoadLife(node);
            }
            if ((node = mapImgNode.Nodes["reactor"]) != null)
            {
                LoadReactor(node);
            }
            if ((node = mapImgNode.Nodes["portal"]) != null)
            {
                LoadPortal(node);
            }
            if ((node = mapImgNode.Nodes["ladderRope"]) != null)
            {
                LoadLadderRope(node);
            }
            if ((node = mapImgNode.Nodes["skyWhale"]) != null)
            {
                LoadSkyWhale(node);
            }
            if ((node = mapImgNode.Nodes["ToolTip"]) != null)
            {
                LoadTooltip(node);
            }
            if ((node = mapImgNode.Nodes["particle"]) != null)
            {
                LoadParticle(node);
            }

            //计算地图大小
            CalcMapSize();
        }
示例#13
0
 public SpineAnimationData LoadSpineAnimation(Wz_Node node)
 {
     return(SpineAnimationData.CreateFromNode(node, null, this.GraphicsDevice, PluginBase.PluginManager.FindWz));
 }
示例#14
0
 public FrameAnimationData LoadFrameAnimation(Wz_Node node)
 {
     return(FrameAnimationData.CreateFromNode(node, this.GraphicsDevice, PluginBase.PluginManager.FindWz));
 }
示例#15
0
 public SpineTextureLoader(ResourceLoader resLoader, Wz_Node topNode)
 {
     this.BaseLoader = resLoader;
     this.TopNode    = topNode;
 }
示例#16
0
        private void CreateBone(Bone root, Wz_Node[] frameNodes, bool?bodyFace = null)
        {
            bool face = true;

            foreach (Wz_Node partNode in frameNodes)
            {
                Wz_Node linkPartNode = partNode;
                while (linkPartNode.Value is Wz_Uol)
                {
                    linkPartNode = linkPartNode.GetValue <Wz_Uol>().HandleUol(linkPartNode);
                }

                foreach (Wz_Node childNode in linkPartNode.Nodes) //分析部件
                {
                    Wz_Node linkNode = childNode;
                    while (linkNode?.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 (this.EarType != 1)
                            {
                                continue;
                            }
                            break;

                        case "lefEar": if (this.EarType != 2)
                            {
                                continue;
                            }
                            break;

                        case "highlefEar": if (this.EarType != 3)
                            {
                                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);
                        var zNode = linkNode.FindNodeByPath("z");
                        if (zNode != null)
                        {
                            var val = zNode.Value;
                            if (val is int)
                            {
                                skin.ZIndex = (int)val;
                            }
                            else
                            {
                                skin.Z = zNode.GetValue <string>();
                            }
                        }

                        //读取骨骼
                        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;
                        }
                    }
                }
            }
        }
示例#17
0
 public virtual T Load <T>(Wz_Node node)
 {
     return(Load <T>(node, null));
 }
示例#18
0
        //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 <int>(0); break;

                    case "maxMP": mobInfo.MaxMP = propNode.GetValueEx <int>(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);
        }
示例#19
0
        private Bitmap RenderSetItem(out int picHeight)
        {
            Bitmap       setBitmap = new Bitmap(261, DefaultPicHeight);
            Graphics     g         = Graphics.FromImage(setBitmap);
            StringFormat format    = new StringFormat();

            format.Alignment = StringAlignment.Center;

            picHeight = 10;
            g.DrawString(this.SetItem.SetItemName, GearGraphics.ItemDetailFont2, GearGraphics.GreenBrush2, 130, 10, format);
            picHeight += 25;

            format.Alignment = StringAlignment.Far;

            Wz_Node characterWz = PluginManager.FindWz(Wz_Type.Character);

            foreach (var setItemPart in this.SetItem.ItemIDs.Parts)
            {
                string itemName = setItemPart.Value.RepresentName;
                string typeName = setItemPart.Value.TypeName;

                Gear gear = null;

                if (characterWz != null)
                {
                    foreach (var itemID in setItemPart.Value.ItemIDs)
                    {
                        foreach (Wz_Node typeNode in characterWz.Nodes)
                        {
                            Wz_Node itemNode = typeNode.FindNodeByPath(string.Format("{0:D8}.img", itemID.Key), true);
                            if (itemNode != null)
                            {
                                gear = Gear.CreateFromNode(itemNode, PluginManager.FindWz);
                                break;
                            }
                        }

                        break;
                    }
                }

                if (string.IsNullOrEmpty(typeName) && SetItem.Parts)
                {
                    typeName = "装备";
                }

                if (string.IsNullOrEmpty(itemName) || string.IsNullOrEmpty(typeName))
                {
                    foreach (var itemID in setItemPart.Value.ItemIDs)
                    {
                        StringResult sr = null;;
                        if (StringLinker != null)
                        {
                            if (StringLinker.StringEqp.TryGetValue(itemID.Key, out sr))
                            {
                                itemName = sr.Name;
                                if (typeName == null)
                                {
                                    typeName = ItemStringHelper.GetSetItemGearTypeString(Gear.GetGearType(itemID.Key));
                                }
                            }
                            else if (StringLinker.StringItem.TryGetValue(itemID.Key, out sr)) //兼容宠物
                            {
                                itemName = sr.Name;
                                if (typeName == null)
                                {
                                    if (itemID.Key / 10000 == 500)
                                    {
                                        typeName = "宠物";
                                    }
                                    else
                                    {
                                        typeName = "";
                                    }
                                }
                            }
                        }
                        if (sr == null)
                        {
                            itemName = "(null)";
                        }

                        break;
                    }
                }

                itemName = itemName ?? string.Empty;
                typeName = typeName ?? "装备";

                if (!Regex.IsMatch(typeName, @"^(\(.*\)|(.*))$"))
                {
                    typeName = "(" + typeName + ")";
                }

                Brush brush = setItemPart.Value.Enabled ? Brushes.White : GearGraphics.GrayBrush2;
                if (gear == null || !gear.Cash)
                {
                    g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 8, picHeight);
                    g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format);
                    picHeight += 18;
                }
                else
                {
                    g.FillRectangle(GearGraphics.GearIconBackBrush2, 10, picHeight, 36, 36);
                    g.DrawImage(Resource.Item_shadow, 10 + 2 + 3, picHeight + 2 + 32 - 6);
                    if (gear != null && gear.IconRaw.Bitmap != null)
                    {
                        g.DrawImage(gear.IconRaw.Bitmap, 10 + 2 - gear.IconRaw.Origin.X, picHeight + 2 + 32 - gear.IconRaw.Origin.Y);
                    }
                    g.DrawImage(Resource.CashItem_0, 10 + 2 + 20, picHeight + 2 + 32 - 12);
                    g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 50, picHeight);
                    g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format);
                    picHeight += 40;
                }
            }

            if (!this.SetItem.ExpandToolTip)
            {
                picHeight += 5;
                g.DrawLine(Pens.White, 6, picHeight, 254, picHeight);//分割线
                picHeight += 9;
                RenderEffect(g, ref picHeight);
            }
            picHeight += 11;

            format.Dispose();
            g.Dispose();
            return(setBitmap);
        }
示例#20
0
 public WzVirtualNode(Wz_Node wzNode) : this()
 {
     this.Name = wzNode.Text;
     this.LinkNodes.Add(wzNode);
 }
示例#21
0
        public void ExportSkillOption(string outputDir)
        {
            Wz_Node skillOption = PluginBase.PluginManager.FindWz("Item/SkillOption.img");
            Wz_Node itemOption  = PluginBase.PluginManager.FindWz("Item/ItemOption.img");
            Wz_Node item0259    = PluginBase.PluginManager.FindWz("Item/Consume/0259.img");
            Wz_Node skill8000   = PluginBase.PluginManager.FindWz("Skill/8000.img/skill");

            if (skillOption == null || itemOption == null || item0259 == null || skill8000 == null)
            {
                return;
            }

            ItemTooltipRender2 itemRender = new ItemTooltipRender2();

            itemRender.StringLinker = this.sl;
            itemRender.ShowObjectID = true;
            SkillTooltipRender2 skillRender = new SkillTooltipRender2();

            skillRender.StringLinker = this.sl;
            skillRender.ShowObjectID = true;
            skillRender.ShowDelay    = true;

            string skillImageDir = Path.Combine(outputDir, "skills");
            string itemImageDir  = Path.Combine(outputDir, "items");

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }
            if (!Directory.Exists(skillImageDir))
            {
                Directory.CreateDirectory(skillImageDir);
            }
            if (!Directory.Exists(itemImageDir))
            {
                Directory.CreateDirectory(itemImageDir);
            }

            StringResult sr;

            FileStream   fs = new FileStream(Path.Combine(outputDir, "SkillOption.html"), FileMode.Create);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);

            try
            {
                sw.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
                sw.WriteLine("<html>");
                sw.WriteLine("<head>");
                sw.WriteLine("<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">");
                sw.WriteLine("<title>魂武器系统</title>");
                sw.WriteLine(@"<style type=""text/css"">");
                sw.WriteLine("table, tr, th, td { font-size:12px; border-collapse:collapse; border:1px solid #c0c0c0; }");
                sw.WriteLine("td { padding:4px 5px; }");
                sw.WriteLine(@"</style>");
                sw.WriteLine("</head>");
                sw.WriteLine("<body>");

                foreach (Wz_Node node in item0259.Nodes)
                {
                    int itemID;
                    if (Int32.TryParse(node.Text, out itemID) && itemID / 1000 == 2591) //02591___
                    {
                        sw.WriteLine(@"<table style=""width:500px; ""><tbody>");
                        sl.StringItem.TryGetValue(itemID, out sr);
                        if (sr != null)
                        {
                            sw.WriteLine(@"<tr style=""background-color:#ffcccc; ""><td>道具名称</td><td>{0} (id:{1})</td></tr>", sr == null ? "null" : sr.Name, itemID);
                        }

                        Item item = Item.CreateFromNode(node);
                        if (item != null)
                        {
                            itemRender.Item = item;
                            string imageName = Path.Combine(itemImageDir, item.ItemID + ".png");
                            if (!File.Exists(imageName))
                            {
                                Bitmap itemImage = itemRender.Render();
                                itemImage.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
                                itemImage.Dispose();
                            }
                            sw.WriteLine(@"<tr><td>道具图片</td><td><img src=""items/{0}.png"" title=""{0}"" /></td></tr>", item.ItemID);
                        }

                        Wz_Node skillOptionNode = skillOption.FindNodeByPath("skill\\" + (itemID % 1000 + 1));
                        if (skillOptionNode != null)
                        {
                            int     skillId     = skillOptionNode.Nodes["skillId"].GetValueEx <int>(-1);
                            int     reqLevel    = skillOptionNode.Nodes["reqLevel"].GetValueEx <int>(-1);
                            int     incTableId  = skillOptionNode.Nodes["incTableID"].GetValueEx <int>(-1);
                            int     incRTableId = skillOptionNode.Nodes["incRTableID"].GetValueEx <int>(-1);
                            Wz_Node incNode     = null;
                            string  per         = null;
                            if (incTableId >= 0)
                            {
                                incNode = skillOption.FindNodeByPath("inc\\" + incTableId);
                            }
                            else if (incRTableId >= 0)
                            {
                                incNode = skillOption.FindNodeByPath("incR\\" + incRTableId);
                                per     = "%";
                            }
                            if (incNode != null)
                            {
                                sw.WriteLine(@"<tr><td rowspan=""3"">魂珠属性</td><td>阶段{0}: 提升物攻/魔攻 + {1}{2}</td></tr>", incNode.Nodes[0].Text, incNode.Nodes[0].Value, per);
                                sw.WriteLine(@"<tr><td>...</td></tr>");
                                sw.WriteLine(@"<tr><td>阶段{0}: 提升物攻/魔攻 + {1}{2}</td></tr>", incNode.Nodes[incNode.Nodes.Count - 1].Text, incNode.Nodes[incNode.Nodes.Count - 1].Value, per);
                            }

                            sw.WriteLine("<tr><td>需求等级</td><td>{0}</td></tr>", reqLevel);
                            sl.StringSkill.TryGetValue(skillId, out sr);
                            if (sr != null)
                            {
                                sw.WriteLine("<tr><td>技能名称</td><td>{0} (id:{1})</td></tr>", sr == null ? "null" : sr.Name, skillId);
                            }

                            Skill skill = Skill.CreateFromNode(skill8000.Nodes[skillId.ToString("D7")], PluginManager.FindWz);
                            if (skill != null)
                            {
                                skill.Level       = skill.MaxLevel;
                                skillRender.Skill = skill;

                                string imageName = Path.Combine(skillImageDir, skill.SkillID + ".png");
                                if (!File.Exists(imageName))
                                {
                                    Bitmap skillImage = skillRender.Render();
                                    skillImage.Save(Path.Combine(skillImageDir, skill.SkillID + ".png"), System.Drawing.Imaging.ImageFormat.Png);
                                    skillImage.Dispose();
                                }
                                sw.WriteLine(@"<tr><td>技能图片</td><td><img src=""skills/{0}.png"" title=""{0}"" /></td></tr>", skill.SkillID);
                            }

                            List <KeyValuePair <int, Potential> > tempOptions = new List <KeyValuePair <int, Potential> >();
                            int     totalProb      = 0;
                            Wz_Node tempOptionNode = skillOptionNode.Nodes["tempOption"];

                            if (tempOptionNode != null)
                            {
                                foreach (Wz_Node optionNode in tempOptionNode.Nodes)
                                {
                                    int id   = optionNode.Nodes["id"].GetValueEx <int>(-1);
                                    int prob = optionNode.Nodes["prob"].GetValueEx <int>(-1);
                                    if (id >= 0 && prob >= 0)
                                    {
                                        Potential optionItem = Potential.CreateFromNode(itemOption.Nodes[id.ToString("000000")], (reqLevel + 9) / 10);
                                        if (optionItem != null)
                                        {
                                            totalProb += prob;
                                            tempOptions.Add(new KeyValuePair <int, Potential>(prob, optionItem));
                                        }
                                    }
                                }
                            }

                            if (tempOptions.Count > 0)
                            {
                                for (int i = 0; i < tempOptions.Count; i++)
                                {
                                    KeyValuePair <int, Potential> opt = tempOptions[i];
                                    sw.Write("<tr>");
                                    if (i == 0)
                                    {
                                        sw.Write(@"<td rowspan=""{0}"">附加属性</td>", tempOptions.Count);
                                    }
                                    sw.WriteLine("<td>{0} &nbsp; &nbsp;[潜能代码:{1:D6}, 获得几率:{2}/{3}({4:P2})])</td></tr>", opt.Value.ConvertSummary(),
                                                 opt.Value.code, opt.Key, totalProb, (1.0 * opt.Key / totalProb));
                                }
                            }
                        }

                        sw.WriteLine("</tbody></table><br/>");
                    }
                }

                sw.WriteLine("</body>");
                sw.WriteLine("</html>");
            }
            finally
            {
                sw.Close();
            }
        }
示例#22
0
 public void AddChild(Wz_Node wzNode)
 {
     this.AddChild(wzNode, false);
 }
示例#23
0
        private Bitmap RenderItem(out int picH)
        {
            Bitmap       tooltip = new Bitmap(290, DefaultPicHeight);
            Graphics     g       = Graphics.FromImage(tooltip);
            StringFormat format  = (StringFormat)StringFormat.GenericDefault.Clone();
            int          value;

            picH = 10;
            //物品标题
            StringResult sr;

            if (StringLinker == null || !StringLinker.StringItem.TryGetValue(item.ItemID, out sr))
            {
                sr      = new StringResult();
                sr.Name = "(null)";
            }

            SizeF titleSize = g.MeasureString(sr.Name, GearGraphics.ItemNameFont2, short.MaxValue, format);

            titleSize.Width += 12 * 2;
            if (titleSize.Width > 290)
            {
                //重构大小
                g.Dispose();
                tooltip.Dispose();

                tooltip = new Bitmap((int)Math.Ceiling(titleSize.Width), DefaultPicHeight);
                g       = Graphics.FromImage(tooltip);
                picH    = 10;
            }

            //绘制标题
            bool hasPart2 = false;

            format.Alignment = StringAlignment.Center;
            g.DrawString(sr.Name, GearGraphics.ItemNameFont2, Brushes.White, tooltip.Width / 2, picH, format);
            picH += 22;

            //额外特性
            string attr = GetItemAttributeString();

            if (!string.IsNullOrEmpty(attr))
            {
                g.DrawString(attr, GearGraphics.ItemDetailFont, GearGraphics.GearNameBrushC, tooltip.Width / 2, picH, format);
                picH    += 19;
                hasPart2 = true;
            }

            string expireTime = null;

            if (item.Props.TryGetValue(ItemPropType.permanent, out value) && value != 0)
            {
                expireTime = ItemStringHelper.GetItemPropString(ItemPropType.permanent, value);
            }
            else if (item.Props.TryGetValue(ItemPropType.life, out value) && value > 0)
            {
                DateTime time = DateTime.Now.AddDays(value);
                expireTime = time.ToString("魔法时间:到 yyyy年 M月 d日 H时");
            }
            if (!string.IsNullOrEmpty(expireTime))
            {
                g.DrawString(expireTime, GearGraphics.ItemDetailFont, Brushes.White, tooltip.Width / 2, picH, format);
                picH    += 16;
                hasPart2 = true;
            }

            if (hasPart2)
            {
                picH += 1;
            }

            //装备限时
            if (item.TimeLimited)
            {
                DateTime time      = DateTime.Now.AddDays(7d);
                string   expireStr = time.ToString("到yyyy年 M月 d日 H时 m分可以用");
                g.DrawString(expireStr, GearGraphics.ItemDetailFont, Brushes.White, tooltip.Width / 2, picH, format);
                picH += 21;
            }

            //绘制图标
            int iconY = picH;
            int iconX = 14;

            g.DrawImage(Resource.UIToolTip_img_Item_ItemIcon_base, iconX, picH);
            if (item.Icon.Bitmap != null)
            {
                g.DrawImage(GearGraphics.EnlargeBitmap(item.Icon.Bitmap),
                            iconX + 6 + (1 - item.Icon.Origin.X) * 2,
                            picH + 6 + (33 - item.Icon.Origin.Y) * 2);
            }
            if (item.Cash)
            {
                Bitmap cashImg = null;

                if (item.Props.TryGetValue(ItemPropType.wonderGrade, out value) && value > 0)
                {
                    string resKey = $"CashShop_img_CashItem_label_{value + 3}";
                    cashImg = Resource.ResourceManager.GetObject(resKey) as Bitmap;
                }
                if (cashImg == null) //default cashImg
                {
                    cashImg = Resource.CashItem_0;
                }

                g.DrawImage(GearGraphics.EnlargeBitmap(cashImg),
                            iconX + 6 + 68 - 26,
                            picH + 6 + 68 - 26);
            }
            g.DrawImage(Resource.UIToolTip_img_Item_ItemIcon_cover, iconX + 4, picH + 4); //绘制左上角cover

            if (item.Props.TryGetValue(ItemPropType.reqLevel, out value))
            {
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                g.DrawString("要求等级 :" + value, GearGraphics.ItemReqLevelFont, Brushes.White, 97, picH);
                picH += 15;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            }
            else
            {
                picH += 3;
            }

            int right = tooltip.Width - 18;

            string desc = null;

            if (item.Level > 0)
            {
                desc += $"[LV.{item.Level}] ";
            }
            desc += sr.Desc;
            if (!string.IsNullOrEmpty(desc))
            {
                GearGraphics.DrawString(g, desc, GearGraphics.ItemDetailFont2, 100, right, ref picH, 16);
            }
            if (!string.IsNullOrEmpty(sr.AutoDesc))
            {
                GearGraphics.DrawString(g, sr.AutoDesc, GearGraphics.ItemDetailFont2, 100, right, ref picH, 16);
            }
            if (item.Props.TryGetValue(ItemPropType.tradeAvailable, out value) && value > 0)
            {
                attr = ItemStringHelper.GetItemPropString(ItemPropType.tradeAvailable, value);
                if (!string.IsNullOrEmpty(attr))
                {
                    GearGraphics.DrawString(g, "#c" + attr + "#", GearGraphics.ItemDetailFont2, 100, right, ref picH, 16);
                }
            }
            if (item.Specs.TryGetValue(ItemSpecType.recipeValidDay, out value) && value > 0)
            {
                GearGraphics.DrawString(g, "(可制作时间:" + value + "天)", GearGraphics.ItemDetailFont, 100, right, ref picH, 16);
            }
            if (item.Specs.TryGetValue(ItemSpecType.recipeUseCount, out value) && value > 0)
            {
                GearGraphics.DrawString(g, "(可制作次数:" + value + "次)", GearGraphics.ItemDetailFont, 100, right, ref picH, 16);
            }

            picH += 3;

            Wz_Node nickResNode     = null;
            bool    willDrawNickTag = this.ShowNickTag &&
                                      this.Item.Props.TryGetValue(ItemPropType.nickTag, out value) &&
                                      this.TryGetNickResource(value, out nickResNode);
            string descLeftAlign = sr["desc_leftalign"];

            if (!string.IsNullOrEmpty(descLeftAlign) || item.Sample.Bitmap != null || willDrawNickTag)
            {
                if (picH < iconY + 84)
                {
                    picH = iconY + 84;
                }
                if (!string.IsNullOrEmpty(descLeftAlign))
                {
                    picH += 12;
                    GearGraphics.DrawString(g, descLeftAlign, GearGraphics.ItemDetailFont, 14, right, ref picH, 16);
                }
                if (item.Sample.Bitmap != null)
                {
                    g.DrawImage(item.Sample.Bitmap, (tooltip.Width - item.Sample.Bitmap.Width) / 2, picH);
                    picH += item.Sample.Bitmap.Height;
                    picH += 2;
                }
                if (nickResNode != null)
                {
                    //获取称号名称
                    string nickName;
                    string nickWithQR = sr["nickWithQR"];
                    if (nickWithQR != null)
                    {
                        string qrDefault = sr["qrDefault"] ?? string.Empty;
                        nickName = Regex.Replace(nickWithQR, "#qr.*?#", qrDefault);
                    }
                    else
                    {
                        nickName = sr.Name;
                    }
                    GearGraphics.DrawNameTag(g, nickResNode, nickName, tooltip.Width, ref picH);
                    picH += 4;
                }
            }


            //绘制配方需求
            if (item.Specs.TryGetValue(ItemSpecType.recipe, out value))
            {
                int reqSkill, reqSkillLevel;
                if (!item.Specs.TryGetValue(ItemSpecType.reqSkill, out reqSkill))
                {
                    reqSkill = value / 10000 * 10000;
                }

                if (!item.Specs.TryGetValue(ItemSpecType.reqSkillLevel, out reqSkillLevel))
                {
                    reqSkillLevel = 1;
                }

                picH = Math.Max(picH, iconY + 107);
                g.DrawLine(Pens.White, 6, picH, 283, picH);//分割线
                picH += 10;
                g.DrawString("<使用限制条件>", GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 8, picH);
                picH += 17;

                //技能标题
                if (StringLinker == null || !StringLinker.StringSkill.TryGetValue(reqSkill, out sr))
                {
                    sr      = new StringResult();
                    sr.Name = "(null)";
                }
                g.DrawString(string.Format("· {0}{1}级以上", sr.Name, reqSkillLevel), GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 13, picH);
                picH += 16;
                picH += 6;
            }

            picH = Math.Max(iconY + 94, picH + 6);
            return(tooltip);
        }
示例#24
0
 public CompareDifference(Wz_Node nodeNew, Wz_Node nodeOld, DifferenceType type)
 {
     this.NodeNew        = nodeNew;
     this.NodeOld        = nodeOld;
     this.DifferenceType = type;
 }
示例#25
0
        public static SetItem CreateFromNode(Wz_Node setItemNode, Wz_Node optionNode)
        {
            if (setItemNode == null)
            {
                return(null);
            }

            SetItem setItem = new SetItem();

            Dictionary <string, string> desc = new Dictionary <string, string>();

            foreach (Wz_Node subNode in setItemNode.Nodes)
            {
                switch (subNode.Text)
                {
                case "setItemName":
                    setItem.setItemName = Convert.ToString(subNode.Value);
                    break;

                case "completeCount":
                    setItem.completeCount = Convert.ToInt32(subNode.Value);
                    break;

                case "ItemID":
                    foreach (Wz_Node itemNode in subNode.Nodes)
                    {
                        int idx = Convert.ToInt32(itemNode.Text);
                        if (itemNode.Nodes.Count == 0)
                        {
                            int itemID = Convert.ToInt32(itemNode.Value);
                            setItem.itemIDs.Add(idx, new SetItemIDPart(itemID));
                        }
                        else
                        {
                            SetItemIDPart part = new SetItemIDPart();
                            int           num;
                            foreach (Wz_Node itemNode2 in itemNode.Nodes)
                            {
                                switch (itemNode2.Text)
                                {
                                case "representName":
                                    part.RepresentName = Convert.ToString(itemNode2.Value);
                                    break;

                                case "typeName":
                                    part.TypeName = Convert.ToString(itemNode2.Value);
                                    break;

                                default:
                                    if (Int32.TryParse(itemNode2.Text, out num) && num > 0)
                                    {
                                        part.ItemIDs[Convert.ToInt32(itemNode2.Value)] = false;
                                    }
                                    break;
                                }
                            }
                            setItem.itemIDs.Add(idx, part);
                        }
                    }
                    break;

                case "Effect":
                    foreach (Wz_Node effectNode in subNode.Nodes)
                    {
                        int           count  = Convert.ToInt32(effectNode.Text);
                        SetItemEffect effect = new SetItemEffect();
                        foreach (Wz_Node propNode in effectNode.Nodes)
                        {
                            switch (propNode.Text)
                            {
                            case "Option":
                                if (optionNode != null)
                                {
                                    List <Potential> potens = new List <Potential>();
                                    foreach (Wz_Node pNode in propNode.Nodes)
                                    {
                                        string  optText = Convert.ToString(pNode.FindNodeByPath("option").Value).PadLeft(6, '0');
                                        Wz_Node opn     = optionNode.FindNodeByPath(optText);
                                        if (opn == null)
                                        {
                                            continue;
                                        }
                                        Potential p = Potential.CreateFromNode(opn, Convert.ToInt32(pNode.FindNodeByPath("level").Value));
                                        if (p != null)
                                        {
                                            potens.Add(p);
                                        }
                                    }
                                    effect.Props.Add(GearPropType.Option, potens);
                                }
                                break;

                            case "OptionToMob":
                                List <SetItemOptionToMob> opToMobList = new List <SetItemOptionToMob>();
                                for (int i = 1; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    SetItemOptionToMob option = new SetItemOptionToMob();

                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "mob":
                                            foreach (Wz_Node mobNode in pNode.Nodes)
                                            {
                                                option.Mobs.Add(mobNode.GetValue <int>());
                                            }
                                            break;

                                        case "mobName":
                                            option.MobName = pNode.GetValue <string>();
                                            break;

                                        default:
                                        {
                                            GearPropType type;
                                            if (Enum.TryParse(pNode.Text, out type))
                                            {
                                                option.Props.Add(type, pNode.GetValue <int>());
                                            }
                                        }
                                        break;
                                        }
                                    }

                                    opToMobList.Add(option);
                                }
                                effect.Props.Add(GearPropType.OptionToMob, opToMobList);
                                break;

                            case "activeSkill":
                                List <SetItemActiveSkill> activeSkillList = new List <SetItemActiveSkill>();
                                for (int i = 0; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    SetItemActiveSkill activeSkill = new SetItemActiveSkill();
                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "id":
                                            activeSkill.SkillID = pNode.GetValue <int>();
                                            break;

                                        case "level":
                                            activeSkill.Level = pNode.GetValue <int>();
                                            break;
                                        }
                                    }
                                    activeSkillList.Add(activeSkill);
                                }
                                effect.Props.Add(GearPropType.activeSkill, activeSkillList);
                                break;

                            default:
                            {
                                GearPropType type;
                                if (Enum.TryParse(propNode.Text, out type))
                                {
                                    effect.Props.Add(type, Convert.ToInt32(propNode.Value));
                                }
                            }
                            break;
                            }
                        }
                        setItem.effects.Add(count, effect);
                    }
                    break;

                case "Desc":
                    foreach (var descNode in subNode.Nodes)
                    {
                        desc[descNode.Text] = Convert.ToString(descNode.Value);
                    }
                    break;
                }
            }

            //处理额外分组
            if (desc.Count > 0)
            {
                foreach (var kv in desc)
                {
                    SetItemIDPart combinePart     = null;
                    string        combineTypeName = null;
                    switch (kv.Key)
                    {
                    case "weapon":
                        combinePart     = CombinePart(setItem, gearID => Gear.IsWeapon(Gear.GetGearType(gearID)));
                        combineTypeName = ItemStringHelper.GetSetItemGearTypeString(GearType.weapon);
                        break;

                    case "subweapon":
                        combinePart     = CombinePart(setItem, gearID => Gear.IsSubWeapon(Gear.GetGearType(gearID)));
                        combineTypeName = ItemStringHelper.GetSetItemGearTypeString(GearType.subWeapon);
                        break;
                    }

                    if (combinePart != null)
                    {
                        combinePart.RepresentName = kv.Value;
                        combinePart.TypeName      = combineTypeName; ItemStringHelper.GetSetItemGearTypeString(GearType.weapon);
                    }
                }
            }


            return(setItem);
        }
示例#26
0
 public WzNodeAgent(Wz_Node target)
 {
     this.Target = target;
 }
示例#27
0
        void btnItem_Click(object sender, EventArgs e)
        {
            Wz_Node node = Context.SelectedNode1;

            if (node != null)
            {
                Wz_Image img    = node.Value as Wz_Image;
                Wz_File  wzFile = node.GetNodeWzFile();

                if (img != null && img.TryExtract())
                {
                    if (wzFile == null || wzFile.Type != Wz_Type.Map)
                    {
                        if (MessageBoxEx.Show("所选Img不属于Map.wz,是否继续?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                        {
                            goto exit;
                        }
                    }

                    StringLinker sl = this.Context.DefaultStringLinker;
                    if (!sl.HasValues) //生成默认stringLinker
                    {
                        sl = new StringLinker();
                        sl.Load(PluginManager.FindWz(Wz_Type.String).GetValueEx <Wz_File>(null));
                    }

                    //开始绘制
                    Thread thread = new Thread(() =>
                    {
#if !DEBUG
                        try
                        {
#endif
#if MapRenderV1
                        if (sender == btnItemMapRender)
                        {
                            if (this.mapRenderGame1 != null)
                            {
                                return;
                            }
                            this.mapRenderGame1 = new FrmMapRender(img)
                            {
                                StringLinker = sl
                            };
                            try
                            {
                                using (this.mapRenderGame1)
                                {
                                    this.mapRenderGame1.Run();
                                }
                            }
                            finally
                            {
                                this.mapRenderGame1 = null;
                            }
                        }
                        else
#endif
                        {
                            if (this.mapRenderGame2 != null)
                            {
                                return;
                            }
                            this.mapRenderGame2 = new FrmMapRender2(img)
                            {
                                StringLinker = sl
                            };
                            this.mapRenderGame2.Window.Title = "MapRender " + this.Version;
                            try
                            {
                                using (this.mapRenderGame2)
                                {
                                    this.mapRenderGame2.Run();
                                }
                            }
                            finally
                            {
                                this.mapRenderGame2 = null;
                            }
                        }
#if !DEBUG
                    }
                                               catch (Exception ex)
                    {
                        MessageBoxEx.Show(ex.ToString(), "MapRender");
                    }
#endif
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.IsBackground = true;
                    thread.Start();
                    goto exit;
                }
            }

            MessageBoxEx.Show("没有选择一个map的img", "MapRender");

exit:
            return;
        }
示例#28
0
        public ParticleDesc LoadParticleDesc(Wz_Node node)
        {
            var desc = new ParticleDesc();

            desc.Name = node.Text;
            foreach (var pNode in node.Nodes)
            {
                switch (pNode.Text)
                {
                case "totalParticle": desc.TotalParticle = pNode.GetValue <int>(); break;

                case "angle": desc.Angle = pNode.GetValue <float>(); break;

                case "angleVar": desc.AngleVar = pNode.GetValue <float>(); break;

                case "duration": desc.Duration = pNode.GetValue <float>(); break;

                case "blendFuncSrc": desc.BlendFuncSrc = (ParticleBlendFunc)pNode.GetValue <int>(); break;

                case "blendFuncDst": desc.BlendFuncDst = (ParticleBlendFunc)pNode.GetValue <int>(); break;

                case "startColor": desc.StartColor = System.Drawing.Color.FromArgb(pNode.GetValue <int>()).ToXnaColor(); break;

                case "startColorVar": desc.StartColorVar = System.Drawing.Color.FromArgb(pNode.GetValue <int>()).ToXnaColor(); break;

                case "endColor": desc.EndColor = System.Drawing.Color.FromArgb(pNode.GetValue <int>()).ToXnaColor(); break;

                case "endColorVar": desc.EndColorVar = System.Drawing.Color.FromArgb(pNode.GetValue <int>()).ToXnaColor(); break;

                case "MiddlePoint0": desc.MiddlePoint0 = pNode.GetValue <int>(); break;

                case "MiddlePointAlpha0": desc.MiddlePointAlpha0 = pNode.GetValue <int>(); break;

                case "MiddlePoint1": desc.MiddlePoint1 = pNode.GetValue <int>(); break;

                case "MiddlePointAlpha1": desc.MiddlePointAlpha1 = pNode.GetValue <int>(); break;

                case "startSize": desc.StartSize = pNode.GetValue <float>(); break;

                case "startSizeVar": desc.StartSizeVar = pNode.GetValue <float>(); break;

                case "endSize": desc.EndSize = pNode.GetValue <float>(); break;

                case "endSizeVar": desc.EndSizeVar = pNode.GetValue <float>(); break;

                case "posX": desc.PosX = pNode.GetValue <float>(); break;

                case "posY": desc.PosY = pNode.GetValue <float>(); break;

                case "posVarX": desc.PosVarX = pNode.GetValue <float>(); break;

                case "posVarY": desc.PosVarY = pNode.GetValue <float>(); break;

                case "startSpin": desc.StartSpin = pNode.GetValue <float>(); break;

                case "startSpinVar": desc.StartSpinVar = pNode.GetValue <float>(); break;

                case "endSpin": desc.EndSpin = pNode.GetValue <float>(); break;

                case "endSpinVar": desc.EndSpinVar = pNode.GetValue <float>(); break;

                case "GRAVITY":
                {
                    var gravityDesc = new ParticleGravityDesc();
                    foreach (var pNode2 in pNode.Nodes)
                    {
                        switch (pNode2.Text)
                        {
                        case "x": gravityDesc.X = pNode2.GetValue <float>(); break;

                        case "y": gravityDesc.Y = pNode2.GetValue <float>(); break;

                        case "speed": gravityDesc.Speed = pNode2.GetValue <float>(); break;

                        case "speedVar": gravityDesc.SpeedVar = pNode2.GetValue <float>(); break;

                        case "radialAccel": gravityDesc.RadialAccel = pNode2.GetValue <float>(); break;

                        case "radialAccelVar": gravityDesc.RadialAccelVar = pNode2.GetValue <float>(); break;

                        case "tangentialAccel": gravityDesc.TangentialAccel = pNode2.GetValue <float>(); break;

                        case "tangentialAccelVar": gravityDesc.TangentialAccelVar = pNode2.GetValue <float>(); break;

                        case "rotationIsDir": gravityDesc.RotationIsDir = pNode2.GetValue <int>() != 0; break;
                        }
                    }
                    desc.Gravity = gravityDesc;
                }
                break;

                case "RADIUS":
                {
                    var radiusDesc = new ParticleRadiusDesc();
                    foreach (var pNode2 in pNode.Nodes)
                    {
                        switch (pNode2.Text)
                        {
                        case "startRadius": radiusDesc.StartRadius = pNode2.GetValue <float>(); break;

                        case "startRadiusVar": radiusDesc.StartRadiusVar = pNode2.GetValue <float>(); break;

                        case "endRadius": radiusDesc.EndRadius = pNode2.GetValue <float>(); break;

                        case "endRadiusVar": radiusDesc.EndRadiusVar = pNode2.GetValue <float>(); break;

                        case "rotatePerSecond": radiusDesc.RotatePerSecond = pNode2.GetValue <float>(); break;

                        case "rotatePerSecondVar": radiusDesc.RotatePerSecondVar = pNode2.GetValue <float>(); break;
                        }
                    }
                    desc.Radius = radiusDesc;
                }
                break;

                case "life": desc.Life = pNode.GetValue <float>(); break;

                case "lifeVar": desc.LifeVar = pNode.GetValue <float>(); break;

                case "opacityModifyRGB": desc.OpacityModifyRGB = pNode.GetValue <int>() != 0; break;

                case "positionType": desc.PositionType = pNode.GetValue <int>(); break;

                case "texture":
                    desc.Texture = this.LoadFrame(pNode);
                    break;
                }
            }
            return(desc);
        }
示例#29
0
        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;

                    case "onlyUpgrade":
                        int upgradeItemID = subNode.Nodes["0"]?.GetValueEx(0) ?? 0;
                        gear.Props.Add(GearPropType.onlyUpgrade, upgradeItemID);
                        break;

                    case "epic":
                        Wz_Node hsNode = subNode.Nodes["hs"];
                        if (hsNode != null)
                        {
                            gear.EpicHs = Convert.ToString(hsNode.Value);
                        }
                        break;

                    case "gatherTool":
                        foreach (Wz_Node gatherNode in subNode.Nodes)
                        {
                            GearPropType type;
                            if (Enum.TryParse(subNode.Text + "_" + gatherNode.Text, out type))
                            {
                                try
                                {
                                    gear.Props.Add(type, Convert.ToInt32(gatherNode.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);
        }
示例#30
0
        public static LifeInfo CreateFromNode(Wz_Node mobNode)
        {
            if (mobNode == null)
            {
                return(null);
            }

            var lifeInfo = new LifeInfo();
            var infoNode = mobNode.Nodes["info"];

            if (infoNode != null)
            {
                foreach (Wz_Node node in infoNode.Nodes)
                {
                    switch (node.Text)
                    {
                    case "level": lifeInfo.level = node.GetValueEx <int>(0); break;

                    case "maxHP": lifeInfo.maxHP = node.GetValueEx <int>(0); break;

                    case "maxMP": lifeInfo.maxMP = node.GetValueEx <int>(0); break;

                    case "speed": lifeInfo.speed = node.GetValueEx <int>(0); break;

                    case "PADamage": lifeInfo.PADamage = node.GetValueEx <int>(0); break;

                    case "PDDamage": lifeInfo.PDDamage = node.GetValueEx <int>(0); break;

                    case "PDRate": lifeInfo.PDRate = node.GetValueEx <int>(0); break;

                    case "MADamage": lifeInfo.MADamage = node.GetValueEx <int>(0); break;

                    case "MDDamage": lifeInfo.MDDamage = node.GetValueEx <int>(0); break;

                    case "MDRate": lifeInfo.MDRate = node.GetValueEx <int>(0); break;

                    case "acc": lifeInfo.acc = node.GetValueEx <int>(0); break;

                    case "eva": lifeInfo.eva = node.GetValueEx <int>(0); break;

                    case "pushed": lifeInfo.pushed = node.GetValueEx <int>(0); break;

                    case "exp": lifeInfo.exp = node.GetValueEx <int>(0); break;

                    case "undead": lifeInfo.undead = node.GetValueEx <int>(0) != 0; break;

                    case "boss": lifeInfo.boss = node.GetValueEx <int>(0) != 0; break;

                    case "elemAttr":
                        string elem = node.GetValueEx <string>(string.Empty);
                        for (int i = 0; i < elem.Length; i += 2)
                        {
                            LifeInfo.ElemResistance resist = (LifeInfo.ElemResistance)(elem[i + 1] - 48);
                            switch (elem[i])
                            {
                            case 'I': lifeInfo.elemAttr.I = resist; break;

                            case 'L': lifeInfo.elemAttr.L = resist; break;

                            case 'F': lifeInfo.elemAttr.F = resist; break;

                            case 'S': lifeInfo.elemAttr.S = resist; break;

                            case 'H': lifeInfo.elemAttr.H = resist; break;

                            case 'D': lifeInfo.elemAttr.D = resist; break;

                            case 'P': lifeInfo.elemAttr.P = resist; break;
                            }
                        }
                        break;
                    }
                }
            }
            return(lifeInfo);
        }