예제 #1
0
        public static string Id(this IBuff ability)
        {
            var descriptor = ability.GetType()
                             .GetCustomAttributes(typeof(BuffXivDbAttribute), false).Cast <BuffXivDbAttribute>()
                             .SingleOrDefault();

            return(descriptor?.BuffId.ToString());
        }
예제 #2
0
        public void AddBuff(IBuff buff)
        {
            var alreadyHasBuff = ActiveBuffs.Where(b => b.Buff.GetType() == buff.GetType()).Any();

            if (!alreadyHasBuff)
            {
                var activeBuff = BuffFactory.GetActiveBuff(buff, this);
                activeBuff.Trigger <IBuffApplyTrigger>();
                ActiveBuffs.Add(activeBuff);
            }
        }
예제 #3
0
        public void RemoveBuff(IBuff buff)
        {
            var presentBuff = ActiveBuffs
                              .Where(b => b.Buff.GetType() == buff.GetType())
                              .FirstOrDefault();

            if (presentBuff != null)
            {
                presentBuff.Trigger <IBuffRemoveTrigger>();
                ActiveBuffs.Remove(presentBuff);
            }
        }
예제 #4
0
파일: StatSet.cs 프로젝트: iblaauw/Aegis
        public void RemoveBuff(IBuff buff)
        {
            if (buff == null)
            {
                throw new ArgumentNullException();
            }

            Type buffType = buff.GetType();

            if (buffMap[buffType].Equals(buff))
            {
                buffMap.Remove(buffType);
            }
        }
예제 #5
0
파일: StatSet.cs 프로젝트: iblaauw/Aegis
        //TODO: the registration collection should be created inside here!!! Not passed in.
        public void AddBuff(IBuff buff, BuffRegistrationCollection eventSet)
        {
            //Fire the event! We want to fire it even if it gets ignored. It fires everytime someone tries to add one.
            if (BuffAdded != null)
            {
                BuffAdded(buff);
            }

            Type buffType = buff.GetType();

            if (buffMap.ContainsKey(buffType))
            {
                if (!buffMap[buffType].OnOverwrite(buff))
                {
                    return;
                }
            }

            buffMap[buffType] = buff;

            buff.RegisterForEvents(eventSet);
        }
예제 #6
0
 private static List <Type> GetTriggers(IBuff buff)
 {
     return(buff.GetType().GetInterfaces()
            .Where(i => i.GetInterfaces().Contains(typeof(IBuffTrigger)))
            .ToList());
 }
예제 #7
0
 public bool HasBuff(IBuff buff)
 {
     return(ActiveBuffs.Where(b => b.Buff.GetType() == buff.GetType()).Any());
 }
예제 #8
0
 public void ShowBuffTrigger(IBuff buff, BattleCharacter before, BattleCharacter after)
 {
     Console.WriteLine($"{before.Name} feels the effect of {buff.GetType().Name}");
     ShowStatDifferences(before, after);
 }
예제 #9
0
 private IBuff GetBuff(IBuff newBuff)
 {
     return(_buffs.FirstOrDefault(buff => buff.GetType() == newBuff.GetType()));
 }
예제 #10
0
 private bool HasBuff(IBuff newBuff)
 {
     return(_buffs.Any(buff => buff.GetType() == newBuff.GetType()));
 }