Package edu.ups.gamedev.weapons

Source Code of edu.ups.gamedev.weapons.DetonationAction

package edu.ups.gamedev.weapons;

import com.jme.input.action.InputAction;
import com.jme.input.action.InputActionEvent;
import com.jme.scene.Node;
import com.jmex.physics.contact.ContactInfo;

import edu.ups.gamedev.game.TankGame;
import edu.ups.gamedev.game.Tools;
import edu.ups.gamedev.scene.Collidable;

public class DetonationAction extends InputAction {
  private ContactInfo info;

  public void performAction(InputActionEvent action) {
    TankGame.GAME.lock();
   
    info = (ContactInfo) action.getTriggerData();
    handleFireable(info.getNode1(), info.getNode2());
    handleFireable(info.getNode2(), info.getNode1());
   
    TankGame.GAME.unlock();
  }

  private void handleFireable(Node node, Node other) {
    Collidable parent = Tools.getCollidableParent(node);
    if (parent instanceof Fireable) {
      ((Fireable) parent).detonate(other);
    }
  }

}
TOP

Related Classes of edu.ups.gamedev.weapons.DetonationAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.