internal NavNode FindNode(Vector2 pos) { NavNode node = nodes .Where(i => pos.CastNav(i.pos)) .OrderBy(i => (pos - i.pos).sqrMagnitude) .FirstOrDefault(); if (node == null) { Debug.Log("find node null"); } return(node); }
void WeaveBranches(NavNode pivot, HashSet <Bezite> branches) { foreach (Bezite branch in branches) { bezite = branch; List <NavNode> nodes = new List <NavNode>(new Linker <NavNode>(InitNode, Eval).result); this.nodes.Remove(nodes[0]); nodes.RemoveAt(0); pivot.Link(nodes[0]); for (int i = 0; i < nodes.Count - 1; i++) { nodes[i].Link(nodes[i + 1]); } } }
public void createDownNodeAt(int x, int y, int depth, float cost) { if (grid [x, y] != null) { if (grid [x, y].getDownNode() != null) { NavNode temp = grid [x, y].getDownNode(); while (temp.getDownNode() != null) { temp = temp.getDownNode(); } NavNode newNode = new NavNode(cost, depth); temp.setDownNode(newNode); } else { NavNode newNode = new NavNode(cost, depth); grid [x, y].getDownNode().setDownNode(newNode); } } }
void FindPathRec() { if (current == target) { return; } foreach (KeyValuePair <NavNode, float> link in current.links) { NavNode node = link.Key; if (node.closed) { continue; } node.Calibrate(current, target.pos); openNodes.Add(node); } openNodes.Remove(current); current.closed = true; current = openNodes.OrderBy(i => i.TotalDist).FirstOrDefault(); FindPathRec(); }
internal void Optimize() { List <NavNode> nodes = this.nodes .OrderByDescending(i => i.links.Count) .Where(i => i.links.Count > 1).ToList(); for (int i = 0; i < nodes.Count; i++) { NavNode node = nodes[i]; NavNode[] links = node.links.Keys .OrderBy(j => (j.pos - node.pos).Angle()) .ToArray(); if (Removable(links)) { LinkAround(node, links); this.nodes.Remove(node); } } foreach (NavNode node in this.nodes) { node.GenWeights(); } }
public void setDownNode(NavNode node) { down = node; }
public void updateNavNodeDepth(NavNode node, int depth) { node.setDepth(depth); }
public void updateNavNodeCost(NavNode node, float Cost) { node.setCost(Cost); }