private void SearchAdjacentNodes(PathNode selectNode) { foreach (Vector2 pos in eightDir) { int searchPosX = selectNode.pathMapDataX + (int)pos.x; int searchPosY = selectNode.pathMapDataZ + (int)pos.y; if ((searchPosX >= 0 && searchPosX < MAP_SIZE_X) && (searchPosY >= 0 && searchPosY < MAP_SIZE_Z)) { if (!IsInClosedList(searchPosX, searchPosY)) { if (!IsInOpenList(searchPosX, searchPosY)) { openList.Add(pathFindMapData[searchPosX, searchPosY]); pathFindMapData[searchPosX, searchPosY].parentNode = curNode; pathFindMapData[searchPosX, searchPosY].Calc_H_Value(goalNode); pathFindMapData[searchPosX, searchPosY].Calc_G_Value(); } else { if ((pathFindMapData[searchPosX, searchPosY].gValue < selectNode.gValue)) { selectNode.parentNode = pathFindMapData[searchPosX, searchPosY]; selectNode.Calc_H_Value(goalNode); selectNode.Calc_G_Value(); } } } } } }
private void SetStartPathNode() { int x = Mathf.RoundToInt(moveObject.position.x); int z = Mathf.RoundToInt(moveObject.position.z); curNode = pathFindMapData[x, z]; curNode.parentNode = null; curNode.Calc_H_Value(goalNode); curNode.Calc_G_Value(); openList.Add(curNode); }