added new card order in CardLayerHandler
This commit is contained in:
@@ -66,7 +66,7 @@ public class MdgaApp extends SimpleApplication {
|
||||
|
||||
private ServerConnection networkConnection;
|
||||
|
||||
public static final int DEBUG_MULTIPLIER = 1;
|
||||
public static final int DEBUG_MULTIPLIER = 0;
|
||||
|
||||
public MdgaApp() {
|
||||
networkConnection = new NetworkSupport(this);
|
||||
|
||||
@@ -29,6 +29,7 @@ public class CardLayerHandler {
|
||||
private DiceControl diceControl;
|
||||
|
||||
private final Map<BonusCard, CardControl> bonusCardControlMap = new HashMap<>();
|
||||
private final List<BonusCard> cardOrder = new ArrayList<>();
|
||||
private final Map<BonusCard, Integer> bonusCardIntegerMap = new HashMap<>();
|
||||
private final Set<CardControl> selectableCards = new HashSet<>();
|
||||
|
||||
@@ -80,14 +81,13 @@ public void addCard(BonusCard card) {
|
||||
if (card == BonusCard.HIDDEN) throw new RuntimeException("Can't add hidden card to GUI");
|
||||
|
||||
if (!bonusCardControlMap.containsKey(card)) {
|
||||
CardControl control = createCard(bonusToAsset(card), nextPos());
|
||||
bonusCardControlMap.put(card, control);
|
||||
cardLayer.addSpatial(control.getRoot());
|
||||
cardOrder.add(card);
|
||||
}
|
||||
|
||||
int newNum = bonusCardIntegerMap.getOrDefault(card, 0) + 1;
|
||||
bonusCardIntegerMap.put(card, newNum);
|
||||
bonusCardControlMap.get(card).setNumCard(newNum);
|
||||
|
||||
updateCard();
|
||||
}
|
||||
|
||||
public void removeCard(BonusCard card){
|
||||
@@ -95,12 +95,11 @@ public void removeCard(BonusCard 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);
|
||||
cardOrder.remove(card);
|
||||
}
|
||||
|
||||
}
|
||||
updateCard();
|
||||
} else throw new RuntimeException("card is not in bonusCardControlMap");
|
||||
}
|
||||
|
||||
public void clearSelectableCards() {
|
||||
@@ -114,6 +113,22 @@ public void clearSelectableCards() {
|
||||
cardSelect = null;
|
||||
}
|
||||
|
||||
private void updateCard(){
|
||||
for(BonusCard card : bonusCardControlMap.keySet()){
|
||||
CardControl control = bonusCardControlMap.get(card);
|
||||
cardLayer.deleteSpatial(control.getRoot());
|
||||
}
|
||||
bonusCardControlMap.clear();
|
||||
|
||||
for(int i = 0; i < cardOrder.size(); i++){
|
||||
BonusCard card = cardOrder.get(i);
|
||||
CardControl control = createCard(bonusToAsset(card), nextPos(i));
|
||||
control.setNumCard(bonusCardIntegerMap.get(card));
|
||||
cardLayer.addSpatial(control.getRoot());
|
||||
bonusCardControlMap.put(card, control);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectableCards(List<BonusCard> select) {
|
||||
for (BonusCard card : select) {
|
||||
selectableCards.add(bonusCardControlMap.get(card));
|
||||
@@ -171,8 +186,8 @@ private Asset bonusToAsset(BonusCard card) {
|
||||
};
|
||||
}
|
||||
|
||||
private Vector3f nextPos() {
|
||||
return START.add(MARGIN.mult(bonusCardControlMap.size()));
|
||||
private Vector3f nextPos(int i) {
|
||||
return START.add(MARGIN.mult(i));
|
||||
}
|
||||
|
||||
private Camera createOverlayCam() {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
public class DiceControl extends AbstractControl {
|
||||
private Quaternion targetRotation;
|
||||
private final Vector3f angularVelocity = new Vector3f();
|
||||
private float deceleration = 1.7f;
|
||||
private float deceleration = 1f;
|
||||
private float timeElapsed = 0.0f;
|
||||
private float rollDuration = 1f;
|
||||
private static final int ANGULAR_MIN = 5;
|
||||
|
||||
@@ -87,16 +87,16 @@ public Game() {
|
||||
gameStatistics = new Statistic();
|
||||
initializeDrawPile();
|
||||
board = new Board();
|
||||
die = new Die(2,1,6,2,1,3);
|
||||
die = new Die(2,4,5,5,1,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes the draw pile with the predefined number of bonus cards.
|
||||
*/
|
||||
private void initializeDrawPile() {
|
||||
// this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
|
||||
// this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
|
||||
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
|
||||
this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
|
||||
this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
|
||||
Collections.shuffle(this.drawPile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user