Exemplo n.º 1
0
    public void AddBuff(Buff buff)
    {
        foreach (var entity in buffList)
        {
            if (entity.Value.name == buff.name)
            {
                Debuff(entity.Value);
                break;
            }
        }
        ClearExpired();

        float expireTime = TimeTool.time + buff.duration;
        if (buffList.ContainsKey(expireTime))
        {
            Debug.LogError("You need dupication evasion rule!!");
        }

        if (owner != null)
        {
            if (buff.spawnEffect > 0)
            {
                owner.AttachEffect(buff.spawnEffect);
            }
            if (buff.spawnSound > 0)
            {
                owner.PlaySound(buff.spawnSound);
            }
        }
        if (buff.OnBuff != null)
        {
            buff.OnBuff(buff);
        }
        buffList.Add(expireTime, buff);
        RefreshStatModifierCache();
        stat.AddBuff(buff);
    }