// 設定觀察的主題 public override void SetSubject( IGameEventSubject theSubject ) { if( theSubject is SoldierKilledSubject ) m_SoldierKilledSubject = theSubject as SoldierKilledSubject; if( theSubject is EnemyKilledSubject) m_EnemyKilledSubject = theSubject as EnemyKilledSubject; }
private AbsGameEventSubject GetGameEvents(GameEventType _type) { AbsGameEventSubject subject = null; if (!gameEvents.TryGetValue(_type, out subject)) { switch (_type) { case GameEventType.Null: break; case GameEventType.EnemyKilled: subject = new EnemyKilledSubject(); gameEvents.Add(GameEventType.EnemyKilled, subject); break; case GameEventType.SoldierKilled: subject = new SoldierKilledSubject(); gameEvents.Add(GameEventType.SoldierKilled, subject); break; case GameEventType.NewStage: subject = new NewStageSubject(); gameEvents.Add(GameEventType.NewStage, subject); break; } } if (subject == null) { Debug.Log("gameEvents not have key:" + gameEvents); } return(subject); }
private ISubject GetGameEvent(Enum_GameEvent gameEvent) { if (gameevents.ContainsKey(gameEvent)) { return(gameevents[gameEvent]); } ISubject subject = null; switch (gameEvent) { case Enum_GameEvent.EnemyKilled: subject = new EnemyKilledSubject(); break; case Enum_GameEvent.WeaponCollectioned: subject = new WeaponCollectionedSubject(); break; case Enum_GameEvent.TrapTriggered: subject = new TrapTriggeredSubject(); break; default: Debug.Log("还没有产生指定的主题类"); return(null); } gameevents.Add(gameEvent, subject); return(subject); }
public IGameEventSubject GetGameEventSub(GameEventType eventType) { IGameEventSubject sub = null; if (mGameEvents.ContainsKey(eventType)) { sub = mGameEvents[eventType]; } else { switch (eventType) { case GameEventType.EnemyKilled: sub = new EnemyKilledSubject(); mGameEvents.Add(GameEventType.EnemyKilled, sub); break; case GameEventType.SoldierKilled: sub = new SoldierKilledSubject(); mGameEvents.Add(GameEventType.SoldierKilled, sub); break; case GameEventType.NewStage: sub = new NewStageSubject(); mGameEvents.Add(GameEventType.NewStage, sub); break; default: Debug.LogError("没有对应被观察事件类型:" + eventType + "的主题类!"); break; } } return(sub); }
private IGameEventSubject GetGameEventSubject(ENUM_GameEvent emGameEvent) { if (m_GameEvents.ContainsKey(emGameEvent)) { return(m_GameEvents[emGameEvent]); } IGameEventSubject rtsSubject = null; switch (emGameEvent) { case ENUM_GameEvent.EnemyKilled: rtsSubject = new EnemyKilledSubject(); break; case ENUM_GameEvent.SoldierKilled: rtsSubject = new SoldierKilledSubject(); break; case ENUM_GameEvent.SoldierUpgate: rtsSubject = new SoldierUpgateSubject(); break; case ENUM_GameEvent.NewStage: rtsSubject = new NewStageSubject(); break; default: Debug.Log("还没有针对[" + emGameEvent + "]指定要产生的Subject类"); return(null); } m_GameEvents.Add(emGameEvent, rtsSubject); return(rtsSubject); }
// 註冊一個事件 private IGameEventSubject GetGameEventSubject( ENUM_GameEvent emGameEvnet ) { // 是否已經存在 if( m_GameEvents.ContainsKey( emGameEvnet )) return m_GameEvents[emGameEvnet]; // 產生對映的GameEvent IGameEventSubject pSujbect= null; switch( emGameEvnet ) { case ENUM_GameEvent.EnemyKilled: pSujbect = new EnemyKilledSubject(); break; case ENUM_GameEvent.SoldierKilled: pSujbect = new SoldierKilledSubject(); break; case ENUM_GameEvent.SoldierUpgate: pSujbect = new SoldierUpgateSubject(); break; case ENUM_GameEvent.NewStage: pSujbect = new NewStageSubject(); break; default: Debug.LogWarning("還沒有針對["+emGameEvnet+"]指定要產生的Subject類別"); return null; } // 加入後並回傳 m_GameEvents.Add (emGameEvnet, pSujbect ); return pSujbect; }
// 設定觀察的主題 public override void SetSubject(IGameEventSubject theSubject) { if (theSubject is SoldierKilledSubject) { m_SoldierKilledSubject = theSubject as SoldierKilledSubject; } if (theSubject is EnemyKilledSubject) { m_EnemyKilledSubject = theSubject as EnemyKilledSubject; } }
// 注册一个事件 private IGameEventSubject GetGameEventSubject(ENUM_GameEvent emGameEvnet) { // 是否已經存在 if (m_GameEvents.ContainsKey(emGameEvnet)) { return(m_GameEvents[emGameEvnet]); } // 产生对应的GameEvent IGameEventSubject pSujbect = null; switch (emGameEvnet) { case ENUM_GameEvent.EnemyKilled: pSujbect = new EnemyKilledSubject(); break; case ENUM_GameEvent.SoldierKilled: pSujbect = new SoldierKilledSubject(); break; case ENUM_GameEvent.SoldierUpgate: pSujbect = new SoldierUpgateSubject(); break; case ENUM_GameEvent.NewStage: pSujbect = new NewStageSubject(); break; default: Debug.LogWarning("还沒有针对[" + emGameEvnet + "]指定要产生的Subject类别"); return(null); } // 加入后并回传 m_GameEvents.Add(emGameEvnet, pSujbect); return(pSujbect); }
public override void SetSubject(IGameEventSubject sub) { mSubject = sub as EnemyKilledSubject; }
// 設定觀察的主題 public override void SetSubject( IGameEventSubject Subject ) { m_Subject = Subject as EnemyKilledSubject; }
public override void SetSubject(IGameEventSubject Subject) { m_Subject = Subject as EnemyKilledSubject; }
public override void SetSubject(AbsGameEventSubject _subject) { subject = _subject as EnemyKilledSubject; }
//设置观察主题 public void SetSubject(ISubject subject) { enemysubject = subject as EnemyKilledSubject; }
public override void SetSubject(GameEventSubject sub) { m_subject = (EnemyKilledSubject)sub; }