Exemplo n.º 1
0
    public Vector2Int getNeighborOrigin(Vector2Int origin, HexMath.Side side)
    {
        if (flatTop)
        {
            switch (side)
            {
            case HexMath.Side.NORTH:                return(origin + new Vector2Int(0, 1));

            case HexMath.Side.NORTH_EAST:   return(origin + new Vector2Int(1, (origin.x % 2) == 0 ? 1 : 0));

            //case HexMath.Side.EAST:			return InvalidPos;
            case HexMath.Side.SOUTH_EAST:   return(origin + new Vector2Int(1, (origin.x % 2) == 0 ? 0 : -1));

            case HexMath.Side.SOUTH:                return(origin + new Vector2Int(0, -1));

            case HexMath.Side.SOUTH_WEST:   return(origin + new Vector2Int(-1, (origin.x % 2) == 0 ? 0 : -1));

            //case HexMath.Side.WEST:			return InvalidPos;
            case HexMath.Side.NORTH_WEST:   return(origin + new Vector2Int(-1, (origin.x % 2) == 0 ? 1 : 0));
            }
        }
        else
        {
            switch (side)
            {
            //case HexMath.Side.NORTH: return InvalidPos;
            case HexMath.Side.NORTH_EAST: return(origin + new Vector2Int((origin.y % 2) == 0 ? 1 : 0, 1));

            case HexMath.Side.EAST: return(origin + new Vector2Int(1, 0));

            case HexMath.Side.SOUTH_EAST: return(origin + new Vector2Int((origin.y % 2) == 0 ? 1 : 0, -1));

            //case HexMath.Side.SOUTH: return InvalidPos;
            case HexMath.Side.SOUTH_WEST: return(origin + new Vector2Int((origin.y % 2) == 0 ? 0 : -1, -1));

            case HexMath.Side.WEST: return(origin + new Vector2Int(-1, 0));

            case HexMath.Side.NORTH_WEST: return(origin + new Vector2Int((origin.y % 2) == 0 ? 0 : -1, 1));
            }
        }
        return(InvalidPos);
    }
Exemplo n.º 2
0
 public HEX_TYPE findNeighbor(Vector2Int origin, HexMath.Side side)
 {
     return(find(getNeighborOrigin(origin, side)));
 }