public static GraphCtrl AddJsonToLinkCloud(JsonLinkCloud jsonlc, GraphCtrl grc) { var reg = jsonlc.region; Debug.Log(" AddJsonToLinkCloud reg.name:" + reg.name); var nreg = grc.regman.NewNodeRegion(reg.name, reg.color, saveToFile: true, makeCurrent: true); foreach (var node in jsonlc.nodes.list) { if (grc.nodeExists(node.name)) { Debug.LogWarning("Node " + node.name + " already exists"); } else { grc.AddNode(node.name, node.pt); } } foreach (var jslink in jsonlc.links.list) { var lnk = grc.AddLinkByNodeName(jslink.n1, jslink.n2, jslink.name); if (jslink.usetype != null) { System.Enum.TryParse <LinkUse>(jslink.usetype, true, out lnk.usetype); } } grc.floorMan = jsonlc.floorplan; return(grc); }
public static JsonLinkCloud MakeJson(GraphCtrl lc, ref NodeRegion region) { int nnodes = 0; int nlinks = 0; var jsonlc = new JsonLinkCloud(region, lc.floorMan); var regionFilter = region.regid; if (region.name == "default") { regionFilter = 0; } foreach (var nname in lc.nodenamelist) { var node = lc.GetNode(nname); if (node.IsInRegion(region.regid)) { jsonlc.AddNode(node.name, node.pt); nnodes += 1; } } foreach (var lname in lc.linknamelist) { var link = lc.GetLink(lname); if (link.node1.IsInRegion(regionFilter) && link.node2.IsInRegion(regionFilter)) { jsonlc.AddLink(link.name, link.node1.name, link.node2.name, link.usetype.ToString()); nlinks += 1; } } //GraphUtil.Log("MakeJson nnodes:" + nnodes + " nlinks:" + nlinks); //Debug.Log("MakeJson nnodes:" + nnodes + " nlinks:" + nlinks); return(jsonlc); }
public LcMapMaker(GraphCtrl grc, MapGenParameters mgp = null) { if (mgp != null) { this.mgp = mgp; } this.grc = grc; lmd = new LcMapData(this, grc); }
public LcNode(GraphCtrl grc, string name, Vector3 pt, LinkUse usetype, ref NodeRegion nodeRegion, string comment = "") { this.grc = grc; this.name = name; this.pt = pt; this.usetype = usetype; this.regid = nodeRegion.regid; this.comment = comment; regionStepIdx = nodeRegion.GetCurStepIdx(); wegtos = null; AstarInit(); }
public LcLink(GraphCtrl grc, string name, LcNode node1, LcNode node2, LinkUse usetype = LinkUse.legacy, string comment = "") { this.grc = grc; this.usetype = usetype; this.name = name; this.node1 = node1; this.node2 = node2; this.node1spec = ""; this.node2spec = ""; this.comment = ""; var regid = grc.regman.curNodeRegion.regid; if (node1.regid == node2.regid) { regid = node1.regid; } this.regid = regid; this.regionStepIdx = grc.regman.curNodeRegion.GetCurStepIdx(); len = Vector3.Distance(node1.pt, node2.pt); LinkLink(); }
public static void SaveToFile(GraphCtrl grc, string fname, ref NodeRegion region) { var jsonlc = LcMapMaker.MakeJson(grc, ref region); JsonLinkCloud.WriteToFile(jsonlc, fname); }
public CodeFileSaver(GraphCtrl grc) { this.grc = grc; }
public void SetGraphCtrl(GraphCtrl grc) { this.grc = grc; }