private static IEnumerable<EnemyCellViewModel> CreateMapCellViewModelsFromEnemiesData(
     MapInfo mi,
     IReadOnlyDictionary<MapInfo, Dictionary<MapCell, Dictionary<string, FleetData>>> mapEnemies,
     IReadOnlyDictionary<MapCell, CellType> cellTypes)
 {
     return mapEnemies.Where(info => info.Key.Id == mi.Id)
         .Select(info => info.Value)
         .SelectMany(cells => cells)
         .Select(cell => new EnemyCellViewModel
         {
             Key = cell.Key.IdInEachMapInfo,
             EnemyFleets = cell.Value
                 .Select(enemy => new EnemyFleetViewModel
                 {
                     Key = enemy.Key,
                     Fleet = enemy.Value,
                     EnemyShips = enemy.Value.Ships.Select(s => new EnemyShipViewModel { Ship = s }).ToArray(),
                 })
                 .GroupBy(x => x.Key, EnemyData.Curret.GetComparer())
                 .Select(x => x.First())
                 .OrderBy(enemy => enemy.Key)
                 .ToArray(),
             ColorNo = cell.Key.ColorNo,
             CellType = cell.Key.GetCellType(cellTypes),
         });
 }
 private static EnemyCellViewModel[] CreateEnemyCells(
     MapInfo mi,
     IReadOnlyDictionary<MapInfo, Dictionary<MapCell, Dictionary<string, FleetData>>> mapEnemies,
     IReadOnlyDictionary<MapCell, CellType> cellTypes)
 {
     return MapResource.HasMapSwf(mi)
         ? MapResource.GetMapCellPoints(mi) //マップSWFがあったらそれを元に作る
             //外部結合
             .GroupJoin(
                 CreateMapCellViewModelsFromEnemiesData(mi, mapEnemies, cellTypes),
                 outer => outer.Key,
                 inner => inner.Key,
                 (o, ie) => new { point = o, cells = ie })
             .SelectMany(
                 x => x.cells.DefaultIfEmpty(),
                 (x, y) => new { x.point, cells = y })
             //座標マージ
             .GroupBy(x => x.point.Value)
             .Select(x => new EnemyCellViewModel
             {
                 Key = x.Min(y => y.point.Key), //若い番号を採用
                 EnemyFleets = x.Where(y => y.cells != null) //敵データをEnemyIdでマージ
                     .SelectMany(y => y.cells.EnemyFleets)
                     .GroupBy(y => y.Key, EnemyData.Curret.GetComparer())
                     .OrderBy(y => y.Key)
                     .Select(y => y.First())
                     .ToArray(),
                 ColorNo = x.Where(y => y.cells != null).Select(y => y.cells.ColorNo).FirstOrDefault(),
                 CellType = x.Where(y => y.cells != null).Select(y => y.cells.CellType).FirstOrDefault(),
             })
             //敵データのないセルは除外
             .Where(x => x.EnemyFleets.Any())
             .ToArray()
         : CreateMapCellViewModelsFromEnemiesData(mi, mapEnemies, cellTypes) //なかったら敵データだけ(重複るが仕方ない)
             .OrderBy(cell => cell.Key)
             .ToArray();
 }
 private static IEnumerable<EnemyCellViewModel> CreateMapCellViewModelsFromEnemiesData(
     MapInfo mi,
     IReadOnlyDictionary<MapInfo, Dictionary<MapCell, Dictionary<string, FleetData>>> mapEnemies,
     IReadOnlyDictionary<MapCell, CellType> cellTypes)
 {
     return mapEnemies.Where(info => info.Key.Id == mi.Id)
         .Select(info => info.Value)
         .SelectMany(cells => cells)
         .Select(cell => new EnemyCellViewModel
         {
             Key = cell.Key.IdInEachMapInfo,
             EnemyFleets = cell.Value.MergeEnemies(),
             ColorNo = cell.Key.ColorNo,
             CellType = cell.Key.GetCellType(cellTypes),
         });
 }