public static Frame CreateFromNode(Wz_Node frameNode, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode) { if (frameNode == null || frameNode.Value == null) { return(null); } while (frameNode.Value is Wz_Uol) { Wz_Uol uol = frameNode.Value as Wz_Uol; Wz_Node uolNode = uol.HandleUol(frameNode); if (uolNode != null) { frameNode = uolNode; } } if (frameNode.Value is Wz_Png) { var linkNode = frameNode.GetLinkedSourceNode(findNode); Wz_Png png = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)frameNode.Value; var frame = new Frame(png.ToTexture(graphicsDevice)) { Png = png, }; foreach (Wz_Node propNode in frameNode.Nodes) { switch (propNode.Text) { case "origin": frame.Origin = (propNode.Value as Wz_Vector).ToPoint(); break; case "delay": frame.Delay = propNode.GetValue <int>(); break; case "z": frame.Z = propNode.GetValue <int>(); break; case "a0": frame.A0 = propNode.GetValue <int>(); break; case "a1": frame.A1 = propNode.GetValue <int>(); break; } } if (frame.Delay == 0) { frame.Delay = 100;//给予默认delay } return(frame); } return(null); }
private Wz_Node FindActionFrameNode(Wz_Node parent, ActionFrame actionFrame) { if (parent == null || actionFrame == null) { return(null); } var actionNode = parent; foreach (var path in new[] { actionFrame.Action, actionFrame.Frame.ToString() }) { if (actionNode != null && !string.IsNullOrEmpty(path)) { actionNode = actionNode.FindNodeByPath(path); //处理uol Wz_Uol uol = actionNode.GetValueEx <Wz_Uol>(null); if (uol != null) { actionNode = uol.HandleUol(actionNode); } } } return(actionNode); }
public void Load(AtlasPage page, string path) { var frameNode = this.TopNode.FindNodeByPath(path); if (frameNode == null || frameNode.Value == null) { return; } if (frameNode.Value is Wz_Uol) { Wz_Uol uol = frameNode.Value as Wz_Uol; Wz_Node uolNode = uol.HandleUol(frameNode); if (uolNode != null) { frameNode = uolNode; } } if (frameNode.Value is Wz_Png) { var linkNode = frameNode.GetLinkedSourceNode(FindNodeFunction); Wz_Png png = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)frameNode.Value; page.rendererObject = png.ToTexture(this.GraphicsDevice); page.width = png.Width; page.height = png.Height; } }
public static GifFrame CreateFrameFromNode(Wz_Node frameNode, GlobalFindNodeFunction findNode) { if (frameNode == null || frameNode.Value == null) { return(null); } while (frameNode.Value is Wz_Uol) { Wz_Uol uol = frameNode.Value as Wz_Uol; Wz_Node uolNode = uol.HandleUol(frameNode); if (uolNode != null) { frameNode = uolNode; } } if (frameNode.Value is Wz_Png) { var linkNode = frameNode.GetLinkedSourceNode(findNode); Wz_Png png = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)frameNode.Value; var gifFrame = new GifFrame(png.ExtractPng()); foreach (Wz_Node propNode in frameNode.Nodes) { switch (propNode.Text) { case "origin": gifFrame.Origin = (propNode.Value as Wz_Vector); break; case "delay": gifFrame.Delay = propNode.GetValue <int>(); break; case "a0": gifFrame.A0 = propNode.GetValue <int>(); break; case "a1": gifFrame.A1 = propNode.GetValue <int>(); break; } } if (gifFrame.Delay == 0) { gifFrame.Delay = 100;//给予默认delay } return(gifFrame); } return(null); }
public static BitmapOrigin CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode) { BitmapOrigin bp = new BitmapOrigin(); Wz_Uol uol = node.GetValue <Wz_Uol>(null); if (uol != 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); }
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); }