コード例 #1
0
	// 設定觀察的主題
	public override	void SetSubject( IGameEventSubject theSubject )
	{
		if( theSubject is SoldierKilledSubject )
			m_SoldierKilledSubject = theSubject as SoldierKilledSubject;
		if( theSubject is EnemyKilledSubject)
			m_EnemyKilledSubject = theSubject as EnemyKilledSubject;
	}
コード例 #2
0
    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);
    }
コード例 #3
0
ファイル: GameEventSystem.cs プロジェクト: maousama/Assets
    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);
    }
コード例 #4
0
ファイル: GameEventSystem.cs プロジェクト: kismy/DesignMode
    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);
    }
コード例 #5
0
ファイル: GameEventSystem.cs プロジェクト: Leon-56/Unity-RTS
        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);
        }
コード例 #6
0
	// 註冊一個事件
	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;
	}
コード例 #7
0
 // 設定觀察的主題
 public override void SetSubject(IGameEventSubject theSubject)
 {
     if (theSubject is SoldierKilledSubject)
     {
         m_SoldierKilledSubject = theSubject as SoldierKilledSubject;
     }
     if (theSubject is EnemyKilledSubject)
     {
         m_EnemyKilledSubject = theSubject as EnemyKilledSubject;
     }
 }
コード例 #8
0
    // 注册一个事件
    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);
    }
コード例 #9
0
 public override void SetSubject(IGameEventSubject sub)
 {
     mSubject = sub as EnemyKilledSubject;
 }
コード例 #10
0
	// 設定觀察的主題
	public override	void SetSubject( IGameEventSubject Subject )
	{
		m_Subject = Subject as EnemyKilledSubject;
	}
コード例 #11
0
 public override void SetSubject(IGameEventSubject Subject)
 {
     m_Subject = Subject as EnemyKilledSubject;
 }
 public override void SetSubject(AbsGameEventSubject _subject)
 {
     subject = _subject as EnemyKilledSubject;
 }
コード例 #13
0
 //设置观察主题
 public void SetSubject(ISubject subject)
 {
     enemysubject = subject as EnemyKilledSubject;
 }
コード例 #14
0
 public override void SetSubject(GameEventSubject sub)
 {
     m_subject = (EnemyKilledSubject)sub;
 }