コード例 #1
0
        private AdaptiveCostEffectObsolete(AdaptiveCostEffectObsolete prototype, IPlayable owner)
        {
            if (!(owner is Playable p))
            {
                throw new Exception($"Can't activate {this} to non-playable {owner}");
            }

            _owner = p;

            _costFunction      = prototype._costFunction;
            _value             = prototype._value;
            _triggerType       = prototype._triggerType;
            _triggerSource     = prototype._triggerSource;
            _condition         = prototype._condition;
            _updateHandler     = Trigger;
            _removedHandler    = RemoveAtEnd;
            _isTriggered       = prototype._isTriggered;
            _isAppliedThisTurn = prototype._isAppliedThisTurn;

            if (prototype._initialisationFunction != null)
            {
                _initialisationFunction = prototype._initialisationFunction;
                _cachedValue            = prototype._initialisationFunction.Invoke(p);
            }
        }
コード例 #2
0
        public void Activate(Playable owner, bool cloning = false)
        {
            if (!cloning && !(owner.Zone is HandZone))
            {
                return;
            }

            var instance = new AdaptiveCostEffectObsolete(this, owner);

            if (owner._costManager == null)
            {
                owner._costManager = new Playable.CostManager();
            }

            owner._costManager.ActivateAdaptiveEffect(instance);
            owner.OngoingEffect = instance;

            switch (_triggerType)
            {
            case TriggerType.NONE:
                break;

            case TriggerType.HEAL:
                owner.Game.TriggerManager.HealTrigger += instance._updateHandler;
                break;

            case TriggerType.DEATH:
                owner.Game.TriggerManager.DeathTrigger += instance._updateHandler;
                break;

            case TriggerType.CAST_SPELL:
                owner.Game.TriggerManager.CastSpellTrigger += instance._updateHandler;
                break;

            case TriggerType.TURN_START:
                owner.Game.TriggerManager.TurnStartTrigger += instance._updateHandler;
                break;

            case TriggerType.ZONE:
                owner.Game.TriggerManager.ZoneTrigger += instance._updateHandler;
                break;

            default:
                throw new NotImplementedException();
            }

            owner.Game.Auras.Add(instance);
        }