lucasjoshua #12
Binary file not shown.
After Width: | Height: | Size: 854 B |
Binary file not shown.
After Width: | Height: | Size: 875 B |
Binary file not shown.
After Width: | Height: | Size: 889 B |
|
@ -0,0 +1,54 @@
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class BoardDisplay extends JPanel {
|
||||
public BoardDisplay(int gridSize, Icon buttonIcon) {
|
||||
super(new GridLayout(gridSize + 1, gridSize + 1)); // +1 wegen extra Zeile/Splate
|
||||
|
||||
// Erstellung von Spielfeld
|
||||
for (int i = 0; i <= gridSize; i++) {
|
||||
for (int j = 0; j <= gridSize; j++) {
|
||||
if (i == 0 && j == 0) {
|
||||
add(new JLabel(" "));
|
||||
} else if (i == 0) {
|
||||
JLabel colLabel = new JLabel(String.valueOf(j));
|
||||
colLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
colLabel.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
add(colLabel);
|
||||
} else if (j == 0) {
|
||||
JLabel rowLabel = new JLabel(String.valueOf((char) ('A' + i - 1)));
|
||||
rowLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
rowLabel.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
add(rowLabel);
|
||||
} else {
|
||||
// Spielfeld (interaktive Zellen)
|
||||
JButton field = new JButton("");
|
||||
field.setBackground(Color.LIGHT_GRAY);
|
||||
field.setOpaque(true);
|
||||
field.setBorderPainted(true);
|
||||
|
||||
field.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(SwingUtilities.isRightMouseButton(e)) {
|
||||
handleFieldClick(field);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
// field.setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
});
|
||||
add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFieldClick(JButton field) {
|
||||
field.setBackground(Color.RED);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
import javafx.scene.control.ToggleGroup;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -19,21 +21,22 @@ public class GameBoard extends JPanel {
|
|||
|
||||
JButton backButton = new JButton(backButtonIcon);
|
||||
// Eigene ModulButtons
|
||||
JButton leftPlayerModul1 = new JButton("Modul 1"); //TODO: Dynamische Namen durch abgleich mit Semester
|
||||
JButton leftPlayerModul2 = new JButton("Modul 2");
|
||||
JButton leftPlayerModul3 = new JButton("Modul 3");
|
||||
JButton leftPlayerModul4 = new JButton("Modul 4");
|
||||
JButton leftPlayerModul5 = new JButton("Modul 5");
|
||||
JButton leftPlayerModul6 = new JButton("Modul 6");
|
||||
JButton leftPlayerModul7 = new JButton("Reset");
|
||||
JToggleButton leftPlayerModul1 = new JToggleButton("Modul 1"); //TODO: Dynamische Namen durch abgleich mit Semester
|
||||
JToggleButton leftPlayerModul2 = new JToggleButton("Modul 2");
|
||||
JToggleButton leftPlayerModul3 = new JToggleButton("Modul 3");
|
||||
JToggleButton leftPlayerModul4 = new JToggleButton("Modul 4");
|
||||
JToggleButton leftPlayerModul5 = new JToggleButton("Modul 5");
|
||||
JToggleButton leftPlayerModul6 = new JToggleButton("Modul 6");
|
||||
JToggleButton leftPlayerModul7 = new JToggleButton("Reset");
|
||||
|
||||
// Gegnerische ModulButtons
|
||||
JButton rightPlayerModul1 = new JButton("Modul 1");
|
||||
JButton rightPlayerModul2 = new JButton("Modul 2");
|
||||
JButton rightPlayerModul3 = new JButton("Modul 3");
|
||||
JButton rightPlayerModul4 = new JButton("Modul 4");
|
||||
JButton rightPlayerModul5 = new JButton("Modul 5");
|
||||
JButton rightPlayerModul6 = new JButton("Modul 6");
|
||||
JButton rightPlayerModul7 = new JButton("Bereit");
|
||||
JToggleButton rightPlayerModul1 = new JToggleButton("Modul 1");
|
||||
JToggleButton rightPlayerModul2 = new JToggleButton("Modul 2");
|
||||
JToggleButton rightPlayerModul3 = new JToggleButton("Modul 3");
|
||||
JToggleButton rightPlayerModul4 = new JToggleButton("Modul 4");
|
||||
JToggleButton rightPlayerModul5 = new JToggleButton("Modul 5");
|
||||
JToggleButton rightPlayerModul6 = new JToggleButton("Modul 6");
|
||||
JToggleButton rightPlayerModul7 = new JToggleButton("Bereit");
|
||||
|
||||
public void buildPanel(MainFrame frame, int semesterCounter) {
|
||||
// Hauptlayout - BorderLayout für die Anordnung der Komponenten
|
||||
|
@ -68,23 +71,31 @@ public class GameBoard extends JPanel {
|
|||
rightButtonsPanel.add(rightPlayerModul7);
|
||||
|
||||
// Spielfelder erstellen (eigenes und gegnerisches)
|
||||
int gridSize = 13 + semesterCounter; // Größe des Spielfelds
|
||||
JPanel ownBoardPanel = new JPanel(new GridLayout(gridSize, gridSize));
|
||||
JPanel opponentBoardPanel = new JPanel(new GridLayout(gridSize, gridSize));
|
||||
int gridSize = GameController.semesterToBoardSize(semesterCounter); // Größe des Spielfelds
|
||||
// Spielfelder werden in BoardDisplay erstellt
|
||||
//JPanel ownBoardPanel = new JPanel(new GridLayout(gridSize, gridSize));
|
||||
//JPanel opponentBoardPanel = new JPanel(new GridLayout(gridSize, gridSize));
|
||||
JPanel ownBoardPanel = new BoardDisplay(gridSize, gameBoardEmtpy);
|
||||
JPanel opponentBoardPanel = new BoardDisplay(gridSize, gameBoardEmtpy);
|
||||
|
||||
// Buttons für das eigene Spielfeld hinzufügen
|
||||
for (int i = 0; i < gridSize; i++) {
|
||||
for (int j = 0; j < gridSize; j++) {
|
||||
ownBoardPanel.add(new JButton(gameBoardEmtpy));
|
||||
}
|
||||
}
|
||||
//Buttons in eine Gruppe packen damit diese beim drücken eines anderen Buttons wieder entwählt werden
|
||||
ButtonGroup leftButtonGroup= new ButtonGroup();
|
||||
leftButtonGroup.add(rightPlayerModul1);
|
||||
leftButtonGroup.add(rightPlayerModul2);
|
||||
leftButtonGroup.add(rightPlayerModul3);
|
||||
leftButtonGroup.add(rightPlayerModul4);
|
||||
leftButtonGroup.add(rightPlayerModul5);
|
||||
leftButtonGroup.add(rightPlayerModul6);
|
||||
leftButtonGroup.add(rightPlayerModul7);
|
||||
|
||||
// Buttons für das gegnerische Spielfeld hinzufügen
|
||||
for (int i = 0; i < gridSize; i++) {
|
||||
for (int j = 0; j < gridSize; j++) {
|
||||
opponentBoardPanel.add(new JButton(gameBoardEmtpy));
|
||||
}
|
||||
}
|
||||
ButtonGroup rightButtonGroup= new ButtonGroup();
|
||||
rightButtonGroup.add(leftPlayerModul1);
|
||||
rightButtonGroup.add(leftPlayerModul2);
|
||||
rightButtonGroup.add(leftPlayerModul3);
|
||||
rightButtonGroup.add(leftPlayerModul4);
|
||||
rightButtonGroup.add(leftPlayerModul5);
|
||||
rightButtonGroup.add(leftPlayerModul6);
|
||||
rightButtonGroup.add(leftPlayerModul7);
|
||||
|
||||
// Panel für beide Spielfelder (nebeneinander in der Mitte)
|
||||
JPanel centerPanel = new JPanel();
|
||||
|
@ -99,7 +110,7 @@ public class GameBoard extends JPanel {
|
|||
add(centerPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
GameBoard(MainFrame frame,int semesterCounter) {
|
||||
GameBoard(MainFrame frame, int semesterCounter,Player p1, Player p2) {
|
||||
buildPanel(frame, semesterCounter);
|
||||
/*
|
||||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/*
|
||||
TODO: evtl an Lucas: die "JoinGame" muss noch informationen erhalten, welche Spieler erstellt wurden und welches Semester
|
||||
Also die startMultiplayerGame muss JoinGame mit parametern für (HumanPlayer/AiEasy/AiNormal/AiHard, Semesteranzahl, Spielername) (3 Parameter) erhalten
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public class JoinGame extends JPanel {
|
||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||
|
@ -51,5 +60,19 @@ public class JoinGame extends JPanel {
|
|||
|
||||
backButton.addActionListener(e -> frame.showPanel("MultiplayerGame"));
|
||||
losButton.addActionListener(e -> frame.showPanel("Verbinden"));
|
||||
/*
|
||||
losButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
frame.showPanel("Verbinden");
|
||||
//public static void startOnlineGame(Class<? extends LocalPlayer> localPlayerClass, String localPlayerName, InetSocketAddress
|
||||
// address, int size) throws IOException {
|
||||
if(playerType == 1) { //Beispiel (für playertape wäre z.B. 1 humanPlayer etc.)
|
||||
GameController.startOnlineGame(HumanPlayer.class, playerName, adress); //
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,8 @@ public class MainFrame extends JFrame {
|
|||
// Von startMultiplayerGame an JoinGame
|
||||
int localMult;
|
||||
|
||||
// Von startLocalGame an GameBoard
|
||||
// Von startLocalGame an startLocalGameLoadingScreen
|
||||
// Von startLocalGameLoadingScreen an GameBoard
|
||||
int semesterCounter;
|
||||
// ---------- //
|
||||
|
||||
|
@ -35,6 +36,7 @@ public class MainFrame extends JFrame {
|
|||
// Verschiedene Panels erstellen und hinzufügen
|
||||
MainMenuView mainMenuView = new MainMenuView(this);
|
||||
startLocalGame localGame = new startLocalGame(this);
|
||||
//startLocalGameLoadingScreen LocalGameLoadingScreen = new startLocalGameLoadingScreen(this);
|
||||
startMultiplayerGame multiplayerGame = new startMultiplayerGame(this);
|
||||
coinToss coinToss = new coinToss(this);
|
||||
Verbinden verbinden = new Verbinden(this);
|
||||
|
@ -60,6 +62,7 @@ public class MainFrame extends JFrame {
|
|||
public void showPanel(String panelName) {
|
||||
cardLayout.show(mainPanel, panelName);
|
||||
}
|
||||
|
||||
// --- ShowPanel der startMultiplayerGame Klasse
|
||||
public void showPanelSMG(String panelName, int num) {
|
||||
this.localMult = num;
|
||||
|
@ -73,12 +76,14 @@ public class MainFrame extends JFrame {
|
|||
|
||||
cardLayout.show(mainPanel, panelName); // Show the panel
|
||||
}
|
||||
// --- ShowPanel der startLocalGame Klasse
|
||||
public void showPanelSLG(String panelName,int semesterCounter) {
|
||||
this.semesterCounter = semesterCounter;
|
||||
// --- ShowPanel der startLocalGameLoadingScreen Klasse (DURCH BACKEND AUFGERUFEN)
|
||||
public void showPanelSLG(String panelName,int semesterCounter, Player p1, Player p2) {
|
||||
this.semesterCounter = semesterCounter;
|
||||
|
||||
//if (!isPanelPresent(panelName)) { //TODO potentiell raus
|
||||
GameBoard gameBoard = new GameBoard(this, semesterCounter);
|
||||
//if (!isPanelPresent(panelName)) { //TODO potentiell raus
|
||||
// gameBoard muss player übergeben bekommen
|
||||
GameBoard gameBoard = new GameBoard(this, semesterCounter, p1, p2);
|
||||
//mainPanel.add(mainMenuView, "MainMenu");
|
||||
mainPanel.add(gameBoard, panelName);
|
||||
mainPanel.revalidate(); // Refresh
|
||||
mainPanel.repaint();
|
||||
|
@ -86,6 +91,20 @@ public class MainFrame extends JFrame {
|
|||
|
||||
cardLayout.show(mainPanel, panelName); // Show the panel
|
||||
}
|
||||
|
||||
// --- ShowPanel der startLocalGame Klasse
|
||||
public void showPanelSLGLS(String panelName,int semesterCounter) {
|
||||
this.semesterCounter = semesterCounter;
|
||||
// gameBoard muss player übergeben bekommen
|
||||
startLocalGameLoadingScreen LocalGameLoadingScreen = new startLocalGameLoadingScreen(this, semesterCounter);
|
||||
mainPanel.add(LocalGameLoadingScreen, panelName);
|
||||
mainPanel.revalidate(); // Refresh
|
||||
mainPanel.repaint();
|
||||
//}
|
||||
|
||||
cardLayout.show(mainPanel, panelName); // Show the panel
|
||||
}
|
||||
|
||||
/* TODO ist dies unnötig?
|
||||
private boolean isPanelPresent(String panelName) {
|
||||
for (Component component : mainPanel.getComponents()) {
|
||||
|
@ -96,6 +115,20 @@ public class MainFrame extends JFrame {
|
|||
return false;
|
||||
} */
|
||||
|
||||
// Methoden für übergabe von playern an GameBoard
|
||||
/*
|
||||
public void setPlayerData() {
|
||||
this.semesterCounter = semesterCounter;
|
||||
|
||||
//if (!isPanelPresent(panelName)) { //TODO potentiell raus
|
||||
// gameBoard muss player übergeben bekommen
|
||||
GameBoard gameBoard = new GameBoard(this, semesterCounter);
|
||||
mainPanel.add(gameBoard, panelName);
|
||||
mainPanel.revalidate(); // Refresh
|
||||
mainPanel.repaint();
|
||||
}*/
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
MainFrame frame = new MainFrame();
|
||||
|
|
|
@ -2,16 +2,26 @@ import javax.swing.*;
|
|||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
// TODO
|
||||
// Evtl. ist Namen selber setzten noch unmöglich
|
||||
//
|
||||
|
||||
public class startLocalGame extends JPanel {
|
||||
// Player
|
||||
Player p1;
|
||||
Player p2;
|
||||
|
||||
// Funktionshilfen
|
||||
int semesterCounter = 1; // Semester Counter Label
|
||||
String leftPlayerNickname = "Spieler 1";
|
||||
String rightPlayerNickname = "Spieler 2";
|
||||
String rightPlayerNickname = "Einfach";
|
||||
|
||||
// Grafiken
|
||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
||||
ImageIcon aiPlayerEasyIcon = new ImageIcon("graphics/botPlayerEasy.png");
|
||||
ImageIcon aiPlayerNormalIcon = new ImageIcon("graphics/botPlayerNormal.png");
|
||||
ImageIcon aiPlayerHardIcon = new ImageIcon("graphics/botPlayerHard.png");
|
||||
|
||||
// Labels und Buttons
|
||||
JLabel frameTitle = new JLabel("Lokales Spiel");
|
||||
|
@ -19,7 +29,7 @@ public class startLocalGame extends JPanel {
|
|||
JLabel leftPlayerName = new JLabel("Name");
|
||||
JLabel rightPlayerName = new JLabel("KI-Level");
|
||||
JLabel leftPlayerIcon = new JLabel(humanPlayerIcon);
|
||||
JLabel rightPlayerIcon = new JLabel(aiPlayerIcon);
|
||||
JLabel rightPlayerIcon = new JLabel(aiPlayerEasyIcon);
|
||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
||||
|
||||
JButton backButton = new JButton(backButtonIcon);
|
||||
|
@ -30,6 +40,7 @@ public class startLocalGame extends JPanel {
|
|||
JButton rightPlayerLeftButton = new JButton("<-");
|
||||
JButton rightPlayerRightButton = new JButton("->");
|
||||
JButton startButton = new JButton("Start!");
|
||||
JButton testButton = new JButton("Test");
|
||||
|
||||
JTextField leftPlayerTextField = new JTextField(20);
|
||||
JTextField rightPlayerTextField = new JTextField(20);
|
||||
|
@ -61,6 +72,9 @@ public class startLocalGame extends JPanel {
|
|||
semesterCounterLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
add(semesterCounterLabel);
|
||||
|
||||
testButton.setBounds(500,800,50,50);
|
||||
add(testButton);
|
||||
|
||||
backButton.setBounds(1380, 20, 80, 80);
|
||||
add(backButton);
|
||||
|
||||
|
@ -93,6 +107,7 @@ public class startLocalGame extends JPanel {
|
|||
rightPlayerTextField.setText(rightPlayerNickname);
|
||||
add(rightPlayerTextField);
|
||||
|
||||
|
||||
// ActionListener für Buttons
|
||||
semesterUpButton.addActionListener(e -> {
|
||||
if (semesterCounter < 6) {
|
||||
|
@ -111,7 +126,7 @@ public class startLocalGame extends JPanel {
|
|||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleLeftPlayerIcon();
|
||||
toggleLeftPlayerIconLeft();
|
||||
updateTextFields();
|
||||
}
|
||||
});
|
||||
|
@ -119,7 +134,7 @@ public class startLocalGame extends JPanel {
|
|||
leftPlayerRightButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleLeftPlayerIcon();
|
||||
toggleLeftPlayerIconRight();
|
||||
updateTextFields();
|
||||
}
|
||||
});
|
||||
|
@ -127,7 +142,7 @@ public class startLocalGame extends JPanel {
|
|||
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleRightPlayerIcon();
|
||||
toggleRightPlayerIconLeft();
|
||||
updateTextFields();
|
||||
}
|
||||
});
|
||||
|
@ -135,29 +150,98 @@ public class startLocalGame extends JPanel {
|
|||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleRightPlayerIcon();
|
||||
toggleRightPlayerIconRight();
|
||||
updateTextFields();
|
||||
}
|
||||
});
|
||||
|
||||
backButton.addActionListener(e -> frame.showPanel("MainMenu"));
|
||||
testButton.addActionListener(e -> frame.showPanelSLG("GameBoard",1,p1,p2));
|
||||
//startButton.addActionListener(e -> frame.showPanelSLG("GameBoard", semesterCounter,p1, p2)); // TODO ECHTE FUNKTION EINFÜGEN
|
||||
startButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
frame.showPanelSLGLS("startLocalGameLoadingScreen", semesterCounter); //TODO
|
||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {// TODO Wird name wirklich weitergegeben?
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerEasy.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerMedium.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerHard.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
}
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerEasy.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerMedium.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerHard.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
}
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerEasy.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerMedium.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerHard.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
}
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerEasy.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerMedium.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
GameController.startLocalGame(HumanPlayer.class, leftPlayerNickname, SpecificAiPlayerHard.class, GameController.semesterToBoardSize(semesterCounter));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
startButton.addActionListener(e -> frame.showPanelSLG("GameBoard", semesterCounter)); // TODO ECHTE FUNKTION EINFÜGEN
|
||||
}
|
||||
|
||||
private void toggleLeftPlayerIcon() {
|
||||
private void toggleLeftPlayerIconLeft() {
|
||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
leftPlayerIcon.setIcon(aiPlayerIcon);
|
||||
} else {
|
||||
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleLeftPlayerIconRight() {
|
||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRightPlayerIcon() {
|
||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
rightPlayerIcon.setIcon(aiPlayerIcon);
|
||||
} else {
|
||||
rightPlayerIcon.setIcon(humanPlayerIcon);
|
||||
private void toggleRightPlayerIconLeft() {
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
||||
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRightPlayerIconRight() {
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
||||
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,15 +250,21 @@ public class startLocalGame extends JPanel {
|
|||
// Linker Spieler
|
||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
leftPlayerTextField.setText("Spieler 1");
|
||||
} else {
|
||||
leftPlayerTextField.setText("Leicht");
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
leftPlayerTextField.setText("Einfach");
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
leftPlayerTextField.setText("Mittel");
|
||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
leftPlayerTextField.setText("Schwer");
|
||||
}
|
||||
|
||||
// Rechter Spieler
|
||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
rightPlayerTextField.setText("Spieler 2");
|
||||
} else {
|
||||
rightPlayerTextField.setText("Leicht");
|
||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
rightPlayerTextField.setText("Einfach");
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
rightPlayerTextField.setText("Mittel");
|
||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
rightPlayerTextField.setText("Schwer");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
//Kann evtl. als genereller LoadingScreen verwendet werden und nicht "nur" für localGame
|
||||
public class startLocalGameLoadingScreen extends JPanel{
|
||||
startLocalGameLoadingScreen(MainFrame frame, int semesterCounter) {
|
||||
// Layout setzen
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Label mit dem Text erstellen
|
||||
JLabel loadingLabel = new JLabel("Spiel wird gestartet, bitte warten...");
|
||||
loadingLabel.setHorizontalAlignment(SwingConstants.CENTER); // Horizontal zentrieren
|
||||
loadingLabel.setVerticalAlignment(SwingConstants.CENTER); // Vertikal zentrieren
|
||||
|
||||
// Schriftgröße anpassen (optional)
|
||||
loadingLabel.setFont(new Font("Arial", Font.PLAIN, 18));
|
||||
|
||||
// Label zum Panel hinzufügen
|
||||
add(loadingLabel, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
import javax.swing.*;
|
||||
|
||||
// TODO
|
||||
// Evtl. ist Namen selber setzten noch unmöglich
|
||||
//
|
||||
|
||||
public class startMultiplayerGame extends JPanel {
|
||||
// Funktionshilfen
|
||||
int semesterCounter = 1; // Semester Counter Label
|
||||
|
@ -7,7 +11,9 @@ public class startMultiplayerGame extends JPanel {
|
|||
// Grafiken
|
||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
||||
ImageIcon aiPlayerEasyIcon = new ImageIcon("graphics/botPlayerEasy.png");
|
||||
ImageIcon aiPlayerNormalIcon = new ImageIcon("graphics/botPlayerNormal.png");
|
||||
ImageIcon aiPlayerHardIcon = new ImageIcon("graphics/botPlayerHard.png");
|
||||
|
||||
// Labels
|
||||
JLabel frameTitle = new JLabel("Multiplayer Spiel");
|
||||
|
@ -76,7 +82,16 @@ public class startMultiplayerGame extends JPanel {
|
|||
PlayerTextField.setText(PlayerNickname);
|
||||
add(PlayerTextField);
|
||||
|
||||
// ActionListener für Buttons
|
||||
/* TODO: Muss in Lucas klasse rein.
|
||||
public static void startOnlineGame(Class<? extends LocalPlayer> localPlayerClass, String localPlayerName, InetSocketAddress
|
||||
address, int size) throws IOException {
|
||||
*/
|
||||
|
||||
//GameController.startOnlineGame(...);
|
||||
|
||||
|
||||
|
||||
// ActionListener für Buttons
|
||||
// SEMESTERBUTTONS
|
||||
semesterUpButton.addActionListener(e -> {
|
||||
if (semesterCounter < 6) {
|
||||
|
@ -94,12 +109,12 @@ public class startMultiplayerGame extends JPanel {
|
|||
|
||||
// PLAYERTOGGLEBUTTONS
|
||||
PlayerLeftButton.addActionListener(e -> {
|
||||
toggleLeftPlayerIcon();
|
||||
togglePlayerIconLeft();
|
||||
updateTextFields();
|
||||
});
|
||||
|
||||
PlayerRightButton.addActionListener(e -> {
|
||||
toggleLeftPlayerIcon();
|
||||
togglePlayerIconRight();
|
||||
updateTextFields();
|
||||
});
|
||||
|
||||
|
@ -111,19 +126,39 @@ public class startMultiplayerGame extends JPanel {
|
|||
}
|
||||
|
||||
// TOGGLE METHODEN
|
||||
private void toggleLeftPlayerIcon() {
|
||||
private void togglePlayerIconLeft() {
|
||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerIcon);
|
||||
} else {
|
||||
PlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
PlayerIcon.setIcon(humanPlayerIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void togglePlayerIconRight() {
|
||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerHardIcon);
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
PlayerIcon.setIcon(humanPlayerIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTextFields() {
|
||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
PlayerTextField.setText(PlayerNickname);
|
||||
} else {
|
||||
PlayerTextField.setText("Leicht");
|
||||
PlayerTextField.setText("Spieler 1");
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||
PlayerTextField.setText("Einfach");
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||
PlayerTextField.setText("Mittel");
|
||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||
PlayerTextField.setText("Schwer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue