コード例 #1
0
        public static void DrawNameTag(Graphics g, Wz_Node resNode, string tagName, int picW, ref int picH)
        {
            if (g == null || resNode == null)
            {
                return;
            }

            //加载资源和文本颜色
            var wce = new[] { "w", "c", "e" }.Select(n =>
            {
                var node = resNode.FindNodeByPath(n);
                if (node == null)
                {
                    return(new BitmapOrigin());
                }
                return(BitmapOrigin.CreateFromNode(node, PluginBase.PluginManager.FindWz));
            }).ToArray();

            Color color = Color.FromArgb(resNode.FindNodeByPath("clr").GetValueEx(-1));

            //测试y轴大小
            int offsetY = wce.Min(bmp => bmp.OpOrigin.Y);
            int height  = wce.Max(bmp => bmp.Rectangle.Bottom);

            //测试宽度
            var font  = GearGraphics.ItemDetailFont2;
            var fmt   = StringFormat.GenericTypographic;
            int width = string.IsNullOrEmpty(tagName) ? 0 : (int)Math.Ceiling(g.MeasureString(tagName, font, 261, fmt).Width);
            int left  = picW / 2 - width / 2;
            int right = left + width;

            //开始绘制背景
            picH -= offsetY;
            if (wce[0].Bitmap != null)
            {
                g.DrawImage(wce[0].Bitmap, left - wce[0].Origin.X, picH - wce[0].Origin.Y);
            }
            if (wce[1].Bitmap != null) //不用拉伸 用纹理平铺 看运气
            {
                var       brush = new TextureBrush(wce[1].Bitmap);
                Rectangle rect  = new Rectangle(left, picH - wce[1].Origin.Y, right - left, brush.Image.Height);
                brush.TranslateTransform(rect.X, rect.Y);
                g.FillRectangle(brush, rect);
                brush.Dispose();
            }
            if (wce[2].Bitmap != null)
            {
                g.DrawImage(wce[2].Bitmap, right - wce[2].Origin.X, picH - wce[2].Origin.Y);
            }

            //绘制文字
            if (!string.IsNullOrEmpty(tagName))
            {
                var brush = new SolidBrush(color);
                g.DrawString(tagName, font, brush, left, picH, fmt);
                brush.Dispose();
            }

            picH += height;
        }
コード例 #2
0
        private IEnumerable <Action> LoadAction(Wz_Node actionNode)
        {
            if (actionNode.FindNodeByPath("0") != null)
            {
                var action = LoadActionFromNode(actionNode, actionNode.Text);
                if (action != null)
                {
                    action.Name = actionNode.Text;
                    yield return(action);
                }
            }
            else
            {
                for (int i = 1; ; i++)
                {
                    var subActionNode = actionNode.FindNodeByPath(i.ToString());
                    if (subActionNode == null)
                    {
                        break;
                    }

                    var action = LoadActionFromNode(subActionNode, actionNode.Text);
                    if (action != null)
                    {
                        action.Name = actionNode.Text + "\\" + i;
                        yield return(action);
                    }
                }
            }
        }
コード例 #3
0
        private Action LoadActionFromNode(Wz_Node actionNode, string actionName)
        {
            Action act = new Action();

            act.Name = actionName;

            if (BaseActions.Contains(actionName)) //基础动作
            {
                act.Level = 0;
            }
            else
            {
                Wz_Node frameNode = actionNode.FindNodeByPath("0");
                if (frameNode == null) //有鬼
                {
                    return(null);
                }
                if (frameNode.FindNodeByPath("action") != null &&
                    frameNode.FindNodeByPath("frame") != null)    //引用动作
                {
                    act.Level = 2;
                }
                else //当成扩展动作
                {
                    act.Level = 1;
                }
            }

            return(act);
        }
コード例 #4
0
ファイル: WzExtentions.cs プロジェクト: MikyWang/WzLoader
        private static Wz_Node SearchNode(this Wz_Node wz_Node, List <string> pathes)
        {
            Wz_Node node;

            pathes.RemoveAt(0);
            if (pathes.Count == 0)
            {
                return(wz_Node);
            }
            node = wz_Node.FindNodeByPath(pathes[0]);
            if (node == null)
            {
                var value = wz_Node.GetValue <Wz_Image>();
                if (value != null)
                {
                    value.TryExtract();
                    wz_Node = value.Node;
                    node    = wz_Node.FindNodeByPath(pathes[0]);
                }
            }
            else
            {
                var value = node.GetValue <Wz_Image>();
                if (value != null)
                {
                    value.TryExtract();
                    node = value.Node;
                }
            }
            return(SearchNode(node, pathes));
        }
コード例 #5
0
        /// <summary>
        /// 获取角色动作的动画帧。
        /// </summary>
        public ActionFrame[] GetActionFrames(string actionName)
        {
            Action action = this.Actions.Find(act => act.Name == actionName);

            if (action == null)
            {
                return(new ActionFrame[0]);
            }

            Wz_Node bodyNode = PluginBase.PluginManager.FindWz("Character\\00002000.img");

            if (action.Level == 2)
            {
                var actionNode = bodyNode.FindNodeByPath(action.Name);
                if (actionNode == null)
                {
                    return(new ActionFrame[0]);
                }

                List <ActionFrame> frames = new List <ActionFrame>();
                for (int i = 0; ; i++)
                {
                    var frameNode = actionNode.FindNodeByPath(i.ToString());
                    if (frameNode == null)
                    {
                        break;
                    }
                    ActionFrame frame = new ActionFrame();
                    frame.Action = frameNode.Nodes["action"].GetValueEx <string>(null);
                    frame.Frame  = frameNode.Nodes["frame"].GetValueEx <int>(0);
                    LoadActionFrameDesc(frameNode, frame);
                    frames.Add(frame);
                }
                return(frames.ToArray());
            }
            else
            {
                Wz_Node actionNode = null;
                if (this.Body != null)
                {
                    actionNode = this.Body.Node.FindNodeByPath(action.Name);
                }
                if (actionNode == null)
                {
                    actionNode = bodyNode.FindNodeByPath(action.Name);
                }

                List <ActionFrame> frames = new List <ActionFrame>();
                frames.AddRange(LoadStandardFrames(actionNode, action.Name));
                return(frames.ToArray());
            }
        }
コード例 #6
0
        private IEnumerable <ActionFrame> LoadStandardFrames(Wz_Node actionNode, string action)
        {
            if (actionNode == null)
            {
                yield break;
            }

            actionNode = actionNode.ResolveUol();

            if (actionNode == null)
            {
                yield break;
            }

            for (int i = 0; ; i++)
            {
                var frameNode = actionNode.FindNodeByPath(i.ToString());
                if (frameNode == null)
                {
                    yield break;
                }
                var frame = LoadStandardFrame(frameNode);
                frame.Action = action;
                frame.Frame  = i;
                yield return(frame);
            }
        }
コード例 #7
0
        private IEnumerable <ActionFrame> LoadStandardFrames(Wz_Node actionNode, string action)
        {
            if (actionNode == null)
            {
                yield break;
            }

            for (int i = 0; ; i++)
            {
                var frameNode = actionNode.FindNodeByPath(i.ToString());
                if (frameNode == null)
                {
                    yield break;
                }
                ActionFrame frame = new ActionFrame();
                frame.Action = action;
                frame.Frame  = i;
                if (frameNode.Value is Wz_Uol)
                {
                    frameNode = frameNode.GetValue <Wz_Uol>().HandleUol(frameNode);
                }
                LoadActionFrameDesc(frameNode, frame);
                yield return(frame);
            }
        }
コード例 #8
0
        public static FrameAnimationData CreateFromNode(Wz_Node node, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode)
        {
            if (node == null)
            {
                return(null);
            }
            var anime = new FrameAnimationData();

            for (int i = 0; ; i++)
            {
                Wz_Node frameNode = node.FindNodeByPath(i.ToString());

                if (frameNode == null || frameNode.Value == null)
                {
                    break;
                }
                Frame frame = Frame.CreateFromNode(frameNode, graphicsDevice, findNode);

                if (frame == null)
                {
                    break;
                }
                anime.Frames.Add(frame);
            }
            if (anime.Frames.Count > 0)
            {
                return(anime);
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
ファイル: Gif.cs プロジェクト: mikuyourworld/MapleStoryDB2
        public static Gif CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            if (node == null)
            {
                return(null);
            }
            Gif gif = new Gif();

            for (int i = 0; ; i++)
            {
                Wz_Node frameNode = node.FindNodeByPath(i.ToString());

                if (frameNode == null || frameNode.Value == null)
                {
                    break;
                }
                GifFrame gifFrame = CreateFrameFromNode(frameNode, findNode);

                if (gifFrame == null)
                {
                    break;
                }
                gif.Frames.Add(gifFrame);
            }
            if (gif.Frames.Count > 0)
            {
                return(gif);
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
 public static Wz_Node FindNodeByPathA(this Wz_Node Node, string FullPath, bool ExtractImage)
 {
     string[] Patten = FullPath.Split('/');
     // if (Node != null)
     return(Node.FindNodeByPath(ExtractImage, Patten));
     //return null;
 }
コード例 #11
0
        private ActionFrame GetActionFrame(string actionName, int frameIndex)
        {
            Action action = this.Actions.Find(act => act.Name == actionName);

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

            Wz_Node bodyNode = PluginBase.PluginManager.FindWz("Character\\00002000.img");

            if (action.Level == 2)
            {
                var frameNode = bodyNode.FindNodeByPath($@"{action.Name}\{frameIndex}");
                if (frameNode != null)
                {
                    ActionFrame frame = new ActionFrame();
                    frame.Action = frameNode.Nodes["action"].GetValueEx <string>(null);
                    frame.Frame  = frameNode.Nodes["frame"].GetValueEx <int>(0);
                    LoadActionFrameDesc(frameNode, frame);
                    return(frame);
                }
            }
            else
            {
                Wz_Node actionNode = this.Body?.Node.FindNodeByPath(action.Name)
                                     ?? bodyNode.FindNodeByPath(action.Name);

                var frameNode = actionNode?.Nodes[frameIndex.ToString()];
                if (frameNode != null)
                {
                    var frame = LoadStandardFrame(frameNode);
                    frame.Action = action.Name;
                    frame.Frame  = frameIndex;
                    return(frame);
                }
            }

            return(null);
        }
コード例 #12
0
        public void LoadResource(GraphicsDevice graphicsDevice)
        {
            Wz_Node minimapNode = PluginBase.PluginManager.FindWz("Map\\MapHelper.img\\minimap");

            if (minimapNode != null)
            {
                Wz_Node portalNode    = minimapNode.FindNodeByPath("portal");
                Wz_Node transportNode = minimapNode.FindNodeByPath("transport");

                Wz_Png png;
                if ((png = portalNode.GetValueEx <Wz_Png>(null)) != null)
                {
                    this.texPortal = TextureLoader.PngToTexture(graphicsDevice, png);
                }

                if ((png = transportNode.GetValueEx <Wz_Png>(null)) != null)
                {
                    this.texTransport = TextureLoader.PngToTexture(graphicsDevice, png);
                }
            }
            this.ResourceLoaded = true;
        }
コード例 #13
0
        public static Potential LoadFromWz(int optID, int optLevel, GlobalFindNodeFunction findNode)
        {
            Wz_Node itemWz = findNode("Item\\ItemOption.img");

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

            Potential opt = Potential.CreateFromNode(itemWz.FindNodeByPath(optID.ToString("d6")), optLevel);

            return(opt);
        }
コード例 #14
0
        public static void LoadSetItems()
        {
            //搜索setItemInfo.img
            Wz_Node etcWz = PluginManager.FindWz(Wz_Type.Etc);

            if (etcWz == null)
            {
                return;
            }
            Wz_Node setItemNode = etcWz.FindNodeByPath("SetItemInfo.img", true);

            if (setItemNode == null)
            {
                return;
            }

            //搜索ItemOption.img
            Wz_Node itemWz = PluginManager.FindWz(Wz_Type.Item);

            if (itemWz == null)
            {
                return;
            }
            Wz_Node optionNode = itemWz.FindNodeByPath("ItemOption.img", true);

            if (optionNode == null)
            {
                return;
            }

            LoadedSetItems.Clear();
            foreach (Wz_Node node in setItemNode.Nodes)
            {
                int setItemIndex;
                if (Int32.TryParse(node.Text, out setItemIndex))
                {
                    SetItem setItem = SetItem.CreateFromNode(node, optionNode);
                    if (setItem != null)
                    {
                        LoadedSetItems[setItemIndex] = setItem;
                    }
                }
            }
        }
コード例 #15
0
        private Wz_Node FindBodyActionNode(ActionFrame actionFrame)
        {
            Wz_Node actionNode = null;

            if (this.Body != null)
            {
                actionNode = this.Body.Node.FindNodeByPath(actionFrame.Action);
            }
            if (actionNode == null)
            {
                Wz_Node bodyNode = PluginBase.PluginManager.FindWz("Character\\00002000.img");
                actionNode = bodyNode.FindNodeByPath(actionFrame.Action);
            }
            if (actionNode != null)
            {
                actionNode = actionNode.FindNodeByPath(actionFrame.Frame.ToString());
            }
            return(actionNode);
        }
コード例 #16
0
        private RenderFrame[] LoadFrames(Wz_Node resNode, Dictionary <string, RenderFrame> loadedRes)
        {
            if (resNode.Value is Wz_Png)
            {
                RenderFrame frame;
                if (!loadedRes.TryGetValue(resNode.FullPath, out frame))
                {
                    frame = this.texLoader.CreateFrame(resNode);
                    loadedRes[resNode.FullPath] = frame;
                }
                return(new RenderFrame[1] {
                    frame
                });
            }

            List <RenderFrame> frames = new List <RenderFrame>();
            Wz_Uol             uol;

            for (int i = 0; ; i++)
            {
                Wz_Node frameNode = resNode.FindNodeByPath(i.ToString());
                if (frameNode == null)
                {
                    break;
                }
                while ((uol = frameNode.Value as Wz_Uol) != null)
                {
                    frameNode = uol.HandleUol(frameNode);
                }
                RenderFrame frame;
                if (!loadedRes.TryGetValue(frameNode.FullPath, out frame))
                {
                    frame = this.texLoader.CreateFrame(frameNode);
                    loadedRes[frameNode.FullPath] = frame;
                }
                frames.Add(frame);
            }

            return(frames.ToArray());
        }
コード例 #17
0
        public static BitmapOrigin CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            BitmapOrigin bp = new BitmapOrigin();
            Wz_Uol       uol;

            while ((uol = node.GetValue <Wz_Uol>(null)) != null)
            {
                node = uol.HandleUol(node);
            }

            //获取linkNode
            var    linkNode = node.GetLinkedSourceNode(findNode);
            Wz_Png png      = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)node.Value;

            bp.Bitmap = png?.ExtractPng();
            Wz_Node   originNode = node.FindNodeByPath("origin");
            Wz_Vector vec        = (originNode == null) ? null : originNode.GetValue <Wz_Vector>();

            bp.Origin = (vec == null) ? new Point() : new Point(vec.X, vec.Y);

            return(bp);
        }
コード例 #18
0
        private void LoadMinimap(Wz_Node miniMapNode, ResourceLoader resLoader)
        {
            Wz_Node canvas  = miniMapNode.FindNodeByPath("canvas"),
                    width   = miniMapNode.FindNodeByPath("width"),
                    height  = miniMapNode.FindNodeByPath("height"),
                    centerX = miniMapNode.FindNodeByPath("centerX"),
                    centerY = miniMapNode.FindNodeByPath("centerY"),
                    mag     = miniMapNode.FindNodeByPath("mag");

            this.MiniMap.ExtraCanvas.Clear();

            canvas = canvas.GetLinkedSourceNode(PluginManager.FindWz);
            if (canvas != null)
            {
                this.MiniMap.Canvas = resLoader.Load <Texture2D>(canvas);
                this.MiniMap.ExtraCanvas.Add("canvas", this.MiniMap.Canvas);
            }
            else
            {
                this.MiniMap.Canvas = null;
            }

            // example mapID: 993200000, KMST1140
            for (int i = 1; ; i++)
            {
                string canvasName  = $"canvas{i}";
                var    extraCanvas = miniMapNode.FindNodeByPath(canvasName);
                if (extraCanvas == null)
                {
                    break;
                }
                extraCanvas = extraCanvas.GetLinkedSourceNode(PluginManager.FindWz);
                this.MiniMap.ExtraCanvas.Add(canvasName, resLoader.Load <Texture2D>(extraCanvas));
            }

            this.MiniMap.Width   = width.GetValueEx(0);
            this.MiniMap.Height  = height.GetValueEx(0);
            this.MiniMap.CenterX = centerX.GetValueEx(0);
            this.MiniMap.CenterY = centerY.GetValueEx(0);
            this.MiniMap.Mag     = mag.GetValueEx(0);
        }
コード例 #19
0
        /// <summary>
        /// 读取扩展属性。
        /// </summary>
        private void LoadActionFrameDesc(Wz_Node frameNode, ActionFrame actionFrame)
        {
            actionFrame.Delay = frameNode.FindNodeByPath("delay").GetValueEx <int>(100);
            actionFrame.Flip  = frameNode.FindNodeByPath("flip").GetValueEx <int>(0) != 0;
            var faceNode = frameNode.FindNodeByPath("face");

            if (faceNode != null)
            {
                actionFrame.Face = faceNode.GetValue <int>() != 0;
            }
            var move = frameNode.FindNodeByPath("move").GetValueEx <Wz_Vector>(null);

            if (move != null)
            {
                actionFrame.Move = move;
            }
            actionFrame.RotateProp = frameNode.FindNodeByPath("rotateProp").GetValueEx <int>(0);
            actionFrame.Rotate     = frameNode.FindNodeByPath("rotate").GetValueEx <int>(0);
        }
コード例 #20
0
ファイル: MapData.cs プロジェクト: zhaoyang90/WzComparerR2
        private void LoadMinimap(Wz_Node miniMapNode, ResourceLoader resLoader)
        {
            Wz_Node canvas  = miniMapNode.FindNodeByPath("canvas"),
                    width   = miniMapNode.FindNodeByPath("width"),
                    height  = miniMapNode.FindNodeByPath("height"),
                    centerX = miniMapNode.FindNodeByPath("centerX"),
                    centerY = miniMapNode.FindNodeByPath("centerY"),
                    mag     = miniMapNode.FindNodeByPath("mag");

            canvas = canvas.GetLinkedSourceNode(PluginManager.FindWz);

            if (canvas != null)
            {
                this.MiniMap.Canvas = resLoader.Load <Texture2D>(canvas);
            }
            this.MiniMap.Width   = width.GetValueEx(0);
            this.MiniMap.Height  = height.GetValueEx(0);
            this.MiniMap.CenterX = centerX.GetValueEx(0);
            this.MiniMap.CenterY = centerY.GetValueEx(0);
            this.MiniMap.Mag     = mag.GetValueEx(0);
        }
コード例 #21
0
        public RenderFrame CreateFrame(Wz_Node frameNode)
        {
            string key = frameNode.FullPathToFile.Replace('\\', '/');
            Wz_Png png = null;

            string source = frameNode.FindNodeByPath("source").GetValueEx <string>(null);

            if (!string.IsNullOrEmpty(source))
            {
                Wz_Node sourceNode = PluginManager.FindWz(source);
                if (sourceNode != null)
                {
                    png = sourceNode.Value as Wz_Png;
                    key = sourceNode.FullPathToFile.Replace('\\', '/');
                }
            }
            else
            {
                png = frameNode.Value as Wz_Png;
            }

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

            RenderFrame frame = new RenderFrame();
            Wz_Vector   vec   = frameNode.FindNodeByPath("origin").GetValueEx <Wz_Vector>(null);

            frame.Texture = GetTexture(png, key);
            frame.Origin  = (vec == null ? new Vector2() : new Vector2(vec.X, vec.Y));
            frame.Delay   = frameNode.FindNodeByPath("delay").GetValueEx <int>(100);
            frame.Z       = frameNode.FindNodeByPath("z").GetValueEx <int>(0);
            frame.A0      = frameNode.FindNodeByPath("a0").GetValueEx <int>(255);
            frame.A1      = frameNode.FindNodeByPath("a1").GetValueEx <int>(frame.A0);
            return(frame);
        }
コード例 #22
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;
                        while (pngNode.Value is Wz_Uol)
                        {
                            Wz_Uol  uol     = pngNode.Value as Wz_Uol;
                            Wz_Node uolNode = uol.HandleUol(subNode);
                            if (uolNode != null)
                            {
                                pngNode = uolNode;
                            }
                        }
                        if (pngNode.Value is Wz_Png)
                        {
                            item.Icon = BitmapOrigin.CreateFromNode(pngNode, findNode);
                        }
                        break;

                    case "iconRaw":
                        pngNode = subNode;
                        while (pngNode.Value is Wz_Uol)
                        {
                            Wz_Uol  uol     = pngNode.Value as Wz_Uol;
                            Wz_Node uolNode = uol.HandleUol(subNode);
                            if (uolNode != null)
                            {
                                pngNode = uolNode;
                            }
                        }
                        if (pngNode.Value is Wz_Png)
                        {
                            item.IconRaw = BitmapOrigin.CreateFromNode(pngNode, findNode);
                        }
                        break;

                    case "sample":
                        if (subNode.Value is Wz_Png)
                        {
                            item.Sample = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "lv":
                        item.Level = Convert.ToInt32(subNode.Value);
                        break;

                    default:
                        ItemPropType type;
                        if (Enum.TryParse(subNode.Text, out type))
                        {
                            try
                            {
                                item.Props.Add(type, Convert.ToInt32(subNode.Value));
                            }
                            finally
                            {
                            }
                        }
                        break;
                    }
                }
            }

            Wz_Node specNode = node.FindNodeByPath("spec");

            if (specNode != null)
            {
                foreach (Wz_Node subNode in specNode.Nodes)
                {
                    ItemSpecType type;
                    if (Enum.TryParse(subNode.Text, out type))
                    {
                        try
                        {
                            item.Specs.Add(type, Convert.ToInt32(subNode.Value));
                        }
                        finally
                        {
                        }
                    }
                }
            }
            return(item);
        }
コード例 #23
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, PluginManager.FindWz);
                        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();
            }
        }
コード例 #24
0
ファイル: Entry.cs プロジェクト: Yukinyaa/WzComparerR2-KMS-
        private Gif CreateContinueAction(AvatarCanvas canvas)
        {
            string  afterImage            = null;
            Wz_Node defaultAfterImageNode = null;

            if (canvas.Weapon != null)
            {
                afterImage = canvas.Weapon.Node.FindNodeByPath(false, "info", "afterImage").GetValueEx <string>(null);
                if (!string.IsNullOrEmpty(afterImage))
                {
                    defaultAfterImageNode = PluginManager.FindWz("Character\\Afterimage\\" + afterImage + ".img\\10");
                }
            }

            GifCanvas gifCanvas = new GifCanvas();

            gifCanvas.Layers.Add(new GifLayer());
            int delay = 0;
            //foreach (string act in new[] { "alert", "swingP1PoleArm", "doubleSwing", "tripleSwing" })
            //foreach (var act in new object[] { "alert", "swingP1PoleArm", "overSwingDouble", "overSwingTriple" })
            var faceFrames = canvas.GetFaceFrames(canvas.EmotionName);

            //foreach (string act in new[] { "PBwalk1", "PBstand4", "PBstand5" })

            foreach (var act in new object[] {
                PluginManager.FindWz("Skill\\2312.img\\skill\\23121004"),
                "stand1",
                PluginManager.FindWz("Skill\\2312.img\\skill\\23121052"),
                //PluginManager.FindWz("Skill\\2112.img\\skill\\21120010"),

                //PluginManager.FindWz("Skill\\200.img\\skill\\2001002"),
                //PluginManager.FindWz("Skill\\230.img\\skill\\2301003"),
                //PluginManager.FindWz("Skill\\230.img\\skill\\2301004"),
                //PluginManager.FindWz("Skill\\231.img\\skill\\2311003"),

                //PluginManager.FindWz("Skill\\13100.img\\skill\\131001010"),
                //"PBwalk1"
            })
            {
                string     actionName     = null;
                Wz_Node    afterImageNode = null;
                List <Gif> effects        = new List <Gif>();

                if (act is string)
                {
                    actionName = (string)act;
                }
                else if (act is Wz_Node)
                {
                    Wz_Node skillNode = (Wz_Node)(object)act;
                    actionName = skillNode.FindNodeByPath("action\\0").GetValueEx <string>(null);
                    if (!string.IsNullOrEmpty(afterImage))
                    {
                        afterImageNode = skillNode.FindNodeByPath("afterimage\\" + afterImage);
                    }

                    for (int i = -1; ; i++)
                    {
                        Wz_Node effNode = skillNode.FindNodeByPath("effect" + (i > -1 ? i.ToString() : ""));
                        if (effNode == null)
                        {
                            break;
                        }
                        effects.Add(Gif.CreateFromNode(effNode, PluginManager.FindWz));
                    }
                }

                if (string.IsNullOrEmpty(actionName))
                {
                    continue;
                }

                //afterImageNode = afterImageNode ?? defaultAfterImageNode;


                //添加特效帧
                foreach (var effGif in effects)
                {
                    if (effGif != null && effGif.Frames.Count > 0)
                    {
                        var layer = new GifLayer();
                        if (delay > 0)
                        {
                            layer.AddBlank(delay);
                        }
                        effGif.Frames.ForEach(af => layer.AddFrame((GifFrame)af));
                        gifCanvas.Layers.Add(layer);
                    }
                }

                //添加角色帧
                ActionFrame[] actionFrames = canvas.GetActionFrames(actionName);
                for (int i = 0; i < actionFrames.Length; i++)
                {
                    var frame = actionFrames[i];

                    if (frame.Delay != 0)
                    {
                        //绘制角色主动作
                        var      bone = canvas.CreateFrame(frame, null, null);
                        var      bmp  = canvas.DrawFrame(bone, frame);
                        GifFrame f    = new GifFrame(bmp.Bitmap, bmp.Origin, Math.Abs(frame.Delay));
                        gifCanvas.Layers[0].Frames.Add(f);

                        //寻找刀光帧
                        if (afterImageNode != null)
                        {
                            var afterImageAction = afterImageNode.FindNodeByPath(false, actionName, i.ToString());
                            if (afterImageAction != null)
                            {
                                Gif aGif = Gif.CreateFromNode(afterImageAction, PluginManager.FindWz);
                                if (aGif != null && aGif.Frames.Count > 0) //添加新图层
                                {
                                    var layer = new GifLayer();
                                    if (delay > 0)
                                    {
                                        layer.AddBlank(delay);
                                    }
                                    aGif.Frames.ForEach(af => layer.AddFrame((GifFrame)af));
                                    gifCanvas.Layers.Add(layer);
                                }
                            }
                        }

                        delay += f.Delay;
                    }
                }
            }

            return(gifCanvas.Combine());
        }
コード例 #25
0
ファイル: Gear.cs プロジェクト: shadowcking/WzComparerR2
        public static Gear CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            int   gearID;
            Match m = Regex.Match(node.Text, @"^(\d{8})\.img$");

            if (!(m.Success && Int32.TryParse(m.Result("$1"), out gearID)))
            {
                return(null);
            }
            Gear gear = new Gear();

            gear.ItemID = gearID;
            gear.type   = Gear.GetGearType(gear.ItemID);
            Wz_Node infoNode = node.FindNodeByPath("info");

            if (infoNode != null)
            {
                foreach (Wz_Node subNode in infoNode.Nodes)
                {
                    switch (subNode.Text)
                    {
                    case "icon":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.Icon = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "iconRaw":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.IconRaw = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "sample":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.Sample = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "addition":     //附加属性信息
                        foreach (Wz_Node addiNode in subNode.Nodes)
                        {
                            Addition addi = Addition.CreateFromNode(addiNode);
                            if (addi != null)
                            {
                                gear.Additions.Add(addi);
                            }
                        }
                        gear.Additions.Sort((add1, add2) => (int)add1.Type - (int)add2.Type);
                        break;

                    case "option":     //附加潜能信息
                        Wz_Node itemWz = findNode != null?findNode("Item\\ItemOption.img") : null;

                        if (itemWz == null)
                        {
                            break;
                        }
                        int optIdx = 0;
                        foreach (Wz_Node optNode in subNode.Nodes)
                        {
                            int optId = 0, optLevel = 0;
                            foreach (Wz_Node optArgNode in optNode.Nodes)
                            {
                                switch (optArgNode.Text)
                                {
                                case "option": optId = Convert.ToInt32(optArgNode.Value); break;

                                case "level": optLevel = Convert.ToInt32(optArgNode.Value); break;
                                }
                            }

                            Potential opt = Potential.CreateFromNode(itemWz.FindNodeByPath(optId.ToString("d6")), optLevel);
                            if (opt != null)
                            {
                                gear.Options[optIdx++] = opt;
                            }
                        }
                        break;

                    case "level":     //可升级信息
                        if (subNode.Nodes["fixLevel"].GetValueEx <int>(0) != 0)
                        {
                            gear.FixLevel = true;
                        }

                        Wz_Node levelInfo = subNode.Nodes["info"];
                        gear.Levels = new List <GearLevelInfo>();
                        if (levelInfo != null)
                        {
                            for (int i = 1; ; i++)
                            {
                                Wz_Node levelInfoNode = levelInfo.Nodes[i.ToString()];
                                if (levelInfoNode != null)
                                {
                                    GearLevelInfo info = GearLevelInfo.CreateFromNode(levelInfoNode);
                                    int           lv;
                                    Int32.TryParse(levelInfoNode.Text, out lv);
                                    info.Level = lv;
                                    gear.Levels.Add(info);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }

                        Wz_Node levelCase = subNode.Nodes["case"];
                        if (levelCase != null)
                        {
                            int probTotal = 0;
                            foreach (Wz_Node caseNode in levelCase.Nodes)
                            {
                                int prob = caseNode.Nodes["prob"].GetValueEx(0);
                                probTotal += prob;
                                for (int i = 0; i < gear.Levels.Count; i++)
                                {
                                    GearLevelInfo info      = gear.Levels[i];
                                    Wz_Node       caseLevel = caseNode.Nodes[info.Level.ToString()];
                                    if (caseLevel != null)
                                    {
                                        //desc
                                        Wz_Node caseHS = caseLevel.Nodes["hs"];
                                        if (caseHS != null)
                                        {
                                            info.HS = caseHS.GetValue <string>();
                                        }

                                        //随机技能
                                        Wz_Node caseSkill = caseLevel.Nodes["Skill"];
                                        if (caseSkill != null)
                                        {
                                            foreach (Wz_Node skillNode in caseSkill.Nodes)
                                            {
                                                int id    = skillNode.Nodes["id"].GetValueEx(-1);
                                                int level = skillNode.Nodes["level"].GetValueEx(-1);
                                                if (id >= 0 && level >= 0)
                                                {
                                                    info.Skills[id] = level;
                                                }
                                            }
                                        }

                                        //装备技能
                                        Wz_Node equipSkill = caseLevel.Nodes["EquipmentSkill"];
                                        if (equipSkill != null)
                                        {
                                            foreach (Wz_Node skillNode in equipSkill.Nodes)
                                            {
                                                int id    = skillNode.Nodes["id"].GetValueEx(-1);
                                                int level = skillNode.Nodes["level"].GetValueEx(-1);
                                                if (id >= 0 && level >= 0)
                                                {
                                                    info.EquipmentSkills[id] = level;
                                                }
                                            }
                                        }
                                        info.Prob = prob;
                                    }
                                }
                            }

                            foreach (var info in gear.Levels)
                            {
                                info.ProbTotal = probTotal;
                            }
                        }
                        gear.Props.Add(GearPropType.level, 1);
                        break;

                    case "sealed":     //封印解除信息
                        Wz_Node sealedInfo = subNode.Nodes["info"];
                        gear.Seals = new List <GearSealedInfo>();
                        if (sealedInfo != null)
                        {
                            foreach (Wz_Node levelInfoNode in sealedInfo.Nodes)
                            {
                                GearSealedInfo info = GearSealedInfo.CreateFromNode(levelInfoNode, findNode);
                                int            lv;
                                Int32.TryParse(levelInfoNode.Text, out lv);
                                info.Level = lv;
                                gear.Seals.Add(info);
                            }
                        }
                        gear.Props.Add(GearPropType.@sealed, 1);
                        break;

                    case "variableStat":     //升级奖励属性
                        foreach (Wz_Node statNode in subNode.Nodes)
                        {
                            GearPropType type;
                            if (Enum.TryParse(statNode.Text, out type))
                            {
                                try
                                {
                                    gear.VariableStat.Add(type, Convert.ToSingle(statNode.Value));
                                }
                                finally
                                {
                                }
                            }
                        }
                        break;

                    case "abilityTimeLimited":     //限时属性
                        foreach (Wz_Node statNode in subNode.Nodes)
                        {
                            GearPropType type;
                            if (Enum.TryParse(statNode.Text, out type))
                            {
                                try
                                {
                                    gear.AbilityTimeLimited.Add(type, Convert.ToInt32(statNode.Value));
                                }
                                finally
                                {
                                }
                            }
                        }
                        break;

                    default:
                    {
                        GearPropType type;
                        if (!int.TryParse(subNode.Text, out _) && Enum.TryParse(subNode.Text, out type))
                        {
                            try
                            {
                                gear.Props.Add(type, Convert.ToInt32(subNode.Value));
                            }
                            finally
                            {
                            }
                        }
                    }
                    break;
                    }
                }
            }
            int value;

            //读取默认可升级状态
            if (gear.Props.TryGetValue(GearPropType.tuc, out value) && value > 0)
            {
                gear.HasTuc       = true;
                gear.CanPotential = true;
            }
            else if (Gear.SpecialCanPotential(gear.type))
            {
                gear.CanPotential = true;
            }

            //读取默认gearGrade
            if (gear.Props.TryGetValue(GearPropType.fixedGrade, out value))
            {
                gear.Grade = (GearGrade)(value - 1);
            }

            //自动填充Grade
            if (gear.Options.Any(opt => opt != null) && gear.Grade == GearGrade.C)
            {
                gear.Grade = GearGrade.B;
            }

            //添加默认装备要求
            GearPropType[] types = new GearPropType[] {
                GearPropType.reqJob, GearPropType.reqLevel, GearPropType.reqSTR, GearPropType.reqDEX,
                GearPropType.reqINT, GearPropType.reqLUK
            };
            foreach (GearPropType type in types)
            {
                if (!gear.Props.ContainsKey(type))
                {
                    gear.Props.Add(type, 0);
                }
            }

            //修复恶魔盾牌特殊属性
            if (gear.type == GearType.demonShield)
            {
                if (gear.Props.TryGetValue(GearPropType.incMMP, out value))
                {
                    gear.Props.Remove(GearPropType.incMMP);
                    gear.Props.Add(GearPropType.incMDF, value);
                }
            }

            //备份标准属性
            gear.StandardProps = new Dictionary <GearPropType, int>(gear.Props);

            //追加限时属性
            gear.MakeTimeLimitedPropAvailable();

            return(gear);
        }
コード例 #26
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());
        }
コード例 #27
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;
                if (linkPartNode.Value is Wz_Uol)
                {
                    linkPartNode = linkPartNode.GetValue <Wz_Uol>().HandleUol(linkPartNode);
                }

                foreach (Wz_Node childNode in linkPartNode.Nodes) //分析部件
                {
                    Wz_Node linkNode = childNode;
                    if (childNode.Value is Wz_Uol)
                    {
                        linkNode = ((Wz_Uol)childNode.Value).HandleUol(linkNode);
                        if (linkNode == null)
                        {
                            continue;
                        }
                    }
                    if (childNode.Text == "hairShade")
                    {
                        linkNode = childNode.FindNodeByPath("0");
                        if (linkNode == null)
                        {
                            continue;
                        }
                    }
                    if (linkNode.Value is Wz_Png)
                    {
                        //过滤纹理
                        switch (childNode.Text)
                        {
                        case "face": if (!(bodyFace ?? face))
                            {
                                continue;
                            }
                            break;

                        case "ear": if (!ShowEar)
                            {
                                continue;
                            }
                            break;

                        case "hairOverHead":
                        case "backHairOverCape":
                        case "backHair": if (HairCover)
                            {
                                continue;
                            }
                            break;

                        case "hair":
                        case "backHairBelowCap": if (!HairCover)
                            {
                                continue;
                            }
                            break;

                        case "hairShade": if (!ShowHairShade)
                            {
                                continue;
                            }
                            break;

                        default:
                            if (childNode.Text.StartsWith("weapon"))
                            {
                                //检查是否多武器颜色
                                if (linkNode.ParentNode.FindNodeByPath("weapon1") != null)
                                {
                                    //只追加限定武器
                                    string weaponName = "weapon" + (this.WeaponIndex == 0 ? "" : this.WeaponIndex.ToString());
                                    if (childNode.Text != weaponName)
                                    {
                                        continue;
                                    }
                                }
                            }
                            break;
                        }

                        //读取纹理
                        Skin skin = new Skin();
                        skin.Name  = childNode.Text;
                        skin.Image = BitmapOrigin.CreateFromNode(linkNode, PluginBase.PluginManager.FindWz);
                        skin.Z     = linkNode.FindNodeByPath("z").GetValueEx <string>(null);

                        //读取骨骼
                        Wz_Node mapNode = linkNode.FindNodeByPath("map");
                        if (mapNode != null)
                        {
                            Bone parentBone = null;
                            foreach (var map in mapNode.Nodes)
                            {
                                string mapName   = map.Text;
                                Point  mapOrigin = map.GetValue <Wz_Vector>();

                                if (mapName == "muzzle") //特殊处理 忽略
                                {
                                    continue;
                                }

                                if (parentBone == null) //主骨骼
                                {
                                    parentBone = AppendBone(root, null, skin, mapName, mapOrigin);
                                }
                                else //级联骨骼
                                {
                                    AppendBone(root, parentBone, skin, mapName, mapOrigin);
                                }
                            }
                        }
                        else
                        {
                            root.Skins.Add(skin);
                        }
                    }
                    else
                    {
                        switch (childNode.Text)
                        {
                        case "face":
                            face = Convert.ToInt32(childNode.Value) != 0;
                            break;
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: Entry.cs プロジェクト: Yukinyaa/WzComparerR2-KMS-
        private Gif CreateKeyDownAction(AvatarCanvas canvas)
        {
            string  afterImage            = null;
            Wz_Node defaultAfterImageNode = null;

            if (canvas.Weapon != null)
            {
                afterImage = canvas.Weapon.Node.FindNodeByPath(false, "info", "afterImage").GetValueEx <string>(null);
                if (!string.IsNullOrEmpty(afterImage))
                {
                    defaultAfterImageNode = PluginManager.FindWz("Character\\Afterimage\\" + afterImage + ".img\\10");
                }
            }

            GifCanvas gifCanvas = new GifCanvas();
            var       layers    = new List <Tuple <GifLayer, int> >();
            var       actLayer  = new GifLayer();

            //gifCanvas.Layers.Add(new GifLayer());
            int delay      = 0;
            var faceFrames = canvas.GetFaceFrames(canvas.EmotionName);

            var skillNode  = PluginManager.FindWz("Skill\\2112.img\\skill\\21120018");
            var actionName = skillNode.FindNodeByPath("action\\0").GetValueEx <string>(null);

            int keydownCount = 2;

            foreach (var part in new [] { "prepare", "keydown", "keydownend" })
            {
                var effects = new List <Tuple <Gif, int> >();

                for (int i = -1; ; i++)
                {
                    Wz_Node effNode = skillNode.FindNodeByPath(part + (i > -1 ? i.ToString() : ""));
                    if (effNode == null)
                    {
                        break;
                    }
                    var gif = Gif.CreateFromNode(effNode, PluginManager.FindWz);
                    var z   = effNode.FindNodeByPath("z").GetValueEx(0);
                    effects.Add(new Tuple <Gif, int>(gif, z));
                }

                int effDelay = 0;
                //添加特效帧
                foreach (var effGif in effects)
                {
                    if (effGif.Item1 != null && effGif.Item1.Frames.Count > 0)
                    {
                        var layer = new GifLayer();
                        if (delay > 0)
                        {
                            layer.AddBlank(delay);
                        }

                        int fDelay = 0;

                        for (int i = 0, i0 = part == "keydown" ? keydownCount : 1; i < i0; i++)
                        {
                            effGif.Item1.Frames.ForEach(af => layer.AddFrame((GifFrame)af));
                            layers.Add(new Tuple <GifLayer, int>(layer, effGif.Item2));
                            fDelay += effGif.Item1.Frames.Select(f => f.Delay).Sum();
                        }

                        effDelay = Math.Max(fDelay, effDelay);
                    }
                }

                delay += effDelay;
            }


            //添加角色帧
            ActionFrame[] actionFrames = canvas.GetActionFrames(actionName);
            int           adelay       = 0;

            while (adelay < delay)
            {
                for (int i = 0; i < actionFrames.Length; i++)
                {
                    var frame = actionFrames[i];

                    if (frame.Delay != 0)
                    {
                        //绘制角色主动作
                        var      bone = canvas.CreateFrame(frame, null, null);
                        var      bmp  = canvas.DrawFrame(bone, frame);
                        GifFrame f    = new GifFrame(bmp.Bitmap, bmp.Origin, Math.Abs(frame.Delay));
                        actLayer.Frames.Add(f);
                        adelay += f.Delay;
                        //delay += f.Delay;
                    }
                }
            }

            layers.Add(new Tuple <GifLayer, int>(actLayer, 0));
            //按照z排序
            layers.Sort((a, b) => a.Item2.CompareTo(b.Item2));
            gifCanvas.Layers.AddRange(layers.Select(t => t.Item1));

            return(gifCanvas.Combine());
        }
コード例 #29
0
        public static SetItem CreateFromNode(Wz_Node setItemNode, Wz_Node optionNode)
        {
            if (setItemNode == null)
            {
                return(null);
            }

            SetItem setItem = new SetItem();
            int     setItemID;

            if (int.TryParse(setItemNode.Text, out setItemID))
            {
                setItem.SetItemID = setItemID;
            }

            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 "parts":
                    setItem.Parts = subNode.GetValue <int>() != 0;
                    break;

                case "expandToolTip":
                    setItem.ExpandToolTip = subNode.GetValue <int>() != 0;
                    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;

                            case "bonusByTime":
                                var bonusByTimeList = new List <SetItemBonusByTime>();
                                for (int i = 0; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    var bonusByTime = new SetItemBonusByTime();
                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "termStart":
                                            bonusByTime.TermStart = pNode.GetValue <int>();
                                            break;

                                        default:
                                        {
                                            GearPropType type;
                                            if (Enum.TryParse(pNode.Text, out type))
                                            {
                                                bonusByTime.Props.Add(type, pNode.GetValue <int>());
                                            }
                                        }
                                        break;
                                        }
                                    }
                                    bonusByTimeList.Add(bonusByTime);
                                }
                                effect.Props.Add(GearPropType.bonusByTime, bonusByTimeList);
                                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;

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

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


            return(setItem);
        }
コード例 #30
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);
        }