Testmerge #5
@@ -1,7 +1,7 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public enum Asset {
|
public enum Asset {
|
||||||
bigTent,
|
bigTent(0.57f),
|
||||||
cardStack,
|
cardStack,
|
||||||
cir,
|
cir,
|
||||||
heer,
|
heer,
|
||||||
@@ -17,7 +17,7 @@ public enum Asset {
|
|||||||
node_bonus("./node_normal/node_normal.j3o", "./node_normal/node_bonus_diff.png"),
|
node_bonus("./node_normal/node_normal.j3o", "./node_normal/node_bonus_diff.png"),
|
||||||
radar,
|
radar,
|
||||||
shieldCard,
|
shieldCard,
|
||||||
ship,
|
ship(0.9f),
|
||||||
smallTent,
|
smallTent,
|
||||||
swapCard,
|
swapCard,
|
||||||
tank,
|
tank,
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
import pp.mdga.game.Node;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class BoardView {
|
public class BoardView {
|
||||||
private static final float GRID_SIZE = 1.72f;
|
private static final float GRID_SIZE = 1.72f;
|
||||||
@@ -25,7 +24,7 @@ public class BoardView {
|
|||||||
private PileControl discardPile = new PileControl();
|
private PileControl discardPile = new PileControl();
|
||||||
|
|
||||||
private ArrayList<NodeControl> infield = new ArrayList<>(40);
|
private ArrayList<NodeControl> infield = new ArrayList<>(40);
|
||||||
private ArrayList<PieceControl> pieces;
|
private Map<UUID, PieceControl> pieces;
|
||||||
|
|
||||||
private Map<Color, List<AssetOnMap>> playerMap;
|
private Map<Color, List<AssetOnMap>> playerMap;
|
||||||
|
|
||||||
@@ -35,9 +34,10 @@ public BoardView(int playerCount, MdgaApp mdgaApp) {
|
|||||||
|
|
||||||
this.mdgaApp = mdgaApp;
|
this.mdgaApp = mdgaApp;
|
||||||
|
|
||||||
this.pieces = new ArrayList<>(4 * playerCount);
|
this.pieces = new HashMap<>();
|
||||||
this.playerMap = new HashMap<>();
|
this.playerMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
initMap();
|
initMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ private void initMap() {
|
|||||||
case heer -> addFigureToPlayerMap(assetToColor(Asset.heer), assetOnMap);
|
case heer -> addFigureToPlayerMap(assetToColor(Asset.heer), assetOnMap);
|
||||||
case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap);
|
case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap);
|
||||||
case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap);
|
case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap);
|
||||||
|
case node_normal, node_bonus, node_start -> displayAndControl(assetOnMap, new NodeControl());
|
||||||
default -> displayAsset(assetOnMap);
|
default -> displayAsset(assetOnMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,18 +97,25 @@ private static Vector3f gridToWorld(int x, int y) {
|
|||||||
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(Color color){
|
public void addPlayer(Color color, UUID uuid){
|
||||||
List<AssetOnMap> playerAssets = playerMap.get(color);
|
List<AssetOnMap> playerAssets = playerMap.get(color);
|
||||||
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
|
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
|
||||||
|
|
||||||
for (AssetOnMap assetOnMap : playerAssets){
|
for (AssetOnMap assetOnMap : playerAssets){
|
||||||
displayAsset(assetOnMap);
|
pieces.put(uuid, displayAndControl(assetOnMap, new PieceControl()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayAsset(AssetOnMap assetOnMap){
|
//displays an assets and return the created asset
|
||||||
|
private Spatial displayAsset(AssetOnMap assetOnMap){
|
||||||
int x = assetOnMap.x();
|
int x = assetOnMap.x();
|
||||||
int y = assetOnMap.y();
|
int y = assetOnMap.y();
|
||||||
Spatial model = createModel(assetOnMap.asset(), gridToWorld(x,y), assetOnMap.rot());
|
return createModel(assetOnMap.asset(), gridToWorld(x,y), assetOnMap.rot());
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control){
|
||||||
|
Spatial spatial = displayAsset(assetOnMap);
|
||||||
|
spatial.addControl(control);
|
||||||
|
return control;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ private static Asset getLoadedAsset(String assetName) {
|
|||||||
case "node_home_black" -> Asset.node_home_black;
|
case "node_home_black" -> Asset.node_home_black;
|
||||||
case "node_home_green" -> Asset.node_home_green;
|
case "node_home_green" -> Asset.node_home_green;
|
||||||
case "world" -> Asset.world;
|
case "world" -> Asset.world;
|
||||||
|
case "jet" -> Asset.jet;
|
||||||
|
case "big_tent" -> Asset.bigTent;
|
||||||
|
case "small_tent" -> Asset.smallTent;
|
||||||
|
case "radar" -> Asset.radar;
|
||||||
|
case "ship" -> Asset.ship;
|
||||||
|
case "tank" -> Asset.tank;
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public class NodeControl {
|
import com.jme3.renderer.RenderManager;
|
||||||
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.scene.control.AbstractControl;
|
||||||
|
|
||||||
|
public class NodeControl extends AbstractControl {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public class PieceControl {
|
import com.jme3.renderer.RenderManager;
|
||||||
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.scene.control.AbstractControl;
|
||||||
|
|
||||||
|
public class PieceControl extends AbstractControl {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MdgaApp extends SimpleApplication {
|
public class MdgaApp extends SimpleApplication {
|
||||||
private AnimationHandler animationHandler;
|
private AnimationHandler animationHandler;
|
||||||
@@ -39,18 +40,22 @@ public static void main(String[] args) {
|
|||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
animationHandler = new AnimationHandler(this);
|
animationHandler = new AnimationHandler(this);
|
||||||
boardView = new BoardView(4,this);
|
boardView = new BoardView(4,this);
|
||||||
boardView.addPlayer(Color.NAVY);
|
|
||||||
boardView.addPlayer(Color.AIRFORCE);
|
//display all pieces
|
||||||
boardView.addPlayer(Color.ARMY);
|
boardView.addPlayer(Color.NAVY, UUID.randomUUID());
|
||||||
boardView.addPlayer(Color.CYBER);
|
boardView.addPlayer(Color.AIRFORCE, UUID.randomUUID());
|
||||||
|
boardView.addPlayer(Color.ARMY, UUID.randomUUID());
|
||||||
|
boardView.addPlayer(Color.CYBER, UUID.randomUUID());
|
||||||
|
|
||||||
|
|
||||||
flyCam.setEnabled(true);
|
flyCam.setEnabled(true);
|
||||||
int zoom = 20;
|
int zoom = 40;
|
||||||
cam.setLocation(new Vector3f(zoom,0,zoom));
|
cam.setLocation(new Vector3f(-zoom,0,zoom));
|
||||||
cam.lookAt(new Vector3f(0,0,0), new Vector3f(0,0,1));
|
cam.lookAt(new Vector3f(0,0,0), new Vector3f(0,0,1));
|
||||||
|
|
||||||
DirectionalLight sun = new DirectionalLight();
|
DirectionalLight sun = new DirectionalLight();
|
||||||
sun.setColor(ColorRGBA.White);
|
sun.setColor(ColorRGBA.White);
|
||||||
sun.setDirection(new Vector3f(-1,0,-1));
|
sun.setDirection(new Vector3f(-0.3f,0,-1));
|
||||||
rootNode.addLight(sun);
|
rootNode.addLight(sun);
|
||||||
AmbientLight ambient = new AmbientLight();
|
AmbientLight ambient = new AmbientLight();
|
||||||
ambient.setColor(new ColorRGBA(0.3f,0.3f,0.3f,1));
|
ambient.setColor(new ColorRGBA(0.3f,0.3f,0.3f,1));
|
||||||
|
|||||||
@@ -42,23 +42,26 @@ cir 4,4 -90
|
|||||||
cir 5,4 -90
|
cir 5,4 -90
|
||||||
cir 5,5 -90
|
cir 5,5 -90
|
||||||
|
|
||||||
|
#Assets
|
||||||
|
jet -10,-1 -45
|
||||||
|
ship 11,0 79
|
||||||
|
big_tent -9,-7 40
|
||||||
|
big_tent 7,-10 135
|
||||||
|
small_tent -9,7 -45
|
||||||
|
small_tent -10,5 -30
|
||||||
|
radar 0,10 -110
|
||||||
|
small_tent 6,8 100
|
||||||
|
small_tent 8,7 70
|
||||||
|
tank -1,-10 45
|
||||||
|
|
||||||
|
|
||||||
#Yellow (CIR) Home Node
|
#Yellow (CIR) Home Node
|
||||||
node_home_yellow 4,5 0
|
node_home_yellow 4,5 0
|
||||||
node_home_yellow 4,4 0
|
node_home_yellow 4,4 0
|
||||||
node_home_yellow 5,4 0
|
node_home_yellow 5,4 0
|
||||||
node_home_yellow 5,5 0
|
node_home_yellow 5,5 0
|
||||||
|
|
||||||
#Nodes für Map 0
|
#Nodes für Map
|
||||||
node_start -1,-5 0
|
|
||||||
node -1,-4 0 0
|
|
||||||
node -1,-3 0 0
|
|
||||||
node -1,-2 0 0
|
|
||||||
node_bonus -1,-1 0
|
|
||||||
node -2,-1 0
|
|
||||||
node -3,-1 0
|
|
||||||
node -4,-1 0
|
|
||||||
node -5,-1 0
|
|
||||||
node -5,0 0
|
|
||||||
node_start -5,1 0
|
node_start -5,1 0
|
||||||
node -4,1 0
|
node -4,1 0
|
||||||
node -3,1 0
|
node -3,1 0
|
||||||
@@ -89,6 +92,17 @@ node 1,-3 0
|
|||||||
node 1,-4 0
|
node 1,-4 0
|
||||||
node 1,-5 0
|
node 1,-5 0
|
||||||
node 0,-5 0
|
node 0,-5 0
|
||||||
|
node_start -1,-5 0
|
||||||
|
node -1,-4 0 0
|
||||||
|
node -1,-3 0 0
|
||||||
|
node -1,-2 0 0
|
||||||
|
node_bonus -1,-1 0
|
||||||
|
node -2,-1 0
|
||||||
|
node -3,-1 0
|
||||||
|
node -4,-1 0
|
||||||
|
node -5,-1 0
|
||||||
|
node -5,0 0
|
||||||
|
|
||||||
|
|
||||||
#Node Home
|
#Node Home
|
||||||
node_home_green 0,-1 0
|
node_home_green 0,-1 0
|
||||||
|
|||||||
Reference in New Issue
Block a user