Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventManager : Singleton<EventManager>
{
[System.Serializable]
public class ObjectCreate
{
public GameObject prefab;
public Transform target;
public Vector3 scale;
public Vector3 pos;
public GameObject create;
public ObjectCreate()
{ }
public ObjectCreate(GameObject prefab, Transform target, Vector3 scale, Vector3 pos)
{
this.prefab = prefab;
this.target = target;
this.scale = scale;
this.pos = pos;
}
}
Dictionary<string, System.Action<object>> dicEvent = new Dictionary<string, System.Action<object>>();
public void Add(string key, System.Action<object> OnRecieve)
{
if(dicEvent.ContainsKey(key))
dicEvent[key] += OnRecieve;
else
dicEvent.Add(key, OnRecieve);
//Debug.Log($"EventManager - {key} : {dicEvent[key].GetInvocationList().GetLength(0)} <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>");
}
public void Remove(string key, System.Action<object> OnRecieve)
{
if (dicEvent.ContainsKey(key))
{
dicEvent[key] -= OnRecieve;
if (dicEvent[key] == null)
{
Debug.Log($"EventManager - {key} <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ϵ<EFBFBD> <EFBFBD>̺<EFBFBD>Ʈ <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
dicEvent.Remove(key);
}
}
}
public void Invoke(string key, object value)
{
if (dicEvent.ContainsKey(key))
dicEvent[key](value);
else
Debug.LogWarning($"EventManager - {key} <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ϵ<EFBFBD> <EFBFBD>̺<EFBFBD>Ʈ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}