Package edu.ups.gamedev.net.message

Source Code of edu.ups.gamedev.net.message.PhysicsFireableSynchronizeCreateMessage

package edu.ups.gamedev.net.message;

import com.captiveimagination.jgn.synchronization.message.SynchronizeCreateMessage;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import edu.ups.gamedev.weapons.PhysicsFireable;
import edu.ups.gamedev.weapons.Warhead;

/**
*
* @author Andrew Blaine
*/
public class PhysicsFireableSynchronizeCreateMessage extends SynchronizeCreateMessage {

  private Class fireableClass;
  private Warhead warhead;
 
  private Vector3f translation;
  private Quaternion rotation;
 
  private float stabilizationForce;
  private float stabilizationSpeed;
  private float linearDragCoefficient;
  private float linearDragArea;
  private float angularDragCoefficient;
  private float angularDragArea;

  public PhysicsFireableSynchronizeCreateMessage() {
    super();
    System.out.println("Creating FireableSyncCreateMessage");
    this.translation = new Vector3f();
    this.rotation = new Quaternion();
  }

  public PhysicsFireableSynchronizeCreateMessage(PhysicsFireable pFire) {
    super();
    System.out.println("Creating FireableSyncCreateMessage");
    warhead = pFire.getWarhead();
   
    this.translation = new Vector3f();
    this.rotation = new Quaternion();
   
    stabilizationForce = pFire.getStabilizationForce();
    stabilizationSpeed = pFire.getStabilizationSpeed();
    linearDragCoefficient = pFire.getLinearDragCoefficient();
    linearDragArea = pFire.getLinearDragArea();
    angularDragCoefficient = pFire.getAngularDragCoefficient();
    angularDragArea = pFire.getAngularDragArea();
  }

  public PhysicsFireableSynchronizeCreateMessage(Class fireableClass, PhysicsFireable pFire) {
    super();
    System.out.println("Creating FireableSyncCreateMessage");
    this.fireableClass = fireableClass;
    warhead = pFire.getWarhead();
   
    this.translation = new Vector3f();
    this.rotation = new Quaternion();
   
    stabilizationForce = pFire.getStabilizationForce();
    stabilizationSpeed = pFire.getStabilizationSpeed();
    linearDragCoefficient = pFire.getLinearDragCoefficient();
    linearDragArea = pFire.getLinearDragArea();
    angularDragCoefficient = pFire.getAngularDragCoefficient();
    angularDragArea = pFire.getAngularDragArea();
  }

  public PhysicsFireable getFireable() {
    PhysicsFireable pFire = null;
    try {
      pFire = (PhysicsFireable) fireableClass.newInstance();
      pFire.setWarhead(warhead);
    } catch (InstantiationException ie) {
      ie.printStackTrace();
    } catch (IllegalAccessException iae) {
      iae.printStackTrace();
    }

    pFire.setLocalTranslation(translation);
    pFire.setLocalRotation(rotation);
   
    pFire.setStabilizationForce(stabilizationForce);
    pFire.setStabilizationSpeed(stabilizationSpeed);
    pFire.setLinearDragCoefficient(linearDragCoefficient);
    pFire.setLinearDragArea(linearDragArea);
    pFire.setAngularDragCoefficient(angularDragCoefficient);
    pFire.setAngularDragArea(angularDragArea);
    return pFire;
  }
}
TOP

Related Classes of edu.ups.gamedev.net.message.PhysicsFireableSynchronizeCreateMessage

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.