@Override
  public void handle(int aEventType, Object aEventData) {
    if (aEventType == FlameMain.EVT_ASSET_RELOADED) {
      Object[] data = (Object[]) aEventData;
      if (data[0] instanceof ParticleEffect) {
        ParticleEffect oldEffect = (ParticleEffect) data[0];
        int currentCount = value.templates.size;
        value.templates.removeAll(oldEffect.getControllers(), true);
        if (value.templates.size != currentCount) {
          int diff = currentCount - value.templates.size;
          if (diff > 0) {
            ParticleEffect newEffect = (ParticleEffect) data[1];
            Array<ParticleController> newControllers = newEffect.getControllers();
            if (newControllers.size > 0) {
              for (int i = 0, c = Math.min(diff, newControllers.size); i < c; ++i)
                value.templates.add(newControllers.get(i));
            }
          } else {
            value.templates.addAll(
                ((ParticleEffect) editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE))
                    .getControllers());
          }

          controllerPicker.reloadTemplates();
          controllerPicker.setValue(value.templates);
          editor.restart();
        }
      }
    }
  }
 private void reloadControllers() {
   Array<ParticleEffect> effects = new Array<ParticleEffect>();
   Array<ParticleController> controllers = new Array<ParticleController>();
   editor.assetManager.getAll(ParticleEffect.class, effects);
   for (ParticleEffect effect : effects) {
     controllers.addAll(effect.getControllers());
   }
   controllerPicker.setLoadedTemplates(controllers);
 }
Beispiel #3
0
 public SpellProjectile(Matrix4 origin, Vector3 movement, ParticleEffect effect) {
   //         this.origin = origin;
   //         this.movement = movement;
   //         position = new Vector3();
   e = effect;
   e = a.firePool.obtain();
   a.particleSystem.add(e);
   e.init();
   e.start();
   body = new btRigidBody(2, null, new btSphereShape(0.1f));
   body.setWorldTransform(origin);
   body.setLinearVelocity(movement);
   //         body.setFriction(0f);
 }
 @Override
 protected void onUpdate(GameObject object, Vector3 offset, float delta) {
   if (effect == null) {
     effect = particleManager.create(object.getPosition(), type);
   }
   trans.set(offset.add(object.getPosition()), object.getOrientation());
   effect.setTransform(trans);
 }
Beispiel #5
0
 public void dispose() {
   if (hasParticles) {
     System.out.println("removed particles");
     magicParticles.end();
     a.particleSystem.remove(magicParticles); // (magicParticles);
     a.firePool.free(magicParticles);
     magicParticles = null;
     hasParticles = false;
   }
 }
Beispiel #6
0
 public void loadModel(AssetProvider a, Player p) {
   this.parent = p;
   this.a = a;
   hasParticles = false;
   if (!weaponID.equals("")) {
     mi = a.createInstance("core/assets/models/weapons/" + weaponID + ".g3dj");
   }
   /*    if (weaponID.contains("poison")) {
      magicParticles = a.poisonPool.obtain();
      magicParticles.init();
      magicParticles.start();
      a.particleSystem.add(magicParticles);
      hasParticles = true;
   } else */
   if (weaponID.contains("spell")) {
     magicParticles = a.firePool.obtain();
     magicParticles.init();
     magicParticles.start();
     a.particleSystem.add(magicParticles);
     hasParticles = true;
   }
 }
Beispiel #7
0
 public void onAttackEnd() {
   switch (attacktype) {
     case Bash:
       break;
     case Shoot:
       break;
     case Spell:
       magicParticles.start();
       break;
     case Stab:
       break;
     case Swing:
       break;
     default:
       break;
   }
 }
Beispiel #8
0
 public void onAttackStart() {
   switch (attacktype) {
     case Bash:
       break;
     case Shoot:
       canShoot = true;
       break;
     case Spell:
       if (parent.drainMana(spellcost)) {
         parent.w.addProjectile(
             new SpellProjectile(
                 mi.transform.cpy(), parent.face.cpy().scl(-8), a.firePool.obtain()));
         magicParticles.end();
       }
       break;
     case Stab:
       break;
     case Swing:
       break;
     default:
       break;
   }
 }
Beispiel #9
0
 public void update(float delta) {
   e.setTransform(body.getWorldTransform());
 }