|
|
@@ -2,6 +2,8 @@ package view;
|
|
|
|
|
|
import util.GAMESTATE;
|
|
|
import view.components.Button;
|
|
|
+import view.tile.interactive.Hut;
|
|
|
+import view.tile.interactive.InteractiveTile;
|
|
|
|
|
|
import java.awt.*;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -11,7 +13,7 @@ public class UI {
|
|
|
private Graphics2D g2;
|
|
|
private Font arial_40;
|
|
|
private ArrayList<Button> activeButtons = new ArrayList<>();
|
|
|
-
|
|
|
+ private ArrayList<InteractiveTile> interactiveTiles = new ArrayList<>();
|
|
|
public UI(GamePanel gp){
|
|
|
this.gp = gp;
|
|
|
arial_40 = new Font("Arial", Font.PLAIN, 80);
|
|
|
@@ -23,11 +25,19 @@ public class UI {
|
|
|
g2.setColor(Color.white);
|
|
|
|
|
|
if(gp.gameState == GAMESTATE.PAUSED){
|
|
|
- drawPauseScreen(g2, "Spiel Pausiert");
|
|
|
+ drawPauseScreen(g2, "Game paused");
|
|
|
+ }
|
|
|
+ if(gp.gameState == GAMESTATE.PLAY){
|
|
|
+ drawHut(g2);
|
|
|
}
|
|
|
}
|
|
|
+ public void drawHut(Graphics2D g2){
|
|
|
+ Hut hut = new Hut(gp.getGameController());
|
|
|
+ hut.draw(g2);
|
|
|
+ interactiveTiles.add(hut);
|
|
|
|
|
|
- public void handleClick(int screenX, int screenY) {
|
|
|
+ }
|
|
|
+ public void handleMenuClick(int screenX, int screenY) {
|
|
|
for (Button button : activeButtons) {
|
|
|
if (button.wasClicked(screenX, screenY)) {
|
|
|
button.click();
|
|
|
@@ -35,6 +45,15 @@ public class UI {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ public void handleClick(int screenX, int screenY){
|
|
|
+
|
|
|
+ for (InteractiveTile tile : interactiveTiles) {
|
|
|
+ if (tile.wasClicked(screenX, screenY)) {
|
|
|
+ tile.click();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
private void drawPauseScreen(Graphics2D g2, String message) {
|
|
|
|
|
|
|
|
|
@@ -66,14 +85,14 @@ public class UI {
|
|
|
int buttonX = gp.screenWidth / 2 - buttonWidth / 2;
|
|
|
int resumeY = boxY + 100;
|
|
|
int exitY = resumeY + buttonHeight + spacing;
|
|
|
- Button resumeButton = new Button(buttonHeight, buttonWidth, "Fortsetzen", () -> {
|
|
|
+ Button resumeButton = new Button(buttonHeight, buttonWidth, "Resume", () -> {
|
|
|
gp.gameState = GAMESTATE.PLAY;
|
|
|
});
|
|
|
resumeButton.setScreenCoordinates(buttonX, resumeY);
|
|
|
resumeButton.draw(g2);
|
|
|
activeButtons.add(resumeButton);
|
|
|
|
|
|
- Button exitButton = new Button(buttonHeight, buttonWidth, "Beenden", () -> {
|
|
|
+ Button exitButton = new Button(buttonHeight, buttonWidth, "Exit", () -> {
|
|
|
gp.gameState = GAMESTATE.QUIT; // or custom exit logic
|
|
|
});
|
|
|
exitButton.setScreenCoordinates(buttonX, exitY);
|