Exemplo n.º 1
0
    /// <summary>
    /// 移除某个事件中的某个回调
    /// </summary>
    /// <param name="eventName"></param>
    /// <param name="cb"></param>
    public static void RemoveEventListener(KCEvent type, CallBack cb)
    {
        string eventName = type.ToString();

        if (eventListerners.ContainsKey(eventName))
        {
            eventListerners[eventName] -= cb;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 移除某个事件监听器
    /// </summary>
    /// <param name="evenName">监听器名称</param>
    public static void RemoveEventListener(KCEvent type)
    {
        string eventName = type.ToString();

        if (eventListerners.ContainsKey(eventName))
        {
            eventListerners.Remove(eventName);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 派发事件
    /// </summary>
    /// <param name="eventName">事件监听器名称</param>
    /// <param name="data">数据</param>
    public static void DispatchEvent(KCEvent type, object data = null)
    {
        string eventName = type.ToString();

        if (!eventListerners.ContainsKey(eventName))
        {
            return;
        }
        eventListerners[eventName](data);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 添加事件监听器
    /// </summary>
    /// <param name="eventName">监听器名称</param>
    /// <param name="cb">回调方法</param>
    public static void AddEventListener(KCEvent type, CallBack cb)
    {
        string eventName = type.ToString();

        if (!eventListerners.ContainsKey(eventName))
        {
            eventListerners[eventName] = null; //表示首次监听,
        }
        eventListerners[eventName] += cb;
    }