Added project
This commit is contained in:
34
Platformer/Assets/Scripts/BuffReceiver.cs
Normal file
34
Platformer/Assets/Scripts/BuffReceiver.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuffReceiver : MonoBehaviour {
|
||||
|
||||
private List<Buff> buffs;
|
||||
public Action OnBuffChanged;
|
||||
|
||||
private void Start() {
|
||||
GameManager.Instance.buffReceiverContainer.Add(gameObject, this);
|
||||
buffs = new List<Buff>();
|
||||
}
|
||||
|
||||
public List<Buff> Buffs => buffs;
|
||||
|
||||
public void AddBuff(Buff buff) {
|
||||
if (!buffs.Contains(buff)) {
|
||||
buffs.Add(buff);
|
||||
}
|
||||
if (OnBuffChanged != null) {
|
||||
OnBuffChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveBuff(Buff buff) {
|
||||
if (buffs.Contains(buff)) {
|
||||
buffs.Remove(buff);
|
||||
}
|
||||
if (OnBuffChanged != null) {
|
||||
OnBuffChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user