private void OpenDoor() { for (int i = 0; i < data.level.doors.Count; i++) { if (Vector2.Adjacent(data.level.doors[i].position, data.player.position)) { data.level.doors[i].Switch(); } } }
/// <summary> /// Neighbours function for the map /// </summary> /// <param name="node">Current node position</param> /// <param name="map">Map to find the neighbours in</param> /// <returns>An enumerable of all the neighbours of the current node</returns> private static IEnumerable <(Vector2 <int>, double)> FindNeighbours(Vector2 <int> node, Grid <byte> map) { return(node.Adjacent() .Where(map.WithinGrid) .Select(neighbour => (neighbour, (double)map[neighbour]))); }