41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class StatusHandler : MonoBehaviour
|
|
{
|
|
private Entity _entityLinked;
|
|
private Dictionary<Enum.StatusType, Status> activeStatuses = new();
|
|
|
|
public void ApplySlow(float intensity, float duration)
|
|
{
|
|
Slow slow = (Slow)GetStatus(Enum.StatusType.Slow);
|
|
slow.Intensity = intensity;
|
|
slow.Apply(duration);
|
|
}
|
|
|
|
// please add status to switch case everytime you design one!
|
|
private Status GetStatus(Enum.StatusType type)
|
|
{
|
|
Status status;
|
|
activeStatuses.TryGetValue(Enum.StatusType.Slow, out status);
|
|
if (!status)
|
|
{
|
|
switch (type)
|
|
{
|
|
case Enum.StatusType.Slow:
|
|
status = gameObject.AddComponent<Slow>();
|
|
break;
|
|
default: break;
|
|
}
|
|
}
|
|
status.EntityLinked = _entityLinked;
|
|
return status;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
_entityLinked = gameObject.GetComponent<Entity>(); ;
|
|
}
|
|
}
|