private static Team readTeam(LayerObject obj) { int team = obj.getIntProperty("Team", -1); if (team == 0) { return Team.BLUE; } else if (team == 1) { return Team.RED; } return null; }
private static void createMapEntities( TiledMap map, PooledEngine engine, PhysixSystem physixSystem) { for (Layer layer : map.getLayers()) { if (layer.isObjectLayer()) { // / pre filtering important objects, // / wich needs to be already existing when loading other // Objects for (LayerObject obj : layer.getObjects()) { String entitytype = obj.getProperty("Entitytype", null); if (entitytype != null) { entitytype = entitytype.toLowerCase(); if (entitytype != null) { createMapEntity(entitytype, engine, physixSystem, obj, readTeam(obj)); } } } } } }
private static void createChainLights(TiledMap map, PooledEngine engine) { for (Layer layer : map.getLayers()) { if (layer.isObjectLayer()) { for (LayerObject obj : layer.getObjects()) { String entitytype = obj.getProperty("Entitytype", null); if (entitytype != null && entitytype.toLowerCase().equals("chainlight")) { createChainLight( engine, obj.getX(), obj.getY(), Color.valueOf(obj.getProperty("color", "FFFFFF")), obj.getFloatProperty("distance", 200), obj.getIntProperty("direction", 1), obj.getPoints()); } } } } }
private static void createMapEntity( String entitytype, PooledEngine engine, PhysixSystem physixSystem, LayerObject obj, Team team) { switch (entitytype) { case "goal": createTrigger( engine, physixSystem, obj.getX(), obj.getY(), obj.getWidth(), obj.getHeight(), new GoalTrigger(engine, team)); break; case "magnet": if (team == Team.BLUE) { entitytype = "magnet_minus"; } else { entitytype = "magnet_plus"; } case "playerspawn": case "ballspawn": createEntity( engine, entitytype, obj.getX() + obj.getWidth() / 2.0f, obj.getY() - obj.getHeight() / 2.0f, team); break; case "goal_particles_tl": // System.out.println("found dings"); createEntity( engine, entitytype, obj.getX() + obj.getWidth() / 2.0f, obj.getY() - obj.getHeight() / 2.0f, team); break; case "goal_particles_tr": createEntity( engine, entitytype, obj.getX() + obj.getWidth() / 2.0f, obj.getY() - obj.getHeight() / 2.0f, team); break; case "goal_particles_bl": createEntity( engine, entitytype, obj.getX() + obj.getWidth() / 2.0f, obj.getY() - obj.getHeight() / 2.0f, team); break; case "goal_particles_br": createEntity( engine, entitytype, obj.getX() + obj.getWidth() / 2.0f, obj.getY() - obj.getHeight() / 2.0f, team); break; default: System.out.println(entitytype + "Nicht bekannt"); } }