예제 #1
0
    private void BuildNeighborsHandle(HexNode node)
    {
        int more = (int)node.ArrayCoord.x % 2;

        node.SetNeighbor(GetNodeFromArray(new Vector2(node.ArrayCoord.x, node.ArrayCoord.y + 1)), (int)HexNodeDir.NORTH);
        node.SetNeighbor(GetNodeFromArray(new Vector2(node.ArrayCoord.x + 1, node.ArrayCoord.y + more)), (int)HexNodeDir.NORTH_EAST);
        node.SetNeighbor(GetNodeFromArray(new Vector2(node.ArrayCoord.x + 1, node.ArrayCoord.y - 1 + more)), (int)HexNodeDir.SOUTH_EAST);
    }
예제 #2
0
 /// <summary>
 /// 设置邻居
 /// </summary>
 /// <param name="neighbor"></param>
 /// <param name="dir"></param>
 public void SetNeighbor(HexNode neighbor, int hexNodeDir)
 {
     neighbors[hexNodeDir - 1] = neighbor;
     if (neighbor != null)
     {
         if (hexNodeDir <= (int)HexNodeDir.SOUTH_EAST)
         {
             neighbor.SetNeighbor(this, hexNodeDir + (int)HexNodeDir.SOUTH_EAST);
         }
     }
 }