-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTimedSpeedBuff.cs
35 lines (29 loc) · 973 Bytes
/
TimedSpeedBuff.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Components;
using ScriptableObjects;
using UnityEngine;
public class TimedSpeedBuff : TimedBuff
{
private readonly MovementComponent _movementComponent;
public TimedSpeedBuff(ScriptableBuff buff, GameObject obj) : base(buff, obj)
{
//Getting MovementComponent, replace with your own implementation
_movementComponent = obj.GetComponent<MovementComponent>();
}
protected override void ApplyEffect()
{
//Add speed increase to MovementComponent
ScriptableSpeedBuff speedBuff = (ScriptableSpeedBuff) Buff;
_movementComponent.MovementSpeed += speedBuff.SpeedIncrease;
}
public override void End()
{
//Revert speed increase
ScriptableSpeedBuff speedBuff = (ScriptableSpeedBuff) Buff;
_movementComponent.MovementSpeed -= speedBuff.SpeedIncrease * EffectStacks;
EffectStacks = 0;
}
protected override void ApplyTick()
{
//Do nothing
}
}