I'm making a game for Android using Libgdx with Android Studio in Java. In my game, I have a class called ObjectFactory which has a method createGameObject(int objectType) which receives an integer from ObjectIds (a static class that hold a final static numbers for every object type: PLAYER = 0, BULLET = 1, ENEMY = 2 and etc...).
This method has a switch condition and 'till now I have reached 69 types of objects. The method gets the id, looks for it using the switch, creating that object and returns it. At the beginning it was comfortable using this way, but now it's really annoying looking for stuff over there because the switch statement is huge. This is an example of a case:
case Rules.GameObjectIds.EXPLOSION:
Explosion explosion = Pools.obtain(Explosion.class);
explosion.init(getTextureAtlas(explosion, AssetsPaths.Gfx.Sheets.Misc.Explosion.DATA_FILE), AssetsPaths.Gfx.Sheets.ImagesNames.BIG_EXP, x, y, AssetsPaths.Configs.ParticleEffects.EXPLOSION);
explosion.setDistanceInteraction(Rules.Misc.Explosion.BLAST_RADIUS);
gameObject = explosion;
listName = Rules.System.GameObjectTypes.EXPLOSIONS;
createEffect(AssetsPaths.Configs.ParticleEffects.BLAST_RING, gameObject);
createLight(explosion);
break;
I'm thinking about a way to simplify the Object Factory, any suggestions? Thanks in advance