Skip to content

Commit 8fbe3e2

Browse files
committed
修改错别字;
修复低帧时的计时Bug; 开放OnBuffUpdate的虚函数;
1 parent b7fd5f3 commit 8fbe3e2

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

Assets/NoSLoofah_BuffSystem/BuffSystem/Base/BuffBase/Buff.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,30 @@ public void OnBuffUpdate()
135135
return;
136136
}
137137
if (!IsEffective) return;
138-
if (!isPermanent) timer -= Time.deltaTime;
139-
if (!isPermanent && timer <= 0)
138+
if (!isPermanent)
140139
{
141-
if (removeOneLayerOnTimeUp)
140+
timer -= Time.deltaTime;
141+
while (timer <= 0 && isEffective)
142142
{
143-
timer = duration;
144-
ModifyLayer(-1);
143+
if (removeOneLayerOnTimeUp)
144+
{
145+
timer += duration;
146+
ModifyLayer(-1);
147+
}
148+
else
149+
{
150+
isEffective = false;
151+
timer = 0;
152+
}
153+
145154
}
146-
else isEffective = false;
147155
}
148156
RealModifyLayer();
149157
if (!runTickTimer) return;
150158
tickTimer -= Time.deltaTime;
151-
if (tickTimer <= 0)
159+
while (tickTimer <= 0)
152160
{
153-
tickTimer = tickInterval;
161+
tickTimer += tickInterval;
154162
OnBuffTickEffect();
155163
}
156164
}
@@ -164,7 +172,7 @@ public void Initialize(IBuffHandler target, GameObject caster)
164172
private void RealModifyLayer()
165173
{
166174
Layer += tmpLayer;
167-
if (layerModified) OnBuffModifyLayer(tmpLayer);
175+
if (layerModified) OnBuffModifyLayer(Layer < 0 ? -Layer : tmpLayer);
168176
if (Layer <= 0) isEffective = false;
169177
tmpLayer = 0;
170178
layerModified = false;

Assets/NoSLoofah_BuffSystem/BuffSystem/Base/BuffHandler/BuffHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void RemoveBuff(int buffId, bool removeAll = true)
137137
else RemoveBuff(b);
138138
}
139139

140-
public void InteruptBuff(int buffId, bool removeAll = true)
140+
public void InterruptBuff(int buffId, bool removeAll = true)
141141
{
142142
var b = buffs.FirstOrDefault(b => b.ID == buffId);
143143
if (b == null)

Assets/NoSLoofah_BuffSystem/BuffSystem/Base/BuffHandler/IBuffHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface IBuffHandler
2525
/// </summary>
2626
/// <param name="buffId">要移除的Buff id</param>
2727
/// <param name="removeAll">如果对象同时存在多个同id的buff,是否将所有一并移除</param>
28-
public void InteruptBuff(int buffId, bool interuptAll = true);
28+
public void InterruptBuff(int buffId, bool interuptAll = true);
2929
/// <summary>
3030
/// 注册事件:添加Buff时
3131
/// </summary>

Assets/NoSLoofah_BuffSystem/Example/Scripts/CustomBuff/Buff_Bleed.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public override void OnBuffModifyLayer(int change)
1818

1919
public override void OnBuffRemove()
2020
{
21-
21+
2222
}
2323

2424
public override void OnBuffStart()
@@ -33,7 +33,7 @@ public override void Reset()
3333
}
3434

3535
protected override void OnBuffTickEffect()
36-
{
36+
{
3737
targetEntity.ModifyHealth(-Layer * bleedDamage);
3838
}
3939

Assets/NoSLoofah_BuffSystem/Example/Scripts/Entity/Entity1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private void Awake()
2222
}
2323
public void ModifyHealth(int changeValue)
2424
{
25-
health += changeValue;
25+
health += (int)(changeValue * (changeValue < 0 ? damageMultiplier : 1));
2626
health = Math.Clamp(health, 0, maxHealth);
2727
}
2828
public void ModifyDamageMultiplier(float changeValue)

Assets/NoSLoofah_BuffSystem/Example/Scripts/UI/BuffButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public void InteruptBuff()
2525
{
2626
int i;
2727
if (!int.TryParse(inputField.text, out i)) return;
28-
buffHandler.InteruptBuff(i);
28+
buffHandler.InterruptBuff(i);
2929
}
3030
}

0 commit comments

Comments
 (0)