Example #1
0
    private IEnumerator PlayHumanTurnRoutine()
    {
        BattleUnit hero = GetFaction(Alignment.Hero).GetUnits().First();

        yield return(hero.ActionStartRoutine());

        if (hero.IsDead())
        {
            yield break;
        }

        Result <List <Intent> > intentsResult = new Result <List <Intent> >();

        yield return(controller.SelectSpellsRoutine(intentsResult, hero));

        List <Intent> prefixBuffer = new List <Intent>();

        foreach (Intent intent in intentsResult.value)
        {
            if (intent.ModifiesNextIntent())
            {
                prefixBuffer.Add(intent);
            }
            else
            {
                foreach (Intent prefix in prefixBuffer)
                {
                    prefix.ModifyNextIntent(intent);
                }
                prefixBuffer.Clear();
            }
            yield return(CoUtils.Wait(0.8f));

            yield return(intent.ResolveRoutine());
        }

        yield return(hero.ActionEndRoutine());

        hero.MarkActionTaken();
    }
Example #2
0
    // called repeatedly by the battle while ai units still have moves left
    public IEnumerator PlayNextAIActionRoutine()
    {
        BattleUnit actor = battle.GetFaction(Alignment.Enemy).NextMoveableUnit();

        yield return(actor.ActionStartRoutine());

        if (actor.IsDead())
        {
            yield break;
        }

        // TODO: AI

        Spell       spell  = RandomUtils.RandomItem(battle.r, actor.unit.spells);
        IntentSpell intent = new IntentSpell(battle, actor, spell);

        intent.AcquireAITargets();
        yield return(intent.ResolveRoutine());

        yield return(actor.ActionEndRoutine());

        actor.MarkActionTaken();
        yield return(null);
    }