mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 12:40:59 +02:00
Compare commits
8 Commits
815899fa8d
...
008cb1ebe4
Author | SHA1 | Date | |
---|---|---|---|
|
008cb1ebe4 | ||
|
723c934d73 | ||
|
4eac2e3312 | ||
|
fef881f42c | ||
|
eeaf29a646 | ||
|
2eae0fce2a | ||
|
aa9e8ed3f0 | ||
|
3e14a2674f |
@ -95,7 +95,7 @@ public class BoardAppState extends MonopolyAppState {
|
|||||||
sceneNode.detachAllChildren();
|
sceneNode.detachAllChildren();
|
||||||
setupScene();
|
setupScene();
|
||||||
if (bobTheBuilder == null) {
|
if (bobTheBuilder == null) {
|
||||||
bobTheBuilder = new BobTheBuilder(getApp(), getApp().getRootNode());
|
bobTheBuilder = new BobTheBuilder(getApp(), sceneNode);
|
||||||
System.out.println("LISTENER IS REGISTEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
|
System.out.println("LISTENER IS REGISTEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
|
||||||
getGameLogic().addListener(bobTheBuilder);
|
getGameLogic().addListener(bobTheBuilder);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class BoardAppState extends MonopolyAppState {
|
|||||||
final float x = mx - cos;
|
final float x = mx - cos;
|
||||||
final float y = my - sin;
|
final float y = my - sin;
|
||||||
final Camera camera = getApp().getCamera();
|
final Camera camera = getApp().getCamera();
|
||||||
camera.setLocation(new Vector3f(x, ABOVE_SEA_LEVEL, y));
|
camera.setLocation(new Vector3f(0,40,0));
|
||||||
camera.lookAt(new Vector3f(0,0, 0),
|
camera.lookAt(new Vector3f(0,0, 0),
|
||||||
Vector3f.UNIT_Y);
|
Vector3f.UNIT_Y);
|
||||||
camera.update();
|
camera.update();
|
||||||
@ -210,6 +210,24 @@ public class BoardAppState extends MonopolyAppState {
|
|||||||
seaGeo.setMaterial(seaMat);
|
seaGeo.setMaterial(seaMat);
|
||||||
seaGeo.setShadowMode(ShadowMode.CastAndReceive);
|
seaGeo.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
TangentBinormalGenerator.generate(seaGeo);
|
TangentBinormalGenerator.generate(seaGeo);
|
||||||
|
sceneNode.attachChild(createCardDeck());
|
||||||
sceneNode.attachChild(seaGeo);
|
sceneNode.attachChild(seaGeo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node createCardDeck() {
|
||||||
|
Node cardDeck = new Node("cardDeck");
|
||||||
|
Spatial card = getApp().getAssetManager().loadModel("models/Kartendecks/Ereigniskarten_Deck.j3o");
|
||||||
|
card.setLocalTranslation(5.5f, 0, 2.7f);
|
||||||
|
card.setLocalScale(4.1f);
|
||||||
|
card.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y));
|
||||||
|
|
||||||
|
Spatial card2 = getApp().getAssetManager().loadModel("models/Kartendecks/Gemeinschaftskarten_Deck.j3o");
|
||||||
|
card2.setLocalTranslation(-1.4f, 0, -3.8f);
|
||||||
|
card2.setLocalScale(4.1f);
|
||||||
|
card2.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI , Vector3f.UNIT_Y));
|
||||||
|
|
||||||
|
cardDeck.attachChild(card);
|
||||||
|
cardDeck.attachChild(card2);
|
||||||
|
return cardDeck;
|
||||||
|
}
|
||||||
}
|
}
|
@ -120,6 +120,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
winnerSound = loadSound(app, "Sound/Effects/winner.ogg");
|
winnerSound = loadSound(app, "Sound/Effects/winner.ogg");
|
||||||
looserSound = loadSound(app, "Sound/Effects/loser.ogg");
|
looserSound = loadSound(app, "Sound/Effects/loser.ogg");
|
||||||
buttonSound = loadSound(app, "Sound/Effects/button.ogg");
|
buttonSound = loadSound(app, "Sound/Effects/button.ogg");
|
||||||
|
setVolume(volumeInPreferences());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,14 +95,14 @@ public class BuildingPropertyCard extends Dialog {
|
|||||||
buildingPropertyContainer.setLocalTranslation(
|
buildingPropertyContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y) / 2,
|
||||||
8
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - buildingPropertyContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + buildingPropertyContainer.getPreferredSize().y+ padding) / 2,
|
||||||
7
|
9
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(buildingPropertyContainer);
|
app.getGuiNode().attachChild(buildingPropertyContainer);
|
||||||
|
@ -125,13 +125,13 @@ public class BuyHouse extends Dialog {
|
|||||||
buyHouseContainer.setLocalTranslation(
|
buyHouseContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y) / 2,
|
||||||
11
|
9
|
||||||
);
|
);
|
||||||
|
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - buyHouseContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y + padding) / 2,
|
(app.getCamera().getHeight() + buyHouseContainer.getPreferredSize().y + padding) / 2,
|
||||||
10
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(buyHouseContainer);
|
app.getGuiNode().attachChild(buyHouseContainer);
|
||||||
|
@ -69,7 +69,7 @@ public class EventCardPopup extends Dialog {
|
|||||||
Container propertyValuesContainer = eventCardContainer.addChild(new Container());
|
Container propertyValuesContainer = eventCardContainer.addChild(new Container());
|
||||||
propertyValuesContainer.addChild(new Label(description, new ElementId("label-Text")));
|
propertyValuesContainer.addChild(new Label(description, new ElementId("label-Text")));
|
||||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
propertyValuesContainer.setPreferredSize(new Vector3f(300,200,10));
|
propertyValuesContainer.setPreferredSize(new Vector3f(300,200,0));
|
||||||
|
|
||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = eventCardContainer.addChild(new Button("Jawohl", new ElementId("button")));
|
Button quitButton = eventCardContainer.addChild(new Button("Jawohl", new ElementId("button")));
|
||||||
@ -83,14 +83,14 @@ public class EventCardPopup extends Dialog {
|
|||||||
eventCardContainer.setLocalTranslation(
|
eventCardContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
||||||
9
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
||||||
8
|
7
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(eventCardContainer);
|
app.getGuiNode().attachChild(eventCardContainer);
|
||||||
|
@ -4,6 +4,7 @@ import java.lang.System.Logger;
|
|||||||
import java.lang.System.Logger.Level;
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
|
||||||
@ -318,10 +319,21 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
if (msg.isAdded()) {
|
if (msg.isAdded()) {
|
||||||
BuildingProperty property = ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId()));
|
BuildingProperty property = ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId()));
|
||||||
if (property.getHotel() == 1 ) {
|
if (property.getHotel() == 1 ) {
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
board.remove(board.getHouse(msg.getId(), i+1));
|
||||||
|
}
|
||||||
|
|
||||||
board.add(new Hotel(property.getId()));
|
board.add(new Hotel(property.getId()));
|
||||||
} else {
|
} else {
|
||||||
board.add(new House( property.getHouses(), property.getId()));
|
board.add(new House( property.getHouses(), property.getId()));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if( ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId())).getHouses() == 4 ) {
|
||||||
|
board.remove(board.getHotel(msg.getId()));
|
||||||
|
} else {
|
||||||
|
board.remove(board.getHouse(msg.getId(), ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId())).getHouses()+1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,13 +454,9 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generatePredefinedGameState() {
|
private void generatePredefinedGameState() {
|
||||||
// Ensure at least two players exist
|
|
||||||
if (playerHandler.getPlayers().size() < 2) {
|
|
||||||
Player player1 = new Player(0, "Player1", playerHandler);
|
|
||||||
Player player2 = new Player(1, "Player2", playerHandler);
|
|
||||||
|
|
||||||
playerHandler.addPlayer(player1);
|
if(playerHandler.getPlayerCount() < 2) {
|
||||||
playerHandler.addPlayer(player2);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player p1 = playerHandler.getPlayerById(0);
|
Player p1 = playerHandler.getPlayerById(0);
|
||||||
@ -484,10 +480,10 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
assignProperties(p2, p2Properties);
|
assignProperties(p2, p2Properties);
|
||||||
|
|
||||||
// Player 1 builds houses on Gym and Sportplatz
|
// Player 1 builds houses on Gym and Sportplatz
|
||||||
buildHouses(p1, Set.of(1, 3));
|
// buildHouses(p1, Set.of(1, 3));
|
||||||
|
|
||||||
// Player 2 builds houses on the Red set
|
// Player 2 builds houses on the Red set
|
||||||
buildHouses(p2, Set.of(21, 23, 24));
|
// buildHouses(p2, Set.of(21, 23, 24));
|
||||||
|
|
||||||
// Set player balances
|
// Set player balances
|
||||||
p1.setAccountBalance(12325);
|
p1.setAccountBalance(12325);
|
||||||
|
@ -139,6 +139,14 @@ public class Board {
|
|||||||
return getItems(House.class);
|
return getItems(House.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public House getHouse(int fieldId, int stage) {
|
||||||
|
return getHouses().filter(house -> house.getFieldID() == fieldId && house.getStage() == stage).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel getHotel(int fieldId) {
|
||||||
|
return getHotels().filter(hotel -> hotel.getFieldID() == fieldId).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a stream of all hotels currently on the map.
|
* Returns a stream of all hotels currently on the map.
|
||||||
*
|
*
|
||||||
|
@ -96,4 +96,13 @@ public class Hotel implements Item{
|
|||||||
// TODO
|
// TODO
|
||||||
return Rotation.NORTH;
|
return Rotation.NORTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ID of the field the hotel is on.
|
||||||
|
*
|
||||||
|
* @return the ID of the field the hotel is on
|
||||||
|
*/
|
||||||
|
public int getFieldID() {
|
||||||
|
return fieldID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,15 @@ public class House implements Item{
|
|||||||
this.fieldID = 0;
|
this.fieldID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the field ID of the house.
|
||||||
|
*
|
||||||
|
* @return the field ID of the house
|
||||||
|
*/
|
||||||
|
public int getFieldID() {
|
||||||
|
return fieldID;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new house with the given stage.
|
* Creates a new house with the given stage.
|
||||||
*
|
*
|
||||||
|
@ -146,9 +146,10 @@ public class BoardManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a House can be sold on the given Property
|
* Checks if a House or Hotel can be sold on the given Property.
|
||||||
|
*
|
||||||
* @param field the Property to check
|
* @param field the Property to check
|
||||||
* @return true if a house can be sold on the property, false otherwise
|
* @return true if a house or hotel can be sold on the property, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean canSell(BuildingProperty field) {
|
public boolean canSell(BuildingProperty field) {
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
@ -174,7 +175,7 @@ public class BoardManager {
|
|||||||
int currentHouses = field.getHouses();
|
int currentHouses = field.getHouses();
|
||||||
int currentHotel = field.getHotel();
|
int currentHotel = field.getHotel();
|
||||||
|
|
||||||
// If there is a hotel, selling is allowed only if all other properties have max houses
|
// If there is a hotel, ensure all other properties have max houses (4) before selling it
|
||||||
if (currentHotel > 0) {
|
if (currentHotel > 0) {
|
||||||
return groupProperties.stream()
|
return groupProperties.stream()
|
||||||
.allMatch(bp -> bp.getHouses() == 4 || bp.equals(field));
|
.allMatch(bp -> bp.getHouses() == 4 || bp.equals(field));
|
||||||
@ -185,6 +186,7 @@ public class BoardManager {
|
|||||||
.allMatch(bp -> bp.getHouses() <= currentHouses);
|
.allMatch(bp -> bp.getHouses() <= currentHouses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt eine Liste von BuildingProperty-Feldern zurück, auf denen Häuser oder Hotels stehen.
|
* Gibt eine Liste von BuildingProperty-Feldern zurück, auf denen Häuser oder Hotels stehen.
|
||||||
* @return Liste von BuildingProperty-Feldern mit Gebäuden
|
* @return Liste von BuildingProperty-Feldern mit Gebäuden
|
||||||
@ -198,3 +200,10 @@ public class BoardManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
- Häuser beim bau eines Hotels entfernen
|
||||||
|
- Alle texturen schwarz
|
||||||
|
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user