Exemplo n.º 1
0
        //Our enemy factory machine
        public static EnemyAbstractFactory MakeFactory(EnemyConfig enemy)
        {
            //Make our abstract factory object to return
            EnemyAbstractFactory factory = null;

            //Find out what type of enemy we're dealing with and return the appropriate factory
            switch (enemy.enemyType)
            {
            case EnemyType.EnemyA:
                factory = new EnemyAFactory();
                break;

            case EnemyType.EnemyB:
                factory = new EnemyBFactory();
                break;

            case EnemyType.MidBoss:
                factory = new MidBossFactory();
                break;

            case EnemyType.FinalBoss:
                factory = new FinalBossFactory();
                break;
            }

            return(factory);
        }
Exemplo n.º 2
0
        public static Enemy Create(BulletManager bulletManager, EnemyConfig enemy, GameData gameData, Vector2 origin)
        {
            //Make a factory for the corresponding type of enemy
            EnemyAbstractFactory factory = MakeFactory(enemy);

            if (factory != null)
            {
                return(factory.Create(bulletManager, enemy, gameData, origin));
            }
            return(null);
        }