public AStarNodeRecord(AStarNodeRecord record) { this.node = record.node; this.connection = record.connection; this.costSoFar = record.costSoFar; this.estimatedTotalCost = record.estimatedTotalCost; }
public AStarNodeRecord(AStarNode inNode, AStarConnection con, float cost, float estimate) { this.node = inNode; this.connection = con; this.costSoFar = cost; this.estimatedTotalCost = estimate; }
public void Reparent(AStarConnection p, float lcost) { parent = p; linkCost = lcost; totalCost = p.totalCost + linkCost; estimatedFinalCost = totalCost + (target - tile.transform.position).magnitude; }
public AStarConnection(Tile t, AStarConnection p, float lcost) { tile = t; parent = p; linkCost = lcost; totalCost = (parent != null) ? parent.totalCost + linkCost : 0; estimatedFinalCost = (tile != null) ? totalCost + (target - tile.transform.position).magnitude : float.MaxValue; }
public AStarNode() { north = new AStarConnection(); north_west = new AStarConnection(); west = new AStarConnection(); south_west = new AStarConnection(); south = new AStarConnection(); south_east = new AStarConnection(); east = new AStarConnection(); north_east = new AStarConnection(); }
private bool PlaceInCorrectList(Tile t, AStarConnection c, float linkCost) { if (t == null) return false; if (t.pathingType == PathingType.UnPathable || t.pathingType == PathingType.AirOnly) return false; // check if the tile is on the open list. var openListInstance = OpenList.Where(conn => conn.tile.Equals(t)); if (openListInstance.Count() > 0) // it's on the open list. { var conn = openListInstance.First(); if (conn.totalCost > c.totalCost + linkCost) // this new path is shorter { conn.Reparent(c, linkCost); } return true; } // check if the tile is on the closed list. var closedListInstance = ClosedList.Where(conn => conn.tile.Equals(t)); if (closedListInstance.Count() > 0) // it's on the closed list. { return true; } // not on either list, add it to the open list. OpenList.Add(new AStarConnection(t, c, linkCost)); return true; }
public void Removeconneciton(AStarConnection connection) { connections.Remove(connection); }
public void AddConnection(AStarConnection connection) { connections.Add(connection); }