/// <summary> /// コンストラクタ /// </summary> public SkillCountService() { SkillStorage.Create(); PowStorage.Create(); MapStorage.Create(); _skillArrayRecognizer.Updated += (_, e) => SkillsUpdated?.Invoke(this, new SkillsUpdatedEventArgs(e)); _powRecognizer.Updated += (_, e) => PowUpdated?.Invoke(this, new PowUpdatedEventArgs(e)); _hpRecognizer.Updated += (_, e) => HpUpdated?.Invoke(this, new HpUpdatedEventArgs(e)); _powDebuffArrayRecognizer.Updated += (_, e) => PowDebuffsUpdated?.Invoke(this, new PowDebuffsUpdatedEventArgs(e)); _keepDamageRecognizer.Updated += (_, e) => KeepDamageUpdated?.Invoke(this, new KeepDamageUpdatedEventArgs(e)); _bookUseRecognizer.Updated += (_, e) => BookUsesUpdated?.Invoke(this, new BookUsesUpdatedEventArgs(e)); _warStateRecognizer.WarStarted += (_, e) => { Logger.WriteLine("War started."); WarStarted?.Invoke(this, new WarStartedEventArgs(e)); }; _warStateRecognizer.WarCanceled += (_, e) => { Logger.WriteLine("War canceled."); WarCanceled?.Invoke(this, new WarCanceledEventArgs(e)); }; _warStateRecognizer.WarFinished += (_, e) => { Logger.WriteLine("War finished."); WarFinished?.Invoke(this, new WarFinishedEventArgs(e)); }; }
public void Report(Bitmap bitmap) { var state = _previousState; // Map取得 var map = GetMap(bitmap); switch (_previousState) { case WarState.Waiting: // 戦争待機中なら、戦争が開始したかどうかチェックする if (IsCostDisplayed(bitmap) && !map.IsEmpty()) { state = WarState.Waring; WarStarted?.Invoke(this, map); } break; case WarState.Waring: // 戦争中なら、戦争が終了したかどうかチェックする // 考慮事項:FO・死んだときやMAP名上にマウスカーソル if (IsWarResultDisplayed(bitmap) && !map.IsEmpty()) { state = WarState.Waiting; WarFinished?.Invoke(this, map); } // FOして別の戦場を入りなおしたとき、状態はAtWarのままのため、 // 一度Waitingに状態変更通知を投げて、即座に戦争状態に戻す if (!map.IsEmpty() && map != _previousValidMap) { WarCanceled?.Invoke(this, map); WarStarted?.Invoke(this, map); } break; default: throw new Exception("invalid state"); } // 状態更新 _previousState = state; if (!map.IsEmpty()) { _previousValidMap = map; } }