private static void Main(string[] args) { MessageBroker.SetMessageBroker(new DefaultMessageBroker()); EventAggregator.SetAggregator(new DefaultEventAggregator()); CombatEncounterService.Create(); EventAggregator .Subscribe<PlayerReadyForActionEvent>(OnPlayerReadyForAction) .Subscribe<DamageEvent>(OnDamage) .Subscribe<RoundBeganEvent>(OnRoundStart) .Subscribe<RoundEndEvent>(OnRoundEnd) .Subscribe<PlayersWinEvent>(OnPlayersWin) .Subscribe<MonstersWinEvent>(OnMonstersWin) .Subscribe<CombatStartedEvent>(OnCombatStarted); _party = new List<IPlayerCombatMember>(); _party.Add(new PlayerCombatMember(100, "JB")); _monsters = new List<IMonsterCombatMember>(); IMonsterCombatMember monster = new MonsterCombatMember(20, "Monster") .SetTargetStrategy(new RandomTargetStrategy()) .SetCombatActionStrategy(new RegularAttackStrategy()); _monsters.Add(monster); var message = new StartCombatMessage(_party, _monsters); MessageBroker.Send(message); while (true) { } }
/// <summary> /// Called when [start combat]. /// </summary> /// <param name="m">The m.</param> private void OnStartCombat(StartCombatMessage m) { EventAggregator.Publish(new CombatStartedEvent(m.Players, m.Monsters)); _currentCombat = new CombatEncounter() .SetPlayers(m.Players) .AddMonsters(m.Monsters) .BeginCombat(); }
private void OnCombat() { var players = new List<IPlayerCombatMember> { new PlayerCombatMember(100, "JB") }; var monsters = new List<IMonsterCombatMember> { new MonsterCombatMember(50, "Monster") }; var message = new StartCombatMessage(players, monsters); MessageBroker.Send(message); }