public static TextureBase LoadTexture(Wz_Node node) { node = node?.GetLinkedSourceNode(PluginManager.FindWz); var png = node.GetValueEx <Wz_Png>(null); if (png != null) { return(Engine.Instance.AssetManager.LoadTexture(null, node.FullPathToFile)); } else { return(null); } }
public static SkeletonData LoadSkeleton(Wz_Node atlasNode, SkeletonLoadType loadType, TextureLoader textureLoader) { string atlasData = atlasNode.GetValueEx <string>(null); if (string.IsNullOrEmpty(atlasData)) { return(null); } StringReader atlasReader = new StringReader(atlasData); Atlas atlas = new Atlas(atlasReader, "", textureLoader); SkeletonData skeletonData; //加载skeleton switch (loadType) { case SkeletonLoadType.Json: if (!TryLoadSkeletonJson(atlasNode, atlas, out skeletonData)) { goto _failed; } break; case SkeletonLoadType.Binary: if (!TryLoadSkeletonBinary(atlasNode, atlas, out skeletonData)) { goto _failed; } break; default: case SkeletonLoadType.Auto: if (!TryLoadSkeletonJson(atlasNode, atlas, out skeletonData) && !TryLoadSkeletonBinary(atlasNode, atlas, out skeletonData)) { goto _failed; } break; } return(skeletonData); _failed: if (atlas != null) { atlas.Dispose(); } return(null); }
public static bool FindMapByID(int mapID, out Wz_Node mapImgNode) { string fullPath = string.Format(@"Map\Map\Map{0}\{1:D9}.img", (mapID / 100000000), mapID); mapImgNode = PluginManager.FindWz(fullPath); Wz_Image mapImg; if (mapImgNode != null && (mapImg = mapImgNode.GetValueEx <Wz_Image>(null)) != null && mapImg.TryExtract()) { mapImgNode = mapImg.Node; return(true); } else { mapImgNode = null; return(false); } }
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); }
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); }
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; }
public static string ValueToStr(this Wz_Node Node) { return(Node.GetValueEx <string>("")); }
public static int ValueToInt(this Wz_Node Node) { return(Node.GetValueEx <int>(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(); } }