added 'Shell' and 'ShellControl' and editet the two visitors 'Visitor' and 'VoidVisitor'

This commit is contained in:
Benjamin Feyer
2024-10-10 22:23:55 +02:00
parent dffb5b4d63
commit 30a735bd6e
4 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package pp.battleship.client.gui;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.battleship.model.Shell;
import pp.battleship.model.ShipMap;
public class ShellControl extends AbstractControl {
private Shell shell;
private ShipMap map;
private static final Float HEIGHT = 0f;
public ShellControl(Shell shell, ShipMap map){
this.shell=shell;
this.map=map;
}
@Override
protected void controlUpdate(float tpf) {
if (spatial == null) return;
if(spatial.getLocalTranslation().getY()<=HEIGHT){
spatial.getParent().detachChild(spatial);
}
else{
spatial.move(0,-0.5f*tpf,0);
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
public Shell getShell(){
return shell;
}
}