コード例 #1
0
ファイル: BuffModule.cs プロジェクト: knightlyj/NG
    //同id的buff不能叠加,只能覆盖
    public bool AddBuff(Creature target, BuffId id)
    {
        BaseBuff newBuff = null;

        switch (id)
        {
        case BuffId.Invincible:
            newBuff = new InvincibleBuff();
            break;
        }
        if (newBuff != null)
        {
            if (buffDict.ContainsKey(id))
            {   //移除原来的buff
                if (buffDict[id] != null)
                {
                    buffDict[id].Stop();
                }
                buffDict[id] = newBuff;
            }
            else
            {
                buffDict.Add(id, newBuff);
            }

            newBuff.Start(target);
        }


        return(true);
    }
コード例 #2
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
 /// <summary>
 /// Returns buff with given id, or null if it didn't
 /// exist.
 /// </summary>
 /// <param name="buffId"></param>
 /// <returns></returns>
 public Buff Get(BuffId buffId)
 {
     lock (_buffs)
     {
         _buffs.TryGetValue(buffId, out var result);
         return(result);
     }
 }
コード例 #3
0
    public void RemoveBuff(IBuff.BuffType type, int insId)
    {
        BuffId id = new BuffId();

        id.mType   = type;
        id.mTypeId = insId;
        mDeathBuffList.Add(id);
    }
コード例 #4
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
        /// <summary>
        /// Removes buff with given id, returns false if it
        /// didn't exist. Updates the client on success.
        /// </summary>
        /// <param name="buffId"></param>
        /// <returns></returns>
        public bool Remove(BuffId buffId)
        {
            if (!this.TryGet(buffId, out var buff))
            {
                return(false);
            }

            return(this.Remove(buff));
        }
コード例 #5
0
        /// <summary>
        /// Returns the buff handler for the given buff. Returns null if
        /// no handler was found.
        /// </summary>
        /// <param name="buffId"></param>
        /// <returns></returns>
        public IBuffHandler GetHandler(BuffId buffId)
        {
            if (_buffHandlers.TryGetValue(buffId, out var handler))
            {
                return(handler);
            }

            return(null);
        }
コード例 #6
0
ファイル: Buff.cs プロジェクト: ivanbiljan/orionshock
        /// <summary>
        /// Initializes a new instance of the <see cref="Buff"/> structure with the specified buff <paramref name="id"/>
        /// and <paramref name="ticks"/>.
        /// </summary>
        /// <param name="id">The buff ID.</param>
        /// <param name="ticks">The buff duration, in ticks.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="ticks"/> is negative.</exception>
        public Buff(BuffId id, int ticks)
        {
            if (ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(ticks), "Ticks is negative");
            }

            Id    = id;
            Ticks = ticks;
        }
コード例 #7
0
ファイル: Buff.cs プロジェクト: ivanbiljan/orionshock
        /// <summary>
        /// Initializes a new instance of the <see cref="Buff"/> structure with the specified buff <paramref name="id"/>
        /// and <paramref name="duration"/>.
        /// </summary>
        /// <param name="id">The buff ID.</param>
        /// <param name="duration">The buff duration.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="duration"/> is negative.</exception>
        public Buff(BuffId id, TimeSpan duration)
        {
            if (duration < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(duration), "Duration is negative");
            }

            Id    = id;
            Ticks = (int)(duration.TotalSeconds * 60.0);
        }
コード例 #8
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
        /// <summary>
        /// Starts the buff with the given id. If the buff is already active,
        /// it gets overbuffed. Returns the created or modified buff.
        /// </summary>
        /// <param name="buffId"></param>
        /// <param name="caster">The entity that casted the buff.</param>
        /// <param name="duration">Custom duration of the buff.</param>
        /// <returns></returns>
        public Buff Start(BuffId buffId, ICombatEntity caster, TimeSpan duration)
        {
            if (!this.TryGet(buffId, out var buff))
            {
                buff = new Buff(caster, this.Entity, buffId, duration);
                this.Add(buff);
            }
            else
            {
                this.Overbuff(buff);
            }

            return(buff);
        }
コード例 #9
0
        static ABuff GetBuff(TargetBuffs target, BuffId buffId)
        {
            if (!BuffsMap.ContainsKey(target))
            {
                BuffsMap.Add(target, new List <ABuff>());
            }

            var buff = BuffsMap[target].Find(b => b.Id == buffId);

            if (buff == null)
            {
                buff = Buffs[buffId].Clone();
                BuffsMap[target].Add(buff);
            }
            return(buff);
        }
コード例 #10
0
ファイル: BuffModule.cs プロジェクト: knightlyj/NG
 public bool RemoveBuff(BuffId id)
 {
     if (buffDict.ContainsKey(id))
     {
         if (buffDict[id] != null)
         {
             buffDict[id].Stop();
         }
         buffDict.Remove(id);
     }
     else
     {   //not exist
         return(false);
     }
     return(true);
 }
コード例 #11
0
ファイル: SkillConfig.cs プロジェクト: 164638896/ARPG
 static public void ParseBuffString(ref List <BuffId> outList, string info, IBuff.BuffType type)
 {
     string[] sArray = info.Split(';');
     for (int i = 0; i < sArray.Length; ++i)
     {
         if (sArray[i] != string.Empty)
         {
             string[] sArrayTrigger = sArray[i].Split(',');
             BuffId   buff          = new BuffId();
             buff.mType       = type;
             buff.mBuffAttach = (IBuff.BuffAttach) int.Parse(sArrayTrigger[0]);
             buff.mTrigger    = (IBuff.BuffStage) int.Parse(sArrayTrigger[1]);
             buff.mTypeId     = int.Parse(sArrayTrigger[2]);
             outList.Add(buff);
         }
     }
 }
コード例 #12
0
 public override string ToString()
 {
     return(string.Format($"{BuffId.ToString()}: Exp tick: {ExpirationTick} Attr: {OnApplyStatusEffect.ToString()} Value: {OnApplyStatusEffectValue}| {OnTickStatusEffect.ToString()}:{ OnTickStatusEffectValue}"));
 }
コード例 #13
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
 /// <summary>
 /// Returns true if the buff exists.
 /// </summary>
 /// <param name="buffId"></param>
 /// <returns></returns>
 public bool Has(BuffId buffId)
 {
     lock (_buffs)
         return(_buffs.ContainsKey(buffId));
 }
コード例 #14
0
 public static void PlayBuff(TargetBuffs target, BuffId buffId)
 => GetBuff(target, buffId).Play(target);
コード例 #15
0
 public bool CheckByIid(BuffId bid)
 {
     return(bid._iid == _iid);
 }
コード例 #16
0
 public static void SetBuff(TargetBuffs target, BuffId buffId, bool isOn)
 => GetBuff(target, buffId).Set(target, isOn);
コード例 #17
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
 /// <summary>
 /// Returns buff with given id via out, returns false if the
 /// buff wasn't found.
 /// </summary>
 /// <param name="buffId"></param>
 /// <param name="buff"></param>
 /// <returns></returns>
 public bool TryGet(BuffId buffId, out Buff buff)
 {
     buff = this.Get(buffId);
     return(buff != null);
 }
コード例 #18
0
ファイル: BuffId.cs プロジェクト: ivanbiljan/orionshock
 /// <summary>
 /// Returns a value indicating whether the buff ID is a debuff.
 /// </summary>
 /// <param name="id">The buff ID.</param>
 /// <returns><see langword="true"/> if the buff ID is a debuff; otherwise, <see langword="false"/>.</returns>
 public static bool IsDebuff(this BuffId id) => _debuffs.Contains(id);
コード例 #19
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
 /// <summary>
 /// Starts the buff with the given id. If the buff is already active,
 /// it gets overbuffed. Returns the created or modified buff.
 /// </summary>
 /// <param name="buffId"></param>
 /// <param name="duration">Custom duration of the buff.</param>
 /// <returns></returns>
 public Buff Start(BuffId buffId, TimeSpan duration)
 => this.Start(buffId, this.Entity, duration);
コード例 #20
0
ファイル: BuffCollection.cs プロジェクト: macmillaninc/melia
 /// <summary>
 /// Starts the buff with the given id, returns the created buff.
 /// If the buff was already active, it gets overbuffed.
 /// </summary>
 /// <remarks>
 /// Uses the duration from the buff's data by default.
 /// </remarks>
 /// <param name="buffId"></param>
 /// <returns></returns>
 public Buff Start(BuffId buffId)
 => this.Start(buffId, TimeSpan.MinValue);