Exemplo n.º 1
0
    public override IEnemy CreateEnemy(ENUM_Enemy emEnemy, Vector3 SpawnPosition)
    {
        EnemyBuildParam EnemyParam = new EnemyBuildParam();


        switch (emEnemy)
        {
        case ENUM_Enemy.Keraha:
            EnemyParam.NewCharacter = new EnemyKeraha();
            break;

        default:
            Debug.LogWarning("无法创建[" + emEnemy + "]");
            return(null);
        }

        if (EnemyParam.NewCharacter == null)
        {
            return(null);
        }


        EnemyParam.SpawnPosition = SpawnPosition;


        EnemyBuilder theEnemyBuilder = new EnemyBuilder();

        theEnemyBuilder.SetBuildParam(EnemyParam);


        m_BuilderDirector.Construct(theEnemyBuilder);
        return(EnemyParam.NewCharacter as IEnemy);
    }
    // 建立Enemy(Generice版)
    public IEnemy CreateEnemy <T>(ENUM_Weapon emWeapon, Vector3 SpawnPosition, Vector3 AttackPosition) where T : IEnemy, new()
    {
        // 产生Enemy的参数
        EnemyBuildParam EnemyParam = new EnemyBuildParam();

        // 产生对应的Character
        EnemyParam.NewCharacter = new T();
        if (EnemyParam.NewCharacter == null)
        {
            return(null);
        }

        // 设定共用参数
        EnemyParam.emWeapon       = emWeapon;
        EnemyParam.SpawnPosition  = SpawnPosition;
        EnemyParam.AttackPosition = AttackPosition;

        //  产生对应的Builder及设定参数
        EnemyBuilder theEnemyBuilder = new EnemyBuilder();

        theEnemyBuilder.SetBuildParam(EnemyParam);

        // 产生
        m_BuilderDirector.Construct(theEnemyBuilder);
        return(EnemyParam.NewCharacter  as IEnemy);
    }
Exemplo n.º 3
0
    // 建立Enemy
    public override IEnemy CreateEnemy(ENUM_Enemy emEnemy, ENUM_Weapon emWeapon, Vector3 SpawnPosition, Vector3 AttackPosition)
    {
        // 產生Enemy的參數
        EnemyBuildParam EnemyParam = new EnemyBuildParam();

        // 產生對應的Character
        switch (emEnemy)
        {
        case ENUM_Enemy.Elf:
            EnemyParam.NewCharacter = new EnemyElf();
            break;

        case ENUM_Enemy.Troll:
            EnemyParam.NewCharacter = new EnemyTroll();
            break;

        case ENUM_Enemy.Ogre:
            EnemyParam.NewCharacter = new EnemyOgre();
            break;

        default:
            Debug.LogWarning("無法建立[" + emEnemy + "]");
            return(null);
        }

        if (EnemyParam.NewCharacter == null)
        {
            return(null);
        }

        // 設定共用參數
        EnemyParam.emWeapon       = emWeapon;
        EnemyParam.SpawnPosition  = SpawnPosition;
        EnemyParam.AttackPosition = AttackPosition;

        //  產生對應的Builder及設定參數
        EnemyBuilder theEnemyBuilder = new EnemyBuilder();

        theEnemyBuilder.SetBuildParam(EnemyParam);

        // 產生
        m_BuilderDirector.Construct(theEnemyBuilder);
        return(EnemyParam.NewCharacter  as IEnemy);
    }
Exemplo n.º 4
0
        public override IEnemy CreateEnemy(ENUM_Enemy enumEnemy, ENUM_Weapon enumWeapon,
                                           Vector3 SpawnPostion, Vector3 AttackPostion)
        {
            // 产生Enenmy的参数
            EnemyBuildParam EnemyParam = new EnemyBuildParam();

            switch (enumEnemy)
            {
            case ENUM_Enemy.Elf:
                EnemyParam.NewCharacter = new EnemyElf();
                break;

            case ENUM_Enemy.Troll:
                EnemyParam.NewCharacter = new EnemyTroll();
                break;

            case ENUM_Enemy.Ogre:
                EnemyParam.NewCharacter = new EnemyOgre();
                break;

            default:
                Debug.LogWarning("CreateEnemy:无法产生[" + enumEnemy + "]");
                return(null);
            }

            if (EnemyParam.NewCharacter == null)
            {
                return(null);
            }

            EnemyParam.emWeapon       = enumWeapon;
            EnemyParam.SpawnPosition  = SpawnPostion;
            EnemyParam.AttackPosition = AttackPostion;

            EnemyBuilder theEnemyBuilder = new EnemyBuilder();

            theEnemyBuilder.SetBuildParam(EnemyParam);

            m_BuilderDirector.Construct(theEnemyBuilder);
            return(EnemyParam.NewCharacter as IEnemy);
        }
	// 建立Enemy
	public override IEnemy CreateEnemy( ENUM_Enemy emEnemy, ENUM_Weapon emWeapon, Vector3 SpawnPosition, Vector3 AttackPosition)
	{
		// 產生Enemy的參數
		EnemyBuildParam EnemyParam = new EnemyBuildParam();

		// 產生對應的Character
		switch( emEnemy)
		{
		case ENUM_Enemy.Elf:
			EnemyParam.NewCharacter = new EnemyElf();
			break;
		case ENUM_Enemy.Troll:
			EnemyParam.NewCharacter = new EnemyTroll();
			break;
		case ENUM_Enemy.Ogre:
			EnemyParam.NewCharacter = new EnemyOgre();
			break;
		default:
			Debug.LogWarning("無法建立["+emEnemy+"]");
			return null;
		}

		if( EnemyParam.NewCharacter == null)
			return null;

		// 設定共用參數
		EnemyParam.emWeapon = emWeapon;
		EnemyParam.SpawnPosition = SpawnPosition;
		EnemyParam.AttackPosition = AttackPosition;
				
		//  產生對應的Builder及設定參數
		EnemyBuilder theEnemyBuilder = new EnemyBuilder();
		theEnemyBuilder.SetBuildParam( EnemyParam ); 
		
		// 產生
		m_BuilderDirector.Construct( theEnemyBuilder );
		return EnemyParam.NewCharacter  as IEnemy;
	}