ChargeGameEvent.cs 694 Bytes
Newer Older
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
using System.Collections.Generic;
using UnityEngine;

namespace _Game.Scripts.Scriptable_Object
{
	[CreateAssetMenu(fileName = "New Charge Game Event", menuName = "Charge Game Event", order = 53)]
	public class ChargeGameEvent : ScriptableObject
	{
		private readonly List<ChargeGameEventListener> _listeners = new List<ChargeGameEventListener>();

		public void Raise()
		{
			for (var i = _listeners.Count - 1; i >= 0; i--)
			{
				_listeners[i].OnEventRaised();
			}
		}

		public void RegisterListener(ChargeGameEventListener listener)
		{
			_listeners.Add(listener);
		}

		public void UnregisterListener(ChargeGameEventListener listener)
		{
			_listeners.Remove(listener);
		}
	}
}