示例#1
0
        public IHexCell GetCellAtPoint(Vector3 point)
        {
            if (!Grid.HasCellAtLocation(point))
            {
                return(null);
            }

            var gridCell = Grid.GetCellAtLocation(point);

            foreach (var direction in EnumUtil.GetValues <HexDirection>())
            {
                if (CellContourCanon.IsPointWithinContour(point.ToXZ(), gridCell, direction))
                {
                    return(gridCell);
                }
            }

            foreach (var neighbor in Grid.GetNeighbors(gridCell))
            {
                foreach (var direction in EnumUtil.GetValues <HexDirection>())
                {
                    if (CellContourCanon.IsPointWithinContour(point.ToXZ(), neighbor, direction.Opposite()))
                    {
                        return(neighbor);
                    }
                }
            }

            return(null);
        }