public RulerGivenSkillContainerSkill(IRulerGivenSkill InnerSkill, Allegiance al) { innerSkillType = InnerSkill.GetType(); Allegiance = al; masterList = new Dictionary<Player, IRulerGivenSkill>(); var trigger = new AutoNotifyPassiveSkillTrigger( this, DistributeSkills, TriggerCondition.OwnerIsSource ) { IsAutoNotify = false, AskForConfirmation = false }; var trigger2 = new AutoNotifyPassiveSkillTrigger( this, (p, e, a) => { if (a.Source.Allegiance == Allegiance && !masterList.ContainsKey(a.Source)) { DistributeSkills(Owner, null, null); } if (a.Source.Allegiance != Allegiance && masterList.ContainsKey(a.Source)) { ISkill skill = masterList[a.Source]; masterList.Remove(a.Source); Game.CurrentGame.PlayerLoseAdditionalSkill(a.Source, skill, true); } }, TriggerCondition.Global ) { IsAutoNotify = false, AskForConfirmation = false }; Triggers.Add(GameEvent.PlayerGameStartAction, trigger); Triggers.Add(GameEvent.PlayerChangedAllegiance, trigger2); IsAutoInvoked = null; IsRulerOnly = true; }
protected void DistributeSkills(Player owner, GameEvent gameEvent, GameEventArgs eventArgs) { foreach (var player in Game.CurrentGame.AlivePlayers) { if ((QualifiedAllegiance == null || player.Allegiance == QualifiedAllegiance) && owner != player && !masterList.ContainsKey(player)) { IRulerGivenSkill skill = Activator.CreateInstance(innerSkillType) as IRulerGivenSkill; Trace.Assert(skill != null); skill.Master = owner; masterList.Add(player, skill); Game.CurrentGame.PlayerAcquireAdditionalSkill(player, skill, HeroTag, true); } } }
public RulerGivenSkillContainerSkill(IRulerGivenSkill InnerSkill, Allegiance?al, bool NotARuler = false) { innerSkillType = InnerSkill.GetType(); QualifiedAllegiance = al; masterList = new Dictionary <Player, IRulerGivenSkill>(); var trigger = new AutoNotifyPassiveSkillTrigger( this, DistributeSkills, TriggerCondition.OwnerIsSource ) { IsAutoNotify = false, AskForConfirmation = false }; var trigger2 = new AutoNotifyPassiveSkillTrigger( this, (p, e, a) => { if ((QualifiedAllegiance == null || a.Source.Allegiance == QualifiedAllegiance) && !masterList.ContainsKey(a.Source)) { DistributeSkills(Owner, null, null); } if (QualifiedAllegiance != null && a.Source.Allegiance != QualifiedAllegiance && masterList.ContainsKey(a.Source)) { ISkill skill = masterList[a.Source]; masterList.Remove(a.Source); Game.CurrentGame.PlayerLoseAdditionalSkill(a.Source, skill, true); } }, TriggerCondition.Global ) { IsAutoNotify = false, AskForConfirmation = false }; Triggers.Add(GameEvent.PlayerGameStartAction, trigger); Triggers.Add(GameEvent.PlayerChangedAllegiance, trigger2); IsAutoInvoked = null; IsRulerOnly = !NotARuler; }