/// <summary> /// Creates a subGrid containing all possible targets /// of spellable /// </summary> /// <param name="current">Page that owner is on</param> /// <param name="previous">supergrid containing a list of possible ISpellables to use</param> /// <param name="caster">User of the Spellable</param> /// <param name="spellable">Spellable to use on target</param> /// <param name="spellHandler">Spell handler</param> /// <returns></returns> public static Grid GenerateTargets(Page current, IButtonable previous, Character caster, ISpellable spellable, Sprite sprite, Action <Spell> spellHandler) { SpellBook sb = spellable.GetSpellBook(); ICollection <Character> targets = sb.TargetType.GetTargets(caster, current); Grid grid = GenerateBackableGrid(previous, sb.Icon, sb.Name, sb.CreateDescription(caster)); grid.Icon = sprite; ICollection <Process> targetProcesses = spellable.GetSpellBook().TargetType.GetTargetProcesses(current, spellable, caster, spellHandler); foreach (Process targetProcess in targetProcesses) { grid.List.Add(targetProcess); } Item item = spellable as Item; if (item != null && item.HasFlag(Items.Flag.OCCUPIES_SPACE)) { grid.List.Add( new Process( string.Format("Drop"), string.Format("Throw away {0}.", item.Name), () => { spellHandler( caster.Spells.CreateSpell(current, new TossItem(item, caster.Inventory), caster, caster) ); } )); } return(grid); }
private static Process GenerateSpellProcess(Page current, IButtonable previous, Character owner, ISpellable spellable, Action <IPlayable> handlePlayable, bool isTargetingSelf) { SpellBook sb = spellable.GetSpellBook(); return(new Process(sb.GetDetailedName(owner), sb.Icon, sb.CreateDescription(owner), () => { if (sb.IsMeetPreTargetRequirements(owner.Stats)) { GenerateTargets(current, previous, owner, spellable, handlePlayable, isTargetingSelf).Invoke(); } })); }
/// <summary> /// Creates a subGrid containing all possible targets /// of spellable /// </summary> /// <param name="current">Page that owner is on</param> /// <param name="previous">supergrid containing a list of possible ISpellables to use</param> /// <param name="owner">User of the Spellable</param> /// <param name="spellable">Spellable to use on target</param> /// <param name="handlePlayable">Playable handler</param> /// <param name="isTargetingSelf">If true, the target will attempt to cast the spell on themselves (used for out of combat inventories)</param> /// <returns></returns> public static Grid GenerateTargets(Page current, IButtonable previous, Character owner, ISpellable spellable, Sprite sprite, Action <IPlayable> handlePlayable, bool isTargetingSelf) { SpellBook sb = spellable.GetSpellBook(); ICollection <Character> targets = sb.TargetType.GetTargets(owner, current); Grid grid = GenerateBackableGrid(previous, sb.Icon, sb.Name, sb.CreateDescription(owner)); grid.Icon = sprite; foreach (Character myTarget in targets) { Character target = myTarget; Character spellOwner = null; if (isTargetingSelf) { spellOwner = target; } else { spellOwner = owner; } grid.List.Add(GenerateTargetProcess(current, previous, spellOwner, target, sb, handlePlayable)); } Item item = spellable as Item; if (item != null && item.HasFlag(Items.Flag.OCCUPIES_SPACE)) { grid.List.Add( new Process( string.Format("Drop"), string.Format("Throw away {0}.", item.Name), () => { handlePlayable( owner.Spells.CreateSpell(current, new TossItem(item, owner.Inventory), owner, owner) ); } )); } return(grid); }