|
| 1 | +using Reactive.Bindings; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Linq; |
| 5 | +using System.Text; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using System.Windows; |
| 8 | +using TUSB_ProgressViewer.Controls; |
| 9 | +using TUSB_ProgressViewer.Util; |
| 10 | + |
| 11 | +namespace TUSB_ProgressViewer.Models |
| 12 | +{ |
| 13 | + public static class IslandsData |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// 島リスト |
| 17 | + /// </summary> |
| 18 | + public static ReactiveCollection<IslandPointer> Islands { get; } = new ReactiveCollection<IslandPointer>(); |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// 島攻略数カウント |
| 22 | + /// </summary> |
| 23 | + public static ReactiveProperty<int> CompletionCount { get; } = new ReactiveProperty<int>(); |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// 島攻略率 |
| 27 | + /// </summary> |
| 28 | + public static ReactiveProperty<double> CompletionRate { get; } = new ReactiveProperty<double>(); |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// 島の数 |
| 32 | + /// </summary> |
| 33 | + private const int islandCount = 50; |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// 島読み込み |
| 37 | + /// </summary> |
| 38 | + /// <param name="count"></param> |
| 39 | + public static void Load(ref int count) |
| 40 | + { |
| 41 | + try |
| 42 | + { |
| 43 | + Islands.ClearOnScheduler(); |
| 44 | + foreach (IslandType type in Enum.GetValues(typeof(IslandType))) |
| 45 | + { |
| 46 | + var island = new Island(type, World.WorldData); |
| 47 | + |
| 48 | + // 実際の座標と画像のピクセル数から画像上の島(エンドポータルフレーム)の位置を計算 |
| 49 | + // 画像のサイズが変わると壊れます() |
| 50 | + var X = (island.IslandType.GetCoordinate().X + 221) / 512.0; |
| 51 | + var Z = (island.IslandType.GetCoordinate().Z + 237) / 512.0; |
| 52 | + |
| 53 | + // 別ディメンションは特殊な位置なので個別指定 |
| 54 | + switch (island.IslandType) |
| 55 | + { |
| 56 | + case IslandType.TheUnderworld: |
| 57 | + X = 47 / 256.0; |
| 58 | + Z = 234 / 256.0; |
| 59 | + break; |
| 60 | + case IslandType.TheNether: |
| 61 | + X = 128 / 256.0; |
| 62 | + Z = 234 / 256.0; |
| 63 | + break; |
| 64 | + case IslandType.GulliversLand: |
| 65 | + X = 183 / 256.0; |
| 66 | + Z = 234 / 256.0; |
| 67 | + break; |
| 68 | + case IslandType.Cloudia: |
| 69 | + X = 43 / 256.0; |
| 70 | + Z = 246 / 256.0; |
| 71 | + break; |
| 72 | + case IslandType.TableMountain: |
| 73 | + X = 82 / 256.0; |
| 74 | + Z = 246 / 256.0; |
| 75 | + break; |
| 76 | + case IslandType.TocultColde: |
| 77 | + X = 157 / 256.0; |
| 78 | + Z = 246 / 256.0; |
| 79 | + break; |
| 80 | + case IslandType.TheEnd: |
| 81 | + X = 218 / 256.0; |
| 82 | + Z = 246 / 256.0; |
| 83 | + break; |
| 84 | + } |
| 85 | + |
| 86 | + Application.Current.Dispatcher.Invoke(() => |
| 87 | + { |
| 88 | + Islands.Add(new IslandPointer() |
| 89 | + { |
| 90 | + IslandName = island.IslandType.GetName(), |
| 91 | + Center = new Point(X, Z), |
| 92 | + IsComplete = island.IsComplete |
| 93 | + }); |
| 94 | + |
| 95 | + CompletionCount.Value = Islands.Where(x => x.IsComplete).Count(); |
| 96 | + CompletionRate.Value = (CompletionCount.Value / (double)islandCount) * 100; |
| 97 | + }); |
| 98 | + |
| 99 | + World.LoadingProgress.Value = (++count / 297.0) * 100; |
| 100 | + } |
| 101 | + } |
| 102 | + catch |
| 103 | + { |
| 104 | + Reset(); |
| 105 | + throw; |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + /// <summary> |
| 110 | + /// データをリセット |
| 111 | + /// </summary> |
| 112 | + public static void Reset() |
| 113 | + { |
| 114 | + Islands.ClearOnScheduler(); |
| 115 | + CompletionCount.Value = 0; |
| 116 | + CompletionRate.Value = 0; |
| 117 | + } |
| 118 | + } |
| 119 | +} |
0 commit comments