Exemple #1
0
        // Calculates the manhatten distance from the current node to the end node.
        private int CalculateHScore(NavNode currentNode)
        {
            int xDist = Mathf.Abs(currentNode.GetIndex().x - endWrapper.node.GetIndex().x);
            int yDist = Mathf.Abs(currentNode.GetIndex().y - endWrapper.node.GetIndex().y);

            return(xDist + yDist);
            //return Mathf.Abs(currentNode.GetIndex().x - endWrapper.node.GetIndex().x) + Mathf.Abs(currentNode.GetIndex().y - endWrapper.node.GetIndex().y);
        }
Exemple #2
0
        bool AreAdjacentTilesBlocked(NavNode node, int offsetX, int offsetY)
        {
            Vector3Int adjIndex = new Vector3Int(node.GetIndex().x + offsetX, currentNavWrapper.node.GetIndex().y, Controls.GetTileZpf());
            NavNode    adjNode  = pf.GetNode(adjIndex);

            if (adjNode == null || adjNode.IsBlocked())
            {
                return(true);
            }
            adjIndex.x -= offsetX;
            adjIndex.y += offsetY;
            adjNode     = pf.GetNode(adjIndex);
            if (adjNode == null || adjNode.IsBlocked())
            {
                return(true);
            }
            return(false);
        }
Exemple #3
0
 // Calculates the manhatten distance from the current node to the end node.
 private int CalculateHScore(NavNode currentNode)
 {
     return(Mathf.Abs(currentNode.GetIndex().x - endWrapper.node.GetIndex().x) + Mathf.Abs(currentNode.GetIndex().y - endWrapper.node.GetIndex().y));
 }