本文参考自 http://www.cnblogs.com/neverdie/p/3790879.html
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
// NotificationCenter的拓展类,在这里弄出多个INotificationCenter的子类,
// 分别处理不同的消息转发,便于消息分组
public class NotificationCenter : INotificationCenter
{
private static INotificationCenter singleton;
private event EventHandler GameOver;
private event EventHandler ScoreAdd;
private NotificationCenter()
: base()
{
// 在这里添加需要分发的各种消息
eventTable["GameOver"] = GameOver;
eventTable["ScoreAdd"] = ScoreAdd;
}
public static INotificationCenter GetInstance()
{
if (singleton == null)
singleton = new NotificationCenter();
return singleton;
}
}
// NotificationCenter的抽象基类
public abstract class INotificationCenter
{
protected Dictionary<string, EventHandler> eventTable;
protected INotificationCenter()
{

最低0.47元/天 解锁文章
1494

被折叠的 条评论
为什么被折叠?



