package org.ntlab.SproutServer.battles; import framework.model3D.CollisionResult; import framework.model3D.Object3D; import framework.model3D.Position3D; import framework.physics.Solid3D; import framework.physics.Velocity3D; import net.arnx.jsonic.JSONHint; import javax.vecmath.Vector3d; import java.net.URLDecoder; /** * プレイヤーの弾 * * @author matsumoto_k */ public class Bullet extends Weapon { private static final int attack = 100; public Bullet(Position3D position3D, Vector3d vector3d, Velocity3D velocity3D) { this.actor = new WeaponActor(new Solid3D(createObject()), null) { @Override public void onIntersect(CollisionResult normal, long interval) { if (normal != null) alive = false; } }; initWeapon(position3D, vector3d, velocity3D); } @Override Object3D createObject() { //TODO:弾のオブジェクトを決める String path = Battles.getInstance().getClass().getResource("pocha.stl").getPath(); try { path = URLDecoder.decode(path, "utf-8"); } catch (Exception e) { } BulletModel bulletModel = new BulletModel(path, null); return bulletModel.createObject(); } public Position3D getPosition3d() { return getActor().getPosition(); } public Vector3d getVector3d() { return getActor().getDirection(); } @Override long getInitWeaponLife() { return BattlesConst.BULLET_LIFE_TIME; } @Override @JSONHint(ignore = true) public int getAttack() { return attack; } }