private void ChooseEnemyCards()
    {
        var strategy = _enemyStrategy.Generate(state);

        state.Enemies
        .Where(e => e.IsConscious())
        .OrderBy(e => state.GetEnemyById(e.Id).PreferredTurnOrder)
        .ForEach(e => Enumerable.Range(0, e.State.ExtraCardPlays())
                 .ForEach(c => resolutionZone.Add(state.GetEnemyById(e.Id).AI.Play(e.Id, state, strategy))));
    }
Example #2
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);
    }
Example #3
0
    protected override void Execute(MemberUnconscious m)
    {
        if (!m.Member.TeamType.Equals(TeamType.Enemies))
        {
            return;
        }

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

        if (!string.IsNullOrWhiteSpace(enemy.DeathEffect))
        {
            Message.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.DOPunchScale(new Vector3(8, 8, 8), 2, 1);
        t.DOSpiral(2);
        StartCoroutine(ExecuteAfterDelay(() => t.gameObject.SetActive(false), 2));
    }
Example #4
0
 private void ResolveUnconsciousMember(Member member, BattleState state)
 {
     if (member.TeamType == TeamType.Enemies)
     {
         state.AddRewardCredits(state.GetEnemyById(member.Id).RewardCredits);
     }
     else
     {
         BattleLog.Write($"{member.Name} - {member.Id} is unconscious");
     }
     Message.Publish(new MemberUnconscious(member));
 }
Example #5
0
    public static CardTypeData[] GetPlayableCards(this BattleState s, int memberId)
    {
        var enemy = s.GetEnemyById(memberId);
        var me    = s.Members[memberId];

        if (!me.IsConscious())
        {
            throw new InvalidOperationException($"{me} is unconscious, but has been asked to play a card");
        }

        var playableCards = enemy.Deck.Cards.Where(c => c.IsPlayableBy(me)).Cast <CardTypeData>().ToArray();

        if (!playableCards.Any())
        {
            throw new InvalidDataException($"{me} has no playable cards in hand");
        }
        return(playableCards);
    }
Example #6
0
    public override PlayedCard Play(int memberId)
    {
        var enemy   = battleState.GetEnemyById(memberId);
        var me      = battleState.Members[memberId];
        var card    = enemy.Deck.Cards.Random();
        var targets = new List <Target>();

        card.Actions.ForEach(
            action =>
        {
            var possibleTargets = battleState.GetPossibleTargets(me, action.Group, action.Scope);
            var target          = possibleTargets.Random();
            targets.Add(target);
        }
            );

        return(new PlayedCard(me, targets.ToArray(), card));
    }
Example #7
0
 public void ChooseCards()
 {
     battle.Members.Where(x => x.Value.TeamType == TeamType.Enemies)
     .ForEach(e => resolutionZone.Add(battle.GetEnemyById(e.Key).AI.Play(e.Key)));
     onEnemyTurnsConfirmed.Publish();
 }