public void RefreshActions() { foreach (var item in TurnActions) { Entity.Destroy(item); } TurnActions.Clear(); foreach (var item in HeroEntities) { var turnAction = item.Value.CreateAction <TurnAction>(); if (MonsterEntities.ContainsKey(item.Key)) { turnAction.Target = MonsterEntities[item.Key]; } else { turnAction.Target = MonsterEntities.Values.ToArray().First(); } TurnActions.Add(turnAction); } foreach (var item in MonsterEntities) { var turnAction = item.Value.CreateAction <TurnAction>(); if (HeroEntities.ContainsKey(item.Key)) { turnAction.Target = HeroEntities[item.Key]; } else { turnAction.Target = HeroEntities.Values.ToArray().First(); } TurnActions.Add(turnAction); } }
public static ActorEntity GetMonsterEntity(UInt32 key) { ActorEntity monster; MonsterEntities.TryGetValue(key, out monster); return(monster); }
public CombatEntity AddMonsterEntity(int seat) { var entity = AddChild <CombatEntity>(); entity.IsHero = false; MonsterEntities.Add(seat, entity); entity.SeatNumber = seat; return(entity); }
public void OnCombatEntityDead(CombatEntity combatEntity) { if (combatEntity.IsHero) { HeroEntities.Remove(combatEntity.SeatNumber); } else { MonsterEntities.Remove(combatEntity.SeatNumber); } }
public async void StartCombat() { RefreshActions(); foreach (var item in TurnActions) { if (item.Creator.CheckDead() || item.Target.CheckDead()) { continue; } await item.ApplyTurn(); } await TimerComponent.Instance.WaitAsync(1000); if (HeroEntities.Count == 0 || MonsterEntities.Count == 0) { HeroEntities.Clear(); MonsterEntities.Clear(); await TimerComponent.Instance.WaitAsync(2000); this.Publish(new CombatEndEvent()); return; } StartCombat(); }
public static bool RemoveMonsterEntity(UInt32 key) { ActorEntity removed; return(MonsterEntities.TryRemove(key, out removed)); }
public static void EnsureMonsterEntity(UInt32 key, ActorEntity entity) { MonsterEntities.AddOrUpdate(key, entity, (k, v) => entity); }