added alienboat

This commit is contained in:
Tamino Mueller 2024-10-11 01:39:25 +02:00
parent 1f75f7bf30
commit d5450df77c
8 changed files with 18211 additions and 16 deletions

BIN
Projekte/Alienship.j3o Normal file

Binary file not shown.

View File

@ -34,6 +34,8 @@ import static pp.util.FloatMath.PI;
*/ */
class SeaSynchronizer extends ShipMapSynchronizer { class SeaSynchronizer extends ShipMapSynchronizer {
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
private static final String ALIENSHIP = "Models/Alienship/Alienship.j3o";
private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS
private static final String COLOR = "Color"; //NON-NLS private static final String COLOR = "Color"; //NON-NLS
private static final String SHIP = "ship"; //NON-NLS private static final String SHIP = "ship"; //NON-NLS
@ -141,8 +143,25 @@ class SeaSynchronizer extends ShipMapSynchronizer {
* @return the spatial representing the battleship * @return the spatial representing the battleship
*/ */
private Spatial createShip(Battleship ship) { private Spatial createShip(Battleship ship) {
return ship.getLength() == 4 ? createBattleship(ship) : createBox(ship); switch (ship.getLength()) {
case 4:
return createBattleship(ship);
case 5:
return createAllienship(ship);
default:
return createBox(ship);
} }
}
private Spatial createAllienship(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(ALIENSHIP);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.scale(0.0005f);
model.setShadowMode(ShadowMode.CastAndReceive);
return model;}
/** /**
* Creates a simple box to represent a battleship that is not of the "King George V" type. * Creates a simple box to represent a battleship that is not of the "King George V" type.

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -42,6 +42,10 @@ public class ModelExporter extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o");//NON-NLS export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o");//NON-NLS
export("Models/Alienship/Alienship.obj", "Alienship.j3o");//NON-NLS
export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o");//NON-NLS
export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o");//NON-NLS
export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o");//NON-NLS
stop(); stop();
} }

View File

@ -0,0 +1,11 @@
# Blender MTL File: 'water ship.blend'
# Material Count: 1
newmtl Material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

View File

@ -7,16 +7,16 @@
package pp.battleship.model; package pp.battleship.model;
import pp.battleship.notification.GameEvent;
import pp.battleship.notification.GameEventBroker;
import pp.battleship.notification.ItemAddedEvent;
import pp.battleship.notification.ItemRemovedEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import pp.battleship.notification.GameEvent;
import pp.battleship.notification.GameEventBroker;
import pp.battleship.notification.ItemAddedEvent;
import pp.battleship.notification.ItemRemovedEvent;
/** /**
* Represents a rectangular map that holds ships and registers shots fired. * Represents a rectangular map that holds ships and registers shots fired.
* It also supports event notification for game state changes such as item addition or removal. * It also supports event notification for game state changes such as item addition or removal.
@ -66,7 +66,7 @@ public class ShipMap {
*/ */
private void addItem(Item item) { private void addItem(Item item) {
items.add(item); items.add(item);
notifyListeners(new ItemRemovedEvent(item, this)); notifyListeners(new ItemAddedEvent(item, this));
} }
/** /**
@ -98,7 +98,7 @@ public class ShipMap {
*/ */
public void remove(Item item) { public void remove(Item item) {
items.remove(item); items.remove(item);
notifyListeners(new ItemAddedEvent(item, this)); notifyListeners(new ItemRemovedEvent(item, this));
} }
/** /**

View File

@ -54,6 +54,8 @@ public class ShipMapTest {
verify(mockBroker).notifyListeners(any(ItemAddedEvent.class)); verify(mockBroker).notifyListeners(any(ItemAddedEvent.class));
} }
@Test @Test
public void testRemoveItem() { public void testRemoveItem() {
map.add(battleship); map.add(battleship);