Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VikingService implements IVikingService {
- ArrayList<IGameEntity> vikings;
- /**
- * Default implementation loads 4 vikings of each type into list
- */
- public VikingService() {
- vikings = new ArrayList<IGameEntity>();
- vikings.add(new Viking(100, 100, IGameEntity.Type.VIKING));
- vikings.add(new Viking(100, 200, IGameEntity.Type.VIKING));
- vikings.add(new Viking(100, 520, IGameEntity.Type.VIKING));
- vikings.add(new Viking(100, 620, IGameEntity.Type.VIKING));
- vikings.add(new Viking(1000, 100, IGameEntity.Type.ENEMY_VIKING));
- vikings.add(new Viking(1000, 200, IGameEntity.Type.ENEMY_VIKING));
- vikings.add(new Viking(1000, 520, IGameEntity.Type.ENEMY_VIKING));
- vikings.add(new Viking(1000, 620, IGameEntity.Type.ENEMY_VIKING));
- }
- //@todo implement selection based on enum type. make new array list and pluck out appropriate types to return in new list.
- @Override
- public ArrayList<IGameEntity> getVikings(IGameEntity.Type t) {
- return vikings;
- }
- @Override
- public void disposeVikings() {
- vikings.clear();
- vikings = null;
- }
- @Override
- public void addViking(double xPos, double yPos, IGameEntity.Type t) {
- if (vikings == null)
- vikings = new ArrayList<IGameEntity>();
- vikings.add(new Viking(xPos, yPos, t));
- }
- }
- //////////////////////ACTIVATOR BELOW HERE//////////////////////
- public class Activator implements BundleActivator {
- private ServiceRegistration registration;
- @Override
- public void start(BundleContext context) throws Exception {
- registration = context.registerService(IVikingService.class, new VikingService(), null);
- }
- @Override
- public void stop(BundleContext context) throws Exception {
- ServiceReference ref = context.getServiceReference(IVikingService.class);
- IVikingService v = (IVikingService) context.getService(ref);
- v.disposeVikings();
- registration.unregister();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement