Development #34
@@ -33,11 +33,11 @@ public enum Asset {
|
||||
treeSmall(1.2f),
|
||||
treeBig(1.2f),
|
||||
turboCard,
|
||||
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
|
||||
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
|
||||
swapCard,
|
||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
|
||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
||||
shieldCard,
|
||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
|
||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
||||
dice
|
||||
;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
import pp.mdga.notification.SelectableCardsNotification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class InputSynchronizer {
|
||||
|
||||
@@ -127,7 +128,17 @@ else if(boardSelect != null) {
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
|
||||
gameView.getGuiHandler().showDice();
|
||||
// gameView.getGuiHandler().showDice();
|
||||
// UUID p1 = UUID.randomUUID();
|
||||
|
||||
// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
||||
// gameView.getBoardHandler().movePieceStartAnim(p1,0);
|
||||
gameView.getGuiHandler().drawCard(Color.ARMY);
|
||||
gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
|
||||
gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public void simpleInitApp() {
|
||||
gameView = new GameView(this);
|
||||
ceremonyView = new CeremonyView(this);
|
||||
|
||||
enter(MdgaState.MAIN);
|
||||
enter(MdgaState.GAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ private void handleGame(Notification notification) {
|
||||
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||
|
||||
if (notification instanceof AcquireCardNotification n) {
|
||||
guiHandler.addCard(n.getBonusCard());
|
||||
guiHandler.addCardOwn(n.getBonusCard());
|
||||
} else if (notification instanceof ActivePlayerNotification n) {
|
||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||
boardHandler.showDice(n.getColor());
|
||||
@@ -147,12 +147,8 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof NoShieldNotification n) {
|
||||
boardHandler.unshieldPiece(n.getPieceId());
|
||||
} else if (notification instanceof PlayCardNotification n) {
|
||||
switch(n.getCard()){
|
||||
case SWAP -> guiHandler.swap();
|
||||
case TURBO -> guiHandler.turbo();
|
||||
case SHIELD -> guiHandler.shield();
|
||||
default -> throw new RuntimeException("invalid card");
|
||||
}
|
||||
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
|
||||
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
||||
} else if (notification instanceof PlayerInGameNotification n) {
|
||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||
|
||||
@@ -60,7 +60,7 @@ private Node createNum(){
|
||||
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.Black);
|
||||
circle.setMaterial(mat);
|
||||
root.attachChild(circle);
|
||||
// root.attachChild(circle);
|
||||
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
||||
num = new BitmapText(guiFont);
|
||||
num.setSize(0.3f);
|
||||
|
||||
@@ -86,7 +86,7 @@ public void render(RenderManager rm) {
|
||||
public void update(float tpf) {
|
||||
if (init && !cardBuffer.isEmpty()) {
|
||||
for (Spatial spatial : cardBuffer) {
|
||||
root.attachChild(spatial);
|
||||
// root.attachChild(spatial);
|
||||
}
|
||||
cardBuffer.clear();
|
||||
}
|
||||
@@ -94,7 +94,9 @@ public void update(float tpf) {
|
||||
}
|
||||
|
||||
public void addSpatial(Spatial card) {
|
||||
cardBuffer.add(card);
|
||||
// cardBuffer.add(card);
|
||||
root.attachChild(card);
|
||||
root = root;
|
||||
}
|
||||
|
||||
public void deleteSpatial(Spatial spatial) {
|
||||
|
||||
@@ -85,6 +85,19 @@ public void addCard(BonusCard card) {
|
||||
bonusCardControlMap.get(card).setNumCard(newNum);
|
||||
}
|
||||
|
||||
public void removeCard(BonusCard card){
|
||||
if(bonusCardControlMap.containsKey(card)){
|
||||
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
|
||||
|
||||
if(bonusCardIntegerMap.get(card) <= 0){
|
||||
cardLayer.deleteSpatial(bonusCardControlMap.get(card).getRoot());
|
||||
bonusCardIntegerMap.remove(card);
|
||||
bonusCardControlMap.remove(card);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSelectableCards() {
|
||||
for (CardControl control : selectableCards) {
|
||||
control.setSelectable(false);
|
||||
|
||||
@@ -74,8 +74,31 @@ public void hideDice() {
|
||||
cardLayerHandler.hideDice();
|
||||
}
|
||||
|
||||
public void addCard(BonusCard card) {
|
||||
//add own handCard
|
||||
public void addCardOwn(BonusCard card) {
|
||||
cardLayerHandler.addCard(card);
|
||||
playerNameHandler.addCard(ownColor);
|
||||
actionTextHandler.drawCardOwn(ownColor);
|
||||
}
|
||||
|
||||
public void playCardOwn(BonusCard card){
|
||||
getEffectByCard(card);
|
||||
cardLayerHandler.removeCard(card);
|
||||
playerNameHandler.removeCard(ownColor);
|
||||
}
|
||||
|
||||
public void playCardEnemy(Color color, BonusCard card) {
|
||||
getEffectByCard(card);
|
||||
playerNameHandler.removeCard(color);
|
||||
}
|
||||
|
||||
private void getEffectByCard(BonusCard bonus){
|
||||
switch(bonus){
|
||||
case SWAP -> swap();
|
||||
case TURBO -> turbo();
|
||||
case SHIELD -> shield();
|
||||
default -> throw new RuntimeException("invalid card");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSelectableCards() {
|
||||
@@ -125,9 +148,11 @@ public void hideText(){
|
||||
actionTextHandler.hide();
|
||||
}
|
||||
|
||||
//addCard Enemy (DrawCardNotification)
|
||||
public void drawCard(Color color) {
|
||||
if (ownColor == color) actionTextHandler.drawCardOwn(color);
|
||||
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||
//Color != ownColor
|
||||
actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||
playerNameHandler.addCard(color);
|
||||
}
|
||||
|
||||
public void finish(Color color){
|
||||
@@ -141,4 +166,6 @@ public void rollRankingResult(Color color, int eye){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,23 +4,27 @@
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.system.AppSettings;
|
||||
import com.jme3.ui.Picture;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class PlayerNameHandler {
|
||||
private final BitmapFont playerFont;
|
||||
private final Node playerNameNode;
|
||||
private final List<Color> playerOrder;
|
||||
private final Map<Color, String> colorNameMap;
|
||||
private final Map<Color, Integer> colorCardMap;
|
||||
|
||||
private final AppSettings appSettings;
|
||||
private final AssetManager assetManager;
|
||||
private Color ownColor;
|
||||
@@ -43,6 +47,7 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
|
||||
playerNameNode = new Node("player name node");
|
||||
playerOrder = new ArrayList<>();
|
||||
colorNameMap = new HashMap<>();
|
||||
colorCardMap = new HashMap<>();
|
||||
this.appSettings = appSettings;
|
||||
this.assetManager = assetManager;
|
||||
}
|
||||
@@ -64,13 +69,38 @@ private void drawPlayers(){
|
||||
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
|
||||
|
||||
Node nameParent = new Node("nameParent");
|
||||
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
|
||||
nameParent.attachChild(createColor(color));
|
||||
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
|
||||
nameParent.attachChild(name);
|
||||
if(colorCardMap.getOrDefault(color, 0) > 0){
|
||||
Picture pic = createHandCard(name.getLineWidth());
|
||||
nameParent.attachChild(pic);
|
||||
nameParent.attachChild(createCardNum(colorCardMap.get(color), pic.getWidth(), pic.getLocalTranslation().getX()));
|
||||
}
|
||||
nameParent.setLocalTranslation(50,appSettings.getWindowHeight()-PADDING_TOP- MARGIN_NAMES *i,0);
|
||||
playerNameNode.attachChild(nameParent);
|
||||
}
|
||||
}
|
||||
|
||||
private Spatial createCardNum(int num, float lastWidth, float lastX ) {
|
||||
BitmapText hudText = new BitmapText(playerFont);
|
||||
//renderedSize = 45
|
||||
hudText.setSize(TEXT_SIZE);
|
||||
hudText.setColor(NORMAL_COLOR);
|
||||
hudText.setText(String.valueOf(num));
|
||||
hudText.setLocalTranslation(lastX + lastWidth + 20,hudText.getHeight()/2, 0);
|
||||
return hudText;
|
||||
}
|
||||
|
||||
private Picture createHandCard(float width) {
|
||||
Picture pic = new Picture("HUD Picture");
|
||||
pic.setImage(assetManager, "./Images/handcard.png", true);
|
||||
pic.setWidth(IMAGE_SIZE);
|
||||
pic.setHeight(IMAGE_SIZE);
|
||||
pic.setPosition(-pic.getWidth()/2 + width + PADDING_LEFT * 2 ,-pic.getHeight()/2);
|
||||
return pic;
|
||||
}
|
||||
|
||||
private String imagePath(Color color){
|
||||
String root = "./Images/name_pictures/";
|
||||
return switch(color){
|
||||
@@ -93,7 +123,7 @@ private Spatial createColor(Color color) {
|
||||
|
||||
|
||||
|
||||
private Spatial createName(String name, boolean first, boolean own){
|
||||
private BitmapText createName(String name, boolean first, boolean own){
|
||||
BitmapText hudText = new BitmapText(playerFont);
|
||||
//renderedSize = 45
|
||||
hudText.setSize(TEXT_SIZE);
|
||||
@@ -124,5 +154,18 @@ public String getName(Color color){
|
||||
return colorNameMap.get(color);
|
||||
}
|
||||
|
||||
public void addCard(Color color){
|
||||
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
public void removeCard(Color color){
|
||||
if(colorCardMap.containsKey(color)){
|
||||
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1);
|
||||
if(colorCardMap.get(color) <= 0) colorCardMap.remove(color);
|
||||
}
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -65,10 +65,11 @@ public void onEnter() {
|
||||
|
||||
app.getAcousticHandler().playSound(MdgaSound.START);
|
||||
|
||||
// guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
|
||||
// guiHandler.addPlayer(Color.ARMY, "Ben");
|
||||
// guiHandler.addPlayer(Color.CYBER, "Felix");
|
||||
// guiHandler.addPlayer(Color.NAVY, "Daniel");
|
||||
guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
|
||||
guiHandler.addPlayer(Color.ARMY, "Ben");
|
||||
guiHandler.addPlayer(Color.CYBER, "Felix");
|
||||
guiHandler.addPlayer(Color.NAVY, "Daniel");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
BIN
Projekte/mdga/client/src/main/resources/Images/handcard.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/Images/handcard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user