NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Buff/Data/GroupBuffCache.cs

43 lines
1.2 KiB
C#

using System.Collections.Generic;
using cfg.BuffCfg;
namespace Gameplay.Buff
{
public class GroupBuffCache
{
public int groupId;
public List<DataBuff> buffList = new List<DataBuff>();
public void AddBuff(DataBuff buff)
{
for (int i = 0; i < buffList.Count; i++)
{
var searchBuff = buffList[i];
if (searchBuff.Level == buff.Level)
{
DebugUtil.LogError($"重复的buff配置,groupId:{groupId},level:{buff.Level}");
return;
}
}
buffList.Add(buff);
}
public DataBuff SearchBuff(int level)
{
// 找到小于等于level的最大的buff
DataBuff result = null;
for (int i = 0; i < buffList.Count; i++)
{
var buff = buffList[i];
if (buff.Level <= level)
{
if (result == null || result.Level < buff.Level)
{
result = buff;
}
}
}
return result;
}
}
}