// 替某一主题注册一个观測者 public void RegisterObserver(ENUM_GameEvent emGameEvnet, IGameEventObserver Observer) { // 取得事件 IGameEventSubject Subject = GetGameEventSubject(emGameEvnet); if (Subject != null) { Subject.Attach(Observer); Observer.SetSubject(Subject); } }
/// <summary> /// 给某一个主题注册观察者 /// </summary> /// <param name="emGameEvnet"></param> /// <param name="Observer"></param> public void RegisterObserver(ENUM_GameEvent emGameEvnet, IGameEventObserver Observer) { IGameEventSubject Subject = GetGameEventSubject(emGameEvnet); //当事件主题不为空,注册进去 if (Subject != null) { Subject.Attach(Observer); Observer.SetSubject(Subject); } }