This class is responsible for holding all of the abilities our character may use in battle.
示例#1
0
        public void UseBuffingActions(IEnumerable <BattleAbility> actions)
        {
            if (actions == null)
            {
                throw new ArgumentNullException(nameof(actions));
            }

            var castables = actions.ToList();

            while (castables.Count > 0)
            {
                foreach (var action in castables.ToList())
                {
                    if (!ActionFilters.BuffingFilter(_fface, action))
                    {
                        castables.Remove(action);
                        continue;
                    }

                    if (!CastSpell(action))
                    {
                        continue;
                    }

                    castables.Remove(action);
                    action.Usages++;
                    action.LastCast = DateTime.Now.AddSeconds(action.Recast);

                    TimeWaiter.Pause(Config.Instance.GlobalCooldown);
                }
            }
        }
示例#2
0
        public void UseActions(IEnumerable <BattleAbility> actions, Position position)
        {
            if (actions == null)
            {
                throw new ArgumentNullException(nameof(actions));
            }

            foreach (var action in actions.ToList())
            {
                if (!ActionFilters.BuffingFilter(_fface, action))
                {
                    continue;
                }

                if (!CastSpell(action, position))
                {
                    continue;
                }

                action.Usages++;
                action.LastCast = DateTime.Now.AddSeconds(action.Recast);

                TimeWaiter.Pause(Config.Instance.GlobalCooldown);
            }
        }
示例#3
0
        /// <summary>
        /// Executes moves without the need for a target.
        /// </summary>
        /// <param name="actions"></param>
        public void UseBuffingActions(IEnumerable <BattleAbility> actions)
        {
            if (actions == null)
            {
                throw new ArgumentNullException("actions");
            }

            var castables = actions.ToList();

            while (castables.Count > 0)
            {
                foreach (var action in castables.ToList())
                {
                    if (!ActionFilters.BuffingFilter(_fface, action))
                    {
                        castables.Remove(action);
                        continue;
                    }

                    // Try to cast the spell. On failure, continue and recast at a later time.
                    if (!_caster.CastSpell(action))
                    {
                        continue;
                    }

                    // Remove spell from castables so that it will not be casted again.
                    castables.Remove(action);

                    // Increase usage count to limit number of usages.
                    action.Usages++;

                    // Set the recast to prevent casting before the recast period.
                    action.LastCast = DateTime.Now.AddSeconds(action.Recast);

                    // Sleep until a spell is recastable.
                    Thread.Sleep(Config.Instance.GlobalCooldown);
                }
            }
        }