방향성 지정 오류 수정
This commit is contained in:
Binary file not shown.
@@ -225,6 +225,9 @@ namespace AStarPathFinding
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
// 방향성 초기 값
|
||||||
|
Form1.Direction = "Up";
|
||||||
|
|
||||||
AstarNode openNode;
|
AstarNode openNode;
|
||||||
|
|
||||||
//예비 자식이 될 노드들의 좌표 계산
|
//예비 자식이 될 노드들의 좌표 계산
|
||||||
@@ -287,32 +290,32 @@ namespace AStarPathFinding
|
|||||||
// continue;
|
// continue;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (dicOpenList.ContainsKey(focusNode.axis) & tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad)
|
//if (dicOpenList.ContainsKey(focusNode.axis) & tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad)
|
||||||
{
|
//{
|
||||||
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
// openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
openNode.SetParent(focusNode);
|
// openNode.SetParent(focusNode);
|
||||||
openNode.SetGCost(gCost + openNode.parent.R);
|
// openNode.SetGCost(gCost + openNode.parent.R);
|
||||||
openNode.SetHCost(openNode.parent.R - 1000);
|
// openNode.SetHCost(openNode.parent.R - 1000);
|
||||||
openNode.ParentDirection = neerAxis[i];
|
// openNode.ParentDirection = neerAxis[i];
|
||||||
|
|
||||||
dicOpenList.Add(tempChildAxis, openNode);
|
// dicOpenList.Add(tempChildAxis, openNode);
|
||||||
tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open;
|
// tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open;
|
||||||
|
|
||||||
Form1.Direction = false;
|
// //Form1.Direction = false;
|
||||||
|
|
||||||
//dicCloseList.Remove(focusNode.axis);
|
// //dicCloseList.Remove(focusNode.axis);
|
||||||
//dicOpenList.Add(focusNode.axis, focusNode);
|
// //dicOpenList.Add(focusNode.axis, focusNode);
|
||||||
//tableStateData[focusNode.axis.X, focusNode.axis.Y] = eTileState.Close;
|
// //tableStateData[focusNode.axis.X, focusNode.axis.Y] = eTileState.Close;
|
||||||
|
|
||||||
continue;
|
// continue;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//만일 클로즈 리스트에 있어도 무시한다.
|
//만일 클로즈 리스트에 있어도 무시한다.
|
||||||
if (dicCloseList.ContainsKey(tempChildAxis))
|
if (dicCloseList.ContainsKey(tempChildAxis))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// !!!길일 때 오픈리스트에 넣어준다.
|
// !!!길일 때 오픈리스트에 넣어준다.
|
||||||
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == true)
|
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == "Right")
|
||||||
{
|
{
|
||||||
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
openNode.SetParent(focusNode);
|
openNode.SetParent(focusNode);
|
||||||
@@ -326,7 +329,7 @@ namespace AStarPathFinding
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == false)
|
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == "Left")
|
||||||
{
|
{
|
||||||
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
openNode.SetParent(focusNode);
|
openNode.SetParent(focusNode);
|
||||||
@@ -340,7 +343,7 @@ namespace AStarPathFinding
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == true)
|
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == "Right")
|
||||||
{
|
{
|
||||||
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
openNode.SetParent(focusNode);
|
openNode.SetParent(focusNode);
|
||||||
@@ -354,7 +357,7 @@ namespace AStarPathFinding
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == false)
|
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == "Left")
|
||||||
{
|
{
|
||||||
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
openNode.SetParent(focusNode);
|
openNode.SetParent(focusNode);
|
||||||
@@ -368,6 +371,21 @@ namespace AStarPathFinding
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.URoad & Form1.Direction == "Up")
|
||||||
|
{
|
||||||
|
openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y];
|
||||||
|
openNode.SetParent(focusNode);
|
||||||
|
openNode.SetGCost(gCost + openNode.parent.U);
|
||||||
|
openNode.SetHCost(openNode.parent.U - 1000); // 휴리스틱 값 수정해서 길 따라갈 수 있게 점수를 낮춰줌 수정
|
||||||
|
|
||||||
|
openNode.ParentDirection = neerAxis[i];
|
||||||
|
|
||||||
|
dicOpenList.Add(tempChildAxis, openNode);
|
||||||
|
tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
////대각선일시 자신의 주변을 체크 후 벽이있다면 무시한다(벽끼고 대각선이동 불가)
|
////대각선일시 자신의 주변을 체크 후 벽이있다면 무시한다(벽끼고 대각선이동 불가)
|
||||||
//if (gCost == 14)
|
//if (gCost == 14)
|
||||||
//{
|
//{
|
||||||
|
|||||||
6
Form1.cs
6
Form1.cs
@@ -17,7 +17,7 @@ namespace AStarPathFinding
|
|||||||
|
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
public static bool Direction { get; set; } // 방향 설정!!!
|
public static string Direction { get; set; } // 방향 설정!!!
|
||||||
|
|
||||||
//구조체=====================
|
//구조체=====================
|
||||||
struct stCurrentAction//사용자의 세팅(타일배치)종류 확인용 구조체
|
struct stCurrentAction//사용자의 세팅(타일배치)종류 확인용 구조체
|
||||||
@@ -417,14 +417,14 @@ namespace AStarPathFinding
|
|||||||
SetCurrentAction(null, eTileState.None);
|
SetCurrentAction(null, eTileState.None);
|
||||||
pathFinder.PathFind(pn_Table, startPoint, goalPoint);
|
pathFinder.PathFind(pn_Table, startPoint, goalPoint);
|
||||||
clickState = false;
|
clickState = false;
|
||||||
Direction = false;
|
Direction = "Up";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCurrentAction(null, eTileState.None);
|
SetCurrentAction(null, eTileState.None);
|
||||||
pathFinder.PathFind(pn_Table, goalPoint, startPoint);
|
pathFinder.PathFind(pn_Table, goalPoint, startPoint);
|
||||||
clickState = true;
|
clickState = true;
|
||||||
Direction = true;
|
Direction = "Up";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user