Esempio n. 1
0
        private static Grid GenerateSpellableGrid(
            bool isTargetingSelf,
            Page current,
            IButtonable previous,
            Character owner,
            SpellBook excluded,
            IEnumerable <ISpellable> spellCollection,
            Action <IPlayable> addPlay,
            Sprite sprite,
            string name,
            string description)
        {
            Grid grid = GenerateBackableGrid(previous, sprite, name, description);

            foreach (ISpellable myS in spellCollection)
            {
                ISpellable s = myS;
                if (!s.Equals(excluded))
                {
                    grid.List.Add(GenerateSpellProcess(current, grid, owner, s, addPlay, isTargetingSelf));
                }
            }

            return(grid);
        }
Esempio n. 2
0
        private Process GetMultiTargetProcess(Page current, ISpellable spellable, Character caster, Action <Spell> spellHandler)
        {
            SpellBook spellbook = spellable.GetSpellBook();

            return(new Process(
                       spellbook.TargetType.Name,
                       Util.GetSprite(MULTI_TARGET_ICON),
                       () => spellHandler(caster.Spells.CreateSpell(current, spellbook, caster)),
                       () => spellbook.IsCastable(caster, spellbook.TargetType.GetTargets(caster, current))
                       ));
        }
Esempio n. 3
0
        public Process[] GetTargetProcesses(Page current, ISpellable spellable, Character caster, Action <Spell> spellHandler)
        {
            List <Process> processes = new List <Process>();
            SpellBook      spellbook = spellable.GetSpellBook();

            if (this.TargetCount == TargetCount.SINGLE_TARGET)
            {
                foreach (Character target in GetTargets(caster, current))
                {
                    processes.Add(GetTargetProcess(current, spellbook, caster, target, spellHandler));
                }
            }
            else if (this.TargetCount == TargetCount.MULTIPLE_TARGETS)
            {
                processes.Add(GetMultiTargetProcess(current, spellable, caster, spellHandler));
            }
            return(processes.ToArray());
        }
Esempio n. 4
0
        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();
                }
            }));
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
 /// <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>
 /// <returns></returns>
 public static Grid GenerateTargets(Page current, IButtonable previous, Character owner, ISpellable spellable, Action <IPlayable> handlePlayable, bool isTargetingSelf)
 {
     return(GenerateTargets(current, previous, owner, spellable, spellable.GetSpellBook().Icon, handlePlayable, isTargetingSelf));
 }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
0
 /// <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="spellHandler">Spell handler</param>
 /// <returns></returns>
 public static Grid GenerateTargets(Page current, IButtonable previous, Character owner, ISpellable spellable, Action <Spell> spellHandler)
 {
     return(GenerateTargets(current, previous, owner, spellable, spellable.GetSpellBook().Icon, spellHandler));
 }