protected SwitchingAura(SwitchingAura prototype, IPlayable owner) : base(prototype, owner) { _initialisationCondtion = prototype._initialisationCondtion; _offTrigger = prototype._offTrigger; _offHandler = TurnOff; _onHandler = TurnOn; }
public override void Activate(IPlayable owner, bool cloning = false) { if (Effects == null) { Effects = EnchantmentCard.Power.Enchant.Effects; } var instance = new SwitchingAura(this, owner); AddToGame(owner, instance); owner.Game.TriggerManager.TurnStartTrigger += instance._onHandler; owner.Game.TriggerManager.EndTurnTrigger += instance._offHandler; switch (_offTrigger) { case TriggerType.PLAY_MINION: owner.Game.TriggerManager.PlayMinionTrigger += instance._offHandler; break; case TriggerType.CAST_SPELL: owner.Game.TriggerManager.CastSpellTrigger += instance._offHandler; break; default: throw new NotImplementedException(); } if (!cloning) { if (!instance._initialisationCondtion.Eval(owner)) { instance.On = false; } else { instance.AuraUpdateInstructionsQueue.Enqueue(new AuraUpdateInstruction(Instruction.AddAll), 1); } } }