/*
* AQP Project
* http://http://code.google.com/p/aqp-project/
* Alexandre Gomez - Clément Troesch - Fabrice Latterner
*/
package com.aqpproject.worldmodel.game.entity;
import com.aqpproject.game.Singleton;
import com.aqpproject.tools.Vector2D;
import com.aqpproject.worldmodel.game.state.RaceGameState;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/**
*
* @author Clément
*/
public class WEMine extends WorldPhysicEntity {
public WEMine(String name, Vector2D pos, float rotation, WECar emitter, RaceGameState state) {
super(name, "mine", pos, rotation, new Vector2D(23, 14), 0, 0, 0, 1);
m_state = state;
}
@Override
public void startContact(WorldPhysicEntity other, Vector2D normal, Vector2D point) {
if (m_isActive) {
m_state.getWorldEntities().put(m_name + "_Explosion", new WEExplosion(m_name + "_Explosion", getCenter()));
Singleton.getPhysics().applyAngularForce(other.m_name, 2000.f * (float) Math.random());
Singleton.getPhysics().applyLinearForce(other.m_name, getDirection().scale(50.f * (float) Math.random()));
m_isActive = false;
try {
Singleton.getAudioController().playSound("boom01", false);
} catch (ParserConfigurationException | SAXException | IOException ex) {
Logger.getLogger(WEMine.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void explode() {
if (m_isActive) {
m_state.getWorldEntities().put(m_name + "_Explosion", new WEExplosion(m_name + "_Explosion", getCenter()));
m_isActive = false;
}
}
@Override
public void stopContact(WorldPhysicEntity other, Vector2D normal, Vector2D point) {
}
@Override
public void startStaticContact(Vector2D normal, Vector2D point) {
}
@Override
public void stopStaticContact(Vector2D normal, Vector2D point) {
}
private RaceGameState m_state;
}