public override List <BattleUnit> AcquireAITargets(IntentSpell intent) { List <BattleUnit> units = new List <BattleUnit> { intent.actor }; return(units); }
protected List <BattleUnit> GetEnemies(IntentSpell intent) { List <BattleUnit> result = new List <BattleUnit>(); foreach (BattleFaction faction in intent.battle.GetFactions()) { if (!faction.GetUnits().Contains(intent.actor)) { result.AddRange(faction.GetUnits()); } } return(result); }
// 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); }
public override List <BattleUnit> AcquireAITargets(IntentSpell intent) { switch (targets) { case TargetType.All: return(intent.battle.AllUnits().ToList()); case TargetType.AllAllies: return(GetAllies(intent)); case TargetType.AllEnemies: return(GetEnemies(intent)); case TargetType.AllNotSelf: return(Without(intent.battle.AllUnits().ToList(), intent.actor)); case TargetType.Ally: return(RandomLiving(intent, GetAllies(intent))); case TargetType.AllyNotSelf: return(RandomLiving(intent, Without(GetAllies(intent), intent.actor))); case TargetType.Anyone: case TargetType.Enemy: case TargetType.AnyoneNotSelf: return(RandomLiving(intent, GetEnemies(intent))); case TargetType.Self: return(new List <BattleUnit> { intent.actor }); default: return(null); } }
public override void ModifyIntent(IntentSpell next) { next.AddPrefix(this); }
public override void ConsumePrefixSpell(IntentSpell intent) { intent.spell.ModifyIntent(this); }
public abstract void ConsumePrefixSpell(IntentSpell intent);
public IEnumerator ResolveRoutine(IntentSpell intent, List <Prefix> prefixes) { this.intent = intent; this.prefixes = prefixes; yield return(InternalResolveRoutine()); }
public IEnumerator SelectSpellsRoutine(Result <List <Intent> > result, BattleUnit hero) { List <Intent> queuedIntents = new List <Intent>(); List <Spell> previousSpells = new List <Spell>(); linker.SetUp((int)hero.Get(StatTag.MAP)); yield return(spellSelect.EnableRoutine(hero.unit.spells)); while (hero.Get(StatTag.AP) > 0) { linker.Populate(previousSpells); Result <Selectable> cardResult = new Result <Selectable>(); yield return(spellSelect.SelectSpellRoutine(cardResult, previousSpells)); if (cardResult.canceled) { // canceled the selection if (queuedIntents.Count > 0) { Global.Instance().Audio.PlaySFX("cancel"); Intent canceled = queuedIntents.Last(); hero.unit.stats.Add(StatTag.AP, canceled.APCost()); queuedIntents.RemoveAt(queuedIntents.Count - 1); previousSpells.RemoveAt(previousSpells.Count - 1); } } else if (cardResult.value.GetComponent <SpellCard>()) { // selected a spell Spell spell = cardResult.value.GetComponent <SpellCard>().spell; linker.Populate(new List <Spell>(previousSpells) { spell }); if (hero.Get(StatTag.AP) > spell.apCost || (hero.Get(StatTag.AP) >= spell.apCost && !spell.LinksToNextSpell())) { Global.Instance().Audio.PlaySFX("confirm"); hero.unit.stats.Sub(StatTag.AP, spell.apCost); // find a target for the spell Result <List <BattleUnit> > targetsResult = new Result <List <BattleUnit> >(); IntentSpell intent = new IntentSpell(this.battle, hero, spell); yield return(intent.AcquireTargetsRoutine(targetsResult)); if (!targetsResult.canceled) { queuedIntents.Add(intent); previousSpells.Add(spell); } else { hero.unit.stats.Add(StatTag.AP, spell.apCost); } } else { Global.Instance().Audio.PlaySFX("error"); } } else { // selected the go ahead if (queuedIntents.Count > 0) { Global.Instance().Audio.PlaySFX("confirm"); break; } else { Global.Instance().Audio.PlaySFX("error"); } } } yield return(spellSelect.DisableRoutine()); result.value = queuedIntents; }
public override void ModifyIntent(IntentSpell next) { Debug.Assert(false); }
protected List <BattleUnit> GetAllies(IntentSpell intent) { return(intent.battle.UnitsByAlignment(intent.actor.align).ToList()); }
public abstract void ModifyIntent(IntentSpell next);
public abstract List <BattleUnit> AcquireAITargets(IntentSpell intent);