Exemple #1
0
    public int CalcDist(GroundNode _dest)
    {
        int x = Mathf.FloorToInt(Mathf.Abs(thisPos.x - _dest.GetPosition().x));
        int y = Mathf.FloorToInt(Mathf.Abs(thisPos.y - _dest.GetPosition().y));

        return(x * 10 + y * 10);
    }
Exemple #2
0
    public int CalcDistNeighbor(GroundNode _neighbor)
    {
        int x = Mathf.FloorToInt(Mathf.Abs(thisPos.x - _neighbor.GetPosition().x));
        int y = Mathf.FloorToInt(Mathf.Abs(thisPos.y - _neighbor.GetPosition().y));

        if (x + y == 2)
        {   //이웃노드가 대각선으로 인접한 경우
            return(14);
        }
        else if (x + y == 1)
        {   //이웃노드가 수직/수평선으로 인접한 경우
            return(10);
        }
        else
        {   //이웃노드가 비정상적(부모가 인접한 노드가 아니거나 자기자신인 경우)
            return(0);
        }
    }
Exemple #3
0
    public int CalcGScore()
    {
        int myGScore;
        int x = Mathf.FloorToInt(Mathf.Abs(thisPos.x - parentNode.GetPosition().x));
        int y = Mathf.FloorToInt(Mathf.Abs(thisPos.y - parentNode.GetPosition().y));

        if (x + y == 2)
        {   //부모노드와 대각선으로 인접한 경우
            myGScore = 14;
        }
        else if (x + y == 1)
        {   //부모노드와 수직/수평으로 인접한 경우
            myGScore = 10;
        }
        else
        {
            myGScore = 0;  //부모노드가 비정상적(부모가 인접한 노드가 아니거나 자기자신인 경우)
        }

        return(myGScore);
    }
Exemple #4
0
 public bool IsSamePosition(GroundNode _node)
 {
     return(_node.GetPosition() == thisPos);
 }