public virtual void Open (AstarPath.BinaryHeap open, AstarPath.Path p, Node start, Node end, float angleCost) { for (int i=0;i<enabledConnections.Length;i++) { Connection connection = enabledConnections[i]; Node node = connection.endNode; if (node == start) { continue; } //Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.red); //Uncomment for debug //If the nodes script variable isn't refering to this path class the node counts as "not used yet" and can then be used if (node.script != p) { //Test if the angle from the current node to this one has exceded the angle limit //if (angle >= maxAngle) { // return; //} node.parent = this; node.script = p; node.basicCost = connection.cost + Mathf.RoundToInt (connection.cost*connection.angle*angleCost); //(current.costs == null || costs.Length == 0 ? costs[node.invParentDirection] : current.costs[node.invParentDirection]); //Calculate the extra cost of moving in a slope //node.extraCost = ; //Add the node to the open array //Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.green); //Uncomment for @Debug node.UpdateH (end); node.UpdateG (); open.Add (node); } else { //If not we can test if the path from the current node to this one is a better one then the one already used int cost2 = connection.cost + Mathf.RoundToInt (connection.cost*connection.angle*angleCost);//(current.costs == null || current.costs.Length == 0 ? costs[current.neighboursKeys[i]] : current.costs[current.neighboursKeys[i]]); //int extraCost2 if (g+cost2+node.penalty < node.g) { node.basicCost = cost2; //node.extraCost = extraCost2; node.parent = this; node.UpdateAllG (); open.Add (node);//@Quality, uncomment for better quality (I think). //Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.cyan); //Uncomment for @Debug } else if (node.g+cost2+penalty < g) {//Or if the path from this node ("node") to the current ("current") is better bool contains = false; //Make sure we don't travel along the wrong direction of a one way link now, make sure the Current node can be accesed from the Node. for (int y=0;y<node.connections.Length;y++) { if (node.connections[y].endNode == this) { contains = true; break; } } if (!contains) { continue; } parent = node; basicCost = cost2; //extraCost = extraCost2; node.UpdateAllG (); //Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.blue); //Uncomment for @Debug open.Add (this); } } } }