예제 #1
0
    private void ResolveUnconscious(MemberUnconscious m)
    {
        if (!m.Member.TeamType.Equals(TeamType.Enemies))
        {
            return;
        }

        var enemy = state.GetEnemyById(m.Member.Id);

        if (!string.IsNullOrWhiteSpace(enemy.DeathEffect))
        {
            BattleEvent.Publish(new BattleEffectAnimationRequested
            {
                EffectName  = enemy.DeathEffect,
                Scope       = Scope.One,
                Target      = new Single(m.Member),
                Group       = Group.Self,
                PerformerId = m.Member.Id
            });
        }

        var t = state.GetTransform(m.Member.Id);

        t.gameObject.SetActive(false);
    }
예제 #2
0
    public void Perform()
    {
        for (var index = 0; index < _card.Actions.Length; index++)
        {
            var action = _card.Actions[index];
            if (!string.IsNullOrWhiteSpace(action.CharacterAnimation))
            {
                BattleEvent.Publish(new CharacterAnimationRequested(_performer.Id, action.CharacterAnimation));
            }
            if (!string.IsNullOrWhiteSpace(action.EffectAnimation))
            {
                BattleEvent.Publish(new BattleEffectAnimationRequested
                {
                    PerformerId = _performer.Id,
                    EffectName  = action.EffectAnimation,
                    Group       = action.Group,
                    Scope       = action.Scope,
                    Target      = _targets[index]
                });
            }

            if (_targets.Length <= index)
            {
                Debug.LogError($"Invalid Targets for {_card.Name}. Action {index}");
            }
            action.Apply(_performer, _targets[index]);
        }
    }
예제 #3
0
    /**
     * @todo #361:30min We sdhould be able to chain effects conditionally, as in MarkOfSalvation paladin card.
     */

    public static void Apply(EffectData effectData, Member source, Target target)
    {
        var effect = Create(effectData);

        BattleLog.Write($"Applying Effect of {effectData.EffectType} to {target.Members} members");
        effect.Apply(source, target);
        target.Members.ForEach(m => BattleEvent.Publish(new MemberStateChanged(m)));
    }
예제 #4
0
 protected override void Execute() =>
 state.Members.Values.ToList()
 .Except(_unconscious)
 .Where(m => !m.State.IsConscious)
 .ForEach(m =>
 {
     _unconscious.Add(m);
     BattleEvent.Publish(new MemberUnconscious(m));
 });
예제 #5
0
    public void Apply(Member source, Target target)
    {
        Effect effect = new UnqueueAfterExceuteEffect(_effect);

        BattleEvent.Publish(new AddEffectToQueue(effect));
        BattleEvent.Subscribe <EffectApplied>(
            (msg) => {
            if (msg.Effect.Equals(_effect))
            {
                BattleEvent.Publish(new RemoveEffectFromQueue(msg.Effect));
                BattleEvent.Unsubscribe(this);
            }
        },
            this);
    }
예제 #6
0
    public void Regeneration_ApplyEffect_RegenerateFlatForTurns()
    {
        Member attacker = TestMembers.With(StatType.Attack, 1);
        Member caster   = TestMembers.Any();
        Member target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        //creating damage
        new Attack(5).Apply(attacker, new Single(target));

        Debug.Log("Target has " + target.State[TemporalStatType.HP] + "HP");

        new HealFlatForTurnsOnTurnStart(1, 3).Apply(caster, new Single(target));

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            6,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 1."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            7,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 2."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 3."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect applied on turn 4."
            );
    }
예제 #7
0
    public void OnNextTurnEffect_ApplyEffect_ApplyOnNextTurn()
    {
        OnNextTurnEffect timedDamage = new OnNextTurnEffect(
            AllEffects.Create(DamageTarget(1))
            );

        Member attacker = TestMembers.With(StatType.Attack, 1);
        Member target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect did not applied on next turn."
            );
    }
예제 #8
0
    public void ForNumberOfTurns_ApplyEffect_DoesNotApplyWhenInactive()
    {
        ForNumberOfTurns timedDamage = new ForNumberOfTurns(AllEffects.Create(DamageTarget(1)));

        Member attacker = TestMembers.With(StatType.Attack, 1);
        Member target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));
        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect did applied when inactive."
            );
    }
예제 #9
0
 public void Apply(Member source, Target target)
 {
     Attacker = source;
     Target   = target;
     if (target.Members.Length > 1)
     {
         target.Members.ForEach(
             member => {
             new Attack(Multiplier).Apply(source, target);
         }
             );
     }
     else
     {
         BattleEvent.Publish(
             new AttackToPerform(this)
             );
         Effect.Apply(source, target);
         BattleEvent.Publish(
             new AttackPerformed(this)
             );
     }
 }
예제 #10
0
 public void Apply(Member source, Target target)
 {
     _effect.Apply(source, target);
     BattleEvent.Publish(new EffectApplied(_effect));
 }
예제 #11
0
 public void Apply(Member source, Target target)
 {
     _origin.Apply(source, target);
     BattleEvent.Publish(new FeedCardResolutionStarted(_type.ToString()));
 }
예제 #12
0
 public static void Write(string message) => BattleEvent.Publish(new WriteBattleLogMessageRequested(message));
예제 #13
0
 public void Apply(Member source, Target target)
 {
     BattleEvent.Publish(new ReplayLastCard());
 }