/// <summary> /// 장애물을 제거합니다. /// </summary> private void TryDestroyObstacle(List <Vector2Int> targetCoords) { var obstacles = new List <IObstacle>(); foreach (var targetCoord in targetCoords) { foreach (var coords in BoardUtil.GetNeighborAll(targetCoord)) { var block = GetBlock(coords); if (block != null && block is IObstacle) { var obstacle = block as IObstacle; if (!obstacles.Exists(x => x == obstacle)) { obstacles.Add(obstacle); } } } } foreach (var obstacle in obstacles) { (obstacle as Block).TryDestroy(); } }
public IEnumerable <Block> GetNeighborAll(Block origin) { return(BoardUtil.GetNeighborAll(origin.coords).Select(x => GetBlock(x)).Where(x => x != null)); }