Пример #1
0
        /// <summary>
        /// Gets the neighbour grid component to a given position in the given direction, if one exists.
        /// The predefined directions on the <see cref="DirectionVector"/> can be combined for more combinations.
        /// </summary>
        /// <param name="mgr">The grid manager.</param>
        /// <param name="position">The position.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>The neighbouring grid, or null if no neighbour exists</returns>
        public static GridComponent GetNeighbourGrid(this IGridManager mgr, Vector3 position, DirectionVector direction)
        {
            var g = mgr.GetGridComponent(position);

            var bounds = g.bounds;
            var pos = bounds.center + ((bounds.extents + Vector3.one) * direction);

            return mgr.GetGridComponent(pos);
        }
Пример #2
0
        /// <summary>
        /// Gets the neighbour grid component in the given direction, if one exists.
        /// The predefined directions on the <see cref="DirectionVector"/> can be combined for more combinations.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>The neighbouring grid, or null if no neighbour exists</returns>
        public static GridComponent GetNeighbourGrid(this GridComponent grid, DirectionVector direction)
        {
            var bounds = grid.bounds;
            var pos = bounds.center + ((bounds.extents + Vector3.one) * direction);

            return GridManager.instance.GetGridComponent(pos);
        }