Compare commits
No commits in common. "d00e12e72ff06b91069bff5029dcb201210df3f0" and "ce4995fb94e3fe8ed3c5e5e75b4991f1056aa9ce" have entirely different histories.
d00e12e72f
...
ce4995fb94
|
@ -2,7 +2,6 @@
|
||||||
<library name="jlayer-1.0.3">
|
<library name="jlayer-1.0.3">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$USER_HOME$/Downloads/jlayer-master/jlayer-master/target/jlayer-1.0.3.jar!/" />
|
<root url="jar://$USER_HOME$/Downloads/jlayer-master/jlayer-master/target/jlayer-1.0.3.jar!/" />
|
||||||
<root url="jar://$USER_HOME$/Downloads/jlayer-1.0.3.jar!/" />
|
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Palette2">
|
|
||||||
<group name="Swing">
|
|
||||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Button" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="RadioButton" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="CheckBox" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Label" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
|
||||||
<preferred-size width="-1" height="20" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
Binary file not shown.
Before Width: | Height: | Size: 668 B |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 829 B |
Binary file not shown.
Before Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 959 B |
|
@ -1,27 +1,7 @@
|
||||||
import java.util.Random;
|
|
||||||
import java.awt.Point;
|
|
||||||
|
|
||||||
public abstract class AiPlayer extends Player {
|
public abstract class AiPlayer extends Player {
|
||||||
|
|
||||||
public AiPlayer(int size) {
|
public AiPlayer(int size) {
|
||||||
super(size);
|
super(size);
|
||||||
}
|
}
|
||||||
public Point RandomPoint() {
|
}
|
||||||
Random random = new Random(); // Pseudo Random für zufallszahlen
|
|
||||||
int posx = random.nextInt(super.board.size); // Generiert 0 - 13
|
|
||||||
int posy = random.nextInt(super.board.size); //
|
|
||||||
return new Point(posx,posy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AiSetShips() {
|
|
||||||
for(int i = 0; i < super.board.ships.size(); i++) { // Interiert durch alle Shiffe
|
|
||||||
while(!super.board.ships.get(i).setPosition(RandomPoint()))
|
|
||||||
} // Versucht das Aktuelle Shiff zu setzten und wiederholt solange bis es funktioniert
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AiShoot() {
|
|
||||||
super.board.hit(RandomPoint());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -67,9 +67,6 @@ public class Board {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
public class GameBoard {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +1,10 @@
|
||||||
public class HalloSchiffeVersenken {
|
public class HalloSchiffeVersenken {
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
MainFrame mf = new MainFrame();
|
|
||||||
mf.setVisible(true);
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
System.out.println("HelloSchiffeVersenekn");
|
System.out.println("HelloSchiffeVersenekn");
|
||||||
|
|
||||||
|
|
||||||
System.out.println("sound");
|
System.out.println("sound");
|
||||||
SoundHandler.playSound("hit");
|
SoundHandler.playSound("hit");
|
||||||
|
|
||||||
|
@ -15,7 +13,7 @@ public class HalloSchiffeVersenken {
|
||||||
SoundHandler.setSoundOn(false);
|
SoundHandler.setSoundOn(false);
|
||||||
System.out.println("sound off");
|
System.out.println("sound off");
|
||||||
SoundHandler.playSound("hit");
|
SoundHandler.playSound("hit");
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class JoinGame extends JPanel {
|
|
||||||
JLabel spielBeitretenLabel= new JLabel("Spiel beitreten");
|
|
||||||
JLabel ipLabel = new JLabel("IP-Adresse");
|
|
||||||
JLabel portLabel = new JLabel("Port");
|
|
||||||
|
|
||||||
JTextField ipTextField = new JTextField(20);
|
|
||||||
JTextField portTextField = new JTextField(20);
|
|
||||||
|
|
||||||
JButton losButton = new JButton("Los!");
|
|
||||||
|
|
||||||
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
|
||||||
|
|
||||||
public JoinGame(MainFrame frame) {
|
|
||||||
setLayout(null);
|
|
||||||
buildPanel(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPanel(MainFrame frame) {
|
|
||||||
spielBeitretenLabel.setBounds(20,20,700, 100);
|
|
||||||
losButton.setBounds(320, 225, 100, 50);
|
|
||||||
|
|
||||||
ipLabel.setBounds(50, 125, 200, 30);
|
|
||||||
portLabel.setBounds(50, 200, 200, 30);
|
|
||||||
|
|
||||||
ipTextField.setBounds(50, 150, 250, 50);
|
|
||||||
portTextField.setBounds(50, 225, 250, 50);
|
|
||||||
|
|
||||||
|
|
||||||
spielBeitretenLabel.setFont(robotoFont.deriveFont(50f));
|
|
||||||
|
|
||||||
add(spielBeitretenLabel);
|
|
||||||
add(ipLabel);
|
|
||||||
add(portLabel);
|
|
||||||
add(losButton);
|
|
||||||
add(ipTextField);
|
|
||||||
add(portTextField);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class MainFrame extends JFrame {
|
|
||||||
|
|
||||||
private CardLayout cardLayout;
|
|
||||||
private JPanel mainPanel;
|
|
||||||
|
|
||||||
public MainFrame() {
|
|
||||||
setTitle("Studium Versenken");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setSize(1500, 1000);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
|
|
||||||
//JLabel backgroundLabel = new JLabel(new ImageIcon("graphics/mainmenubackground.png"));
|
|
||||||
// backgroundLabel.setBounds(0, 0, 1500, 1000);
|
|
||||||
// getContentPane().add(backgroundLabel);
|
|
||||||
|
|
||||||
// backgroundLabel.setOpaque(true);
|
|
||||||
|
|
||||||
// CardLayout und Hauptpanel erstellen
|
|
||||||
cardLayout = new CardLayout();
|
|
||||||
mainPanel = new JPanel(cardLayout);
|
|
||||||
|
|
||||||
// Verschiedene Panels erstellen und hinzufügen
|
|
||||||
MainMenuView mainMenuView = new MainMenuView(this);
|
|
||||||
startLocalGame localGame = new startLocalGame(this);
|
|
||||||
startMultiplayerGame multiplayerGame = new startMultiplayerGame(this);
|
|
||||||
coinToss coinToss = new coinToss(this);
|
|
||||||
JoinGame joinGame = new JoinGame(this);
|
|
||||||
|
|
||||||
mainPanel.add(mainMenuView, "MainMenu");
|
|
||||||
mainPanel.add(localGame, "LocalGame");
|
|
||||||
mainPanel.add(multiplayerGame, "MultiplayerGame");
|
|
||||||
mainPanel.add(coinToss, "coinToss");
|
|
||||||
mainPanel.add(joinGame, "JoinGame");
|
|
||||||
// Hauptpanel in JFrame hinzufügen
|
|
||||||
add(mainPanel);
|
|
||||||
|
|
||||||
// Hauptmenü anzeigen
|
|
||||||
cardLayout.show(mainPanel, "MainMenu");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode, um die Ansicht zu wechseln
|
|
||||||
public void showPanel(String panelName) {
|
|
||||||
cardLayout.show(mainPanel, panelName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
MainFrame frame = new MainFrame();
|
|
||||||
frame.setVisible(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MainMenuController implements ActionListener {
|
|
||||||
private MainMenuView view;
|
|
||||||
private MainMenuModel model;
|
|
||||||
|
|
||||||
public MainMenuController(MainMenuModel model, MainMenuView view) {
|
|
||||||
this.view = view;
|
|
||||||
this.model = model;
|
|
||||||
//this.view.getLocalButton().addActionListener(this);
|
|
||||||
//this.view.getMultiButton().addActionListener(this);
|
|
||||||
// this.view.getSoundButton().addActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
//if (e.getSource() == view.getMultiButton()) {
|
|
||||||
// model.setGameMode("Multiplayer");
|
|
||||||
// MultiMenuModel multiModel = new MultiMenuModel();
|
|
||||||
// MultiMenuView multiView = new MultiMenuView();
|
|
||||||
// MultiMenuController multiMenuController = new MultiMenuController(multiModel, multiView);
|
|
||||||
// view.addPanel(multiView.getMultiPanel(), "MultiMenu");
|
|
||||||
// view.showPanel("MultiMenu");
|
|
||||||
// }else if (e.getSource() == view.getSoundButton()) {
|
|
||||||
// view.toggleMute();
|
|
||||||
// }else if(e.getSource() == view.getLocalButton()) {
|
|
||||||
model.setGameMode("LocalGame");
|
|
||||||
//startLocalGame localGame = new startLocalGame();
|
|
||||||
// view.addPanel(localGame.getLocalPanel(), "LocalMenu");
|
|
||||||
// view.showPanel("LocalMenu");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}
|
|
|
@ -1,11 +0,0 @@
|
||||||
public class MainMenuModel {
|
|
||||||
private String gameMode;
|
|
||||||
|
|
||||||
public void setGameMode(String mode) {
|
|
||||||
this.gameMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGameMode() {
|
|
||||||
return gameMode;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MainMenuView extends JPanel {
|
|
||||||
|
|
||||||
private JLabel titelLabel = new JLabel("Studium versenken");
|
|
||||||
private JButton lokalButton = new JButton("Lokal");
|
|
||||||
private JButton multiButton = new JButton("Multiplayer");
|
|
||||||
private JButton soundButton;
|
|
||||||
|
|
||||||
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
|
||||||
private ImageIcon soundIcon = new ImageIcon("graphics/sound button.png");
|
|
||||||
private ImageIcon muteIcon = new ImageIcon("graphics/sound button muted.png");
|
|
||||||
|
|
||||||
public MainMenuView(MainFrame frame) {
|
|
||||||
setLayout(null);
|
|
||||||
buildPanel(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPanel(MainFrame frame) {
|
|
||||||
lokalButton.setBounds(200, 200, 500, 500);
|
|
||||||
multiButton.setBounds(800, 200, 500, 500);
|
|
||||||
titelLabel.setBounds(550, 10, 700, 100);
|
|
||||||
soundButton = new JButton(soundIcon);
|
|
||||||
soundButton.setBounds(20, 20, 128, 128);
|
|
||||||
|
|
||||||
titelLabel.setFont(robotoFont);
|
|
||||||
lokalButton.setFont(robotoFont.deriveFont(50f));
|
|
||||||
multiButton.setFont(robotoFont.deriveFont(50f));
|
|
||||||
|
|
||||||
add(titelLabel);
|
|
||||||
add(lokalButton);
|
|
||||||
add(multiButton);
|
|
||||||
add(soundButton);
|
|
||||||
|
|
||||||
// Event Listener für Buttons
|
|
||||||
lokalButton.addActionListener(e -> frame.showPanel("LocalGame"));
|
|
||||||
multiButton.addActionListener(e -> frame.showPanel("MultiplayerGame"));
|
|
||||||
soundButton.addActionListener(e -> toggleMute());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleMute() {
|
|
||||||
if (soundButton.getIcon() == soundIcon) {
|
|
||||||
soundButton.setIcon(muteIcon);
|
|
||||||
} else {
|
|
||||||
soundButton.setIcon(soundIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MultiMenuController implements ActionListener {
|
|
||||||
private MultiMenuView view;
|
|
||||||
private MultiMenuModel model;
|
|
||||||
|
|
||||||
public MultiMenuController(MultiMenuModel model, MultiMenuView view) {
|
|
||||||
this.view = view;
|
|
||||||
this.model = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (e.getSource() == view.getPlayerLeftButton()){
|
|
||||||
view.togglePlayerIcon();
|
|
||||||
}else if(e.getSource() == view.getPlayerRightButton()){
|
|
||||||
view.togglePlayerIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
public class MultiMenuModel {
|
|
||||||
private String gameMode;
|
|
||||||
|
|
||||||
public void setGameMode(String mode) {
|
|
||||||
this.gameMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGameMode() {
|
|
||||||
return gameMode;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
import java.awt.*;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MultiMenuView {
|
|
||||||
int semesterCounter = 1;
|
|
||||||
private JPanel multiPanel = new JPanel(null);
|
|
||||||
|
|
||||||
private ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
|
||||||
private ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
|
||||||
|
|
||||||
JButton PlayerLeftButton = new JButton("<-");
|
|
||||||
JButton PlayerRightButton = new JButton("->");
|
|
||||||
JButton semesterUpButton = new JButton("^");
|
|
||||||
JButton semesterDownButton = new JButton("v");
|
|
||||||
|
|
||||||
JLabel semesterLabel = new JLabel("Semester");
|
|
||||||
private JLabel titelLabel = new JLabel("Multiplayer");
|
|
||||||
private JLabel PlayerIcon = new JLabel(humanPlayerIcon);
|
|
||||||
private JLabel PlayerName = new JLabel("Name");
|
|
||||||
private JTextField PlayerTextField = new JTextField(20);
|
|
||||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
|
||||||
|
|
||||||
private Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
|
||||||
public MultiMenuView() {
|
|
||||||
buildPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void buildPanel(){
|
|
||||||
titelLabel.setBounds(20,20,700,100);
|
|
||||||
PlayerIcon.setBounds(75, 400, 200, 128);
|
|
||||||
PlayerName.setBounds(50, 625, 200, 30);
|
|
||||||
PlayerTextField.setBounds(50, 650, 250, 50);
|
|
||||||
semesterCounterLabel.setBounds(725, 475, 50, 50); // zwischen den Up/Down-Buttons
|
|
||||||
PlayerLeftButton.setBounds(50, 450, 50, 50);
|
|
||||||
PlayerRightButton.setBounds(250, 450, 50, 50);
|
|
||||||
semesterLabel.setBounds(500, 400, 200, 30);
|
|
||||||
semesterUpButton.setBounds(700, 400, 50, 50);
|
|
||||||
semesterDownButton.setBounds(700, 550, 50, 50);
|
|
||||||
|
|
||||||
|
|
||||||
multiPanel.setLayout(null);
|
|
||||||
titelLabel.setFont(robotoFont.deriveFont(50f));
|
|
||||||
semesterLabel.setFont(robotoFont.deriveFont(20f));
|
|
||||||
|
|
||||||
multiPanel.add(PlayerName);
|
|
||||||
multiPanel.add(titelLabel);
|
|
||||||
multiPanel.add(PlayerIcon);
|
|
||||||
multiPanel.add(PlayerTextField);
|
|
||||||
multiPanel.add(semesterCounterLabel);
|
|
||||||
multiPanel.add(semesterUpButton);
|
|
||||||
multiPanel.add(semesterDownButton);
|
|
||||||
multiPanel.add(PlayerLeftButton);
|
|
||||||
multiPanel.add(PlayerRightButton);
|
|
||||||
multiPanel.add(semesterLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getMultiPanel() {
|
|
||||||
return multiPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
//public void showMultiPanel(String panelName) {
|
|
||||||
// CardLayout cl = (CardLayout)mainPanel.getLayout();
|
|
||||||
// cl.show(multiPanel, panelName);
|
|
||||||
//}
|
|
||||||
|
|
||||||
public void togglePlayerIcon() {
|
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
PlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
PlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getPlayerLeftButton() {
|
|
||||||
return PlayerLeftButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getPlayerRightButton() {
|
|
||||||
return PlayerRightButton;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
public class SpecificAiPlayer1 extends AiPlayer{
|
|
||||||
|
|
||||||
public SpecificAiPlayer1(int size) {
|
|
||||||
super(size);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
|
|
||||||
public class SpecificAiPlayerMedium extends AiPlayer{
|
|
||||||
|
|
||||||
private List<Point> hitsQueue = new ArrayList<>();
|
|
||||||
|
|
||||||
public SpecificAiPlayerMedium(int size) {
|
|
||||||
super(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void AiShoot() {
|
|
||||||
Point nextShot = ComputeNextShot();
|
|
||||||
// Shoot at the enemy and receive the hit response
|
|
||||||
enemy.receiveShoot(nextShot);
|
|
||||||
|
|
||||||
HitResponse hitResponse = enemy.board.getHitResponsOnPoint(nextShot)
|
|
||||||
// If it's a hit or sunk, add adjacent cells to the hitsQueue
|
|
||||||
if (hitResponse.getHitResponse() == HitResponseType.HIT) {
|
|
||||||
addAdjacentPoints(nextShot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point ComputeNextShot() {
|
|
||||||
Point nextShot;
|
|
||||||
|
|
||||||
// Prioritize shots from the hitsQueue
|
|
||||||
while (!hitsQueue.isEmpty()) {
|
|
||||||
nextShot = hitsQueue.remove(0);
|
|
||||||
if (!alreadyShot(nextShot)) {
|
|
||||||
return nextShot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If hitsQueue is empty, pick a random point that hasn't been shot
|
|
||||||
do {
|
|
||||||
nextShot = RandomPoint();
|
|
||||||
} while (alreadyShot(nextShot));
|
|
||||||
|
|
||||||
return nextShot;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAdjacentPoints(Point point) {
|
|
||||||
int x = point.x;
|
|
||||||
int y = point.y;
|
|
||||||
|
|
||||||
// Possible adjacent positions (up, down, left, right)
|
|
||||||
Point[] adjacentPoints = {
|
|
||||||
new Point(x, y - 1),
|
|
||||||
new Point(x, y + 1),
|
|
||||||
new Point(x - 1, y),
|
|
||||||
new Point(x + 1, y)
|
|
||||||
};
|
|
||||||
|
|
||||||
for (Point p : adjacentPoints) {
|
|
||||||
if (isValidPoint(p) && !alreadyShot(p) && !hitsQueue.contains(p)) {
|
|
||||||
hitsQueue.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isValidPoint(Point point) {
|
|
||||||
return point.x >= 0 && point.x < board.getSize() &&
|
|
||||||
point.y >= 0 && point.y < board.getSize();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class coinToss extends JPanel {
|
|
||||||
private int reihenfolge = 1; // 1 = Spieler 1 fängt an, 0 = Spieler 2 fängt an
|
|
||||||
private Timer timer;
|
|
||||||
private JLabel infoLabel;
|
|
||||||
|
|
||||||
// Konstruktor
|
|
||||||
public coinToss(MainFrame frame) {
|
|
||||||
setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
// Info-Label für den Anzeigetext
|
|
||||||
infoLabel = new JLabel("", SwingConstants.CENTER);
|
|
||||||
infoLabel.setFont(new Font("Arial", Font.BOLD, 24));
|
|
||||||
add(infoLabel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// Bestimme den Anfangstext basierend auf der "reihenfolge" Variable
|
|
||||||
if (reihenfolge == 1) {
|
|
||||||
infoLabel.setText("Du fängst an, mach dich bereit...");
|
|
||||||
} else {
|
|
||||||
infoLabel.setText("Dein Gegner fängt an, mach dich bereit...");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erster Timer, der den Text nach 3 Sekunden auf "Es geht Los!" setzt
|
|
||||||
/*timer = new Timer(3000, e -> {
|
|
||||||
infoLabel.setText("Es geht Los!");
|
|
||||||
|
|
||||||
// Zweiter Timer, der nach weiteren 3 Sekunden zum Hauptmenü zurückkehrt
|
|
||||||
Timer backToMenuTimer = new Timer(3000, ev -> {
|
|
||||||
frame.showPanel("MainMenu");
|
|
||||||
});
|
|
||||||
//backToMenuTimer.setRepeats(false); // Timer nur einmal ausführen
|
|
||||||
backToMenuTimer.start();
|
|
||||||
});
|
|
||||||
//timer.setRepeats(false); // Erster Timer soll nur einmal ausgeführt werden
|
|
||||||
timer.start();*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,181 +0,0 @@
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
public class startLocalGame extends JPanel {
|
|
||||||
// Funktionshilfen
|
|
||||||
int semesterCounter = 1; // Semester Counter Label
|
|
||||||
String leftPlayerNickname = "Spieler 1";
|
|
||||||
String rightPlayerNickname = "Spieler 2";
|
|
||||||
|
|
||||||
// Grafiken
|
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
|
||||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
|
||||||
|
|
||||||
// Labels und Buttons
|
|
||||||
JLabel frameTitle = new JLabel("Lokales Spiel");
|
|
||||||
JLabel semesterLabel = new JLabel("Semester");
|
|
||||||
JLabel leftPlayerName = new JLabel("Name");
|
|
||||||
JLabel rightPlayerName = new JLabel("KI-Level");
|
|
||||||
JLabel leftPlayerIcon = new JLabel(humanPlayerIcon);
|
|
||||||
JLabel rightPlayerIcon = new JLabel(aiPlayerIcon);
|
|
||||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
|
||||||
|
|
||||||
JButton backButton = new JButton(backButtonIcon);
|
|
||||||
JButton leftPlayerLeftButton = new JButton("<-");
|
|
||||||
JButton leftPlayerRightButton = new JButton("->");
|
|
||||||
JButton semesterUpButton = new JButton("^");
|
|
||||||
JButton semesterDownButton = new JButton("v");
|
|
||||||
JButton rightPlayerLeftButton = new JButton("<-");
|
|
||||||
JButton rightPlayerRightButton = new JButton("->");
|
|
||||||
JButton startButton = new JButton("Start!");
|
|
||||||
|
|
||||||
JTextField leftPlayerTextField = new JTextField(20);
|
|
||||||
JTextField rightPlayerTextField = new JTextField(20);
|
|
||||||
|
|
||||||
// Methode zur Erstellung des Panels
|
|
||||||
startLocalGame(MainFrame frame) {
|
|
||||||
setLayout(null); // Stelle das Layout des Panels ein
|
|
||||||
|
|
||||||
// Setze Komponentenpositionen
|
|
||||||
frameTitle.setBounds(20, 20, 200, 30);
|
|
||||||
add(frameTitle);
|
|
||||||
|
|
||||||
semesterLabel.setBounds(700, 300, 200, 30);
|
|
||||||
add(semesterLabel);
|
|
||||||
|
|
||||||
leftPlayerName.setBounds(50, 625, 200, 30);
|
|
||||||
add(leftPlayerName);
|
|
||||||
|
|
||||||
rightPlayerName.setBounds(1200, 625, 200, 30);
|
|
||||||
add(rightPlayerName);
|
|
||||||
|
|
||||||
leftPlayerIcon.setBounds(75, 400, 200, 128);
|
|
||||||
add(leftPlayerIcon);
|
|
||||||
|
|
||||||
rightPlayerIcon.setBounds(1225, 400, 200, 128);
|
|
||||||
add(rightPlayerIcon);
|
|
||||||
|
|
||||||
semesterCounterLabel.setBounds(725, 475, 50, 50);
|
|
||||||
semesterCounterLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
add(semesterCounterLabel);
|
|
||||||
|
|
||||||
backButton.setBounds(1380, 20, 80, 80);
|
|
||||||
add(backButton);
|
|
||||||
|
|
||||||
leftPlayerLeftButton.setBounds(50, 450, 50, 50);
|
|
||||||
add(leftPlayerLeftButton);
|
|
||||||
|
|
||||||
leftPlayerRightButton.setBounds(250, 450, 50, 50);
|
|
||||||
add(leftPlayerRightButton);
|
|
||||||
|
|
||||||
semesterUpButton.setBounds(725, 400, 50, 50);
|
|
||||||
add(semesterUpButton);
|
|
||||||
|
|
||||||
semesterDownButton.setBounds(725, 550, 50, 50);
|
|
||||||
add(semesterDownButton);
|
|
||||||
|
|
||||||
rightPlayerLeftButton.setBounds(1200, 450, 50, 50);
|
|
||||||
add(rightPlayerLeftButton);
|
|
||||||
|
|
||||||
rightPlayerRightButton.setBounds(1400, 450, 50, 50);
|
|
||||||
add(rightPlayerRightButton);
|
|
||||||
|
|
||||||
startButton.setBounds(700, 750, 100, 50);
|
|
||||||
add(startButton);
|
|
||||||
|
|
||||||
leftPlayerTextField.setBounds(50, 650, 250, 50);
|
|
||||||
leftPlayerTextField.setText(leftPlayerNickname);
|
|
||||||
add(leftPlayerTextField);
|
|
||||||
|
|
||||||
rightPlayerTextField.setBounds(1200, 650, 250, 50);
|
|
||||||
rightPlayerTextField.setText(rightPlayerNickname);
|
|
||||||
add(rightPlayerTextField);
|
|
||||||
|
|
||||||
// ActionListener für Buttons
|
|
||||||
semesterUpButton.addActionListener(e -> {
|
|
||||||
if (semesterCounter < 6) {
|
|
||||||
semesterCounter++;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
semesterDownButton.addActionListener(e -> {
|
|
||||||
if (semesterCounter > 1) {
|
|
||||||
semesterCounter--;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
leftPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleRightPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
toggleRightPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
backButton.addActionListener(e -> frame.showPanel("MainMenu"));
|
|
||||||
|
|
||||||
startButton.addActionListener(e -> frame.showPanel("coinToss")); // TODO ECHTE FUNKTION EINFÜGEN
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleLeftPlayerIcon() {
|
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
leftPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleRightPlayerIcon() {
|
|
||||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
rightPlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
rightPlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode zum Aktualisieren der Textfelder basierend auf den ausgewählten Icons
|
|
||||||
private void updateTextFields() {
|
|
||||||
// Linker Spieler
|
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
leftPlayerTextField.setText("Spieler 1");
|
|
||||||
} else {
|
|
||||||
leftPlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rechter Spieler
|
|
||||||
if (rightPlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
rightPlayerTextField.setText("Spieler 2");
|
|
||||||
} else {
|
|
||||||
rightPlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
|
|
||||||
public class startMultiplayerGame extends JPanel {
|
|
||||||
// Funktionshilfen
|
|
||||||
int semesterCounter = 1; // Semester Counter Label
|
|
||||||
String PlayerNickname = "Spieler 1";
|
|
||||||
|
|
||||||
// Grafiken
|
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
|
||||||
ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
|
||||||
|
|
||||||
// Labels
|
|
||||||
JLabel frameTitle = new JLabel("Multiplayer Spiel");
|
|
||||||
JLabel semesterLabel = new JLabel("Semester");
|
|
||||||
JLabel PlayerName = new JLabel("Name");
|
|
||||||
JLabel PlayerIcon = new JLabel(humanPlayerIcon);
|
|
||||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
|
||||||
|
|
||||||
// Buttons
|
|
||||||
JButton backButton = new JButton(backButtonIcon);
|
|
||||||
JButton PlayerLeftButton = new JButton("<-");
|
|
||||||
JButton PlayerRightButton = new JButton("->");
|
|
||||||
JButton semesterUpButton = new JButton("^");
|
|
||||||
JButton semesterDownButton = new JButton("v");
|
|
||||||
JButton createGameButton = new JButton("Spiel erstellen");
|
|
||||||
JButton joinGameButton = new JButton("Spiel beitreten");
|
|
||||||
|
|
||||||
// Textfelder
|
|
||||||
JTextField PlayerTextField = new JTextField(20);
|
|
||||||
|
|
||||||
// Konstruktor
|
|
||||||
startMultiplayerGame(MainFrame frame) {
|
|
||||||
setLayout(null); // Setze das Layout für das Panel auf null
|
|
||||||
|
|
||||||
// Setze Komponentenpositionen und füge sie dem Panel hinzu
|
|
||||||
frameTitle.setBounds(20, 20, 200, 30);
|
|
||||||
add(frameTitle);
|
|
||||||
|
|
||||||
semesterLabel.setBounds(700, 300, 200, 30);
|
|
||||||
add(semesterLabel);
|
|
||||||
|
|
||||||
PlayerName.setBounds(50, 625, 200, 30);
|
|
||||||
add(PlayerName);
|
|
||||||
|
|
||||||
PlayerIcon.setBounds(75, 400, 200, 128);
|
|
||||||
add(PlayerIcon);
|
|
||||||
|
|
||||||
semesterCounterLabel.setBounds(725, 475, 50, 50); // zwischen den Up/Down-Buttons
|
|
||||||
semesterCounterLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
add(semesterCounterLabel);
|
|
||||||
|
|
||||||
// Füge Buttons hinzu und setze ihre Positionen
|
|
||||||
backButton.setBounds(1380, 20, 80, 80);
|
|
||||||
add(backButton);
|
|
||||||
|
|
||||||
PlayerLeftButton.setBounds(50, 450, 50, 50);
|
|
||||||
add(PlayerLeftButton);
|
|
||||||
|
|
||||||
PlayerRightButton.setBounds(250, 450, 50, 50);
|
|
||||||
add(PlayerRightButton);
|
|
||||||
|
|
||||||
semesterUpButton.setBounds(725, 400, 50, 50);
|
|
||||||
add(semesterUpButton);
|
|
||||||
|
|
||||||
semesterDownButton.setBounds(725, 550, 50, 50);
|
|
||||||
add(semesterDownButton);
|
|
||||||
|
|
||||||
joinGameButton.setBounds(1100, 350, 200, 50);
|
|
||||||
add(joinGameButton);
|
|
||||||
|
|
||||||
createGameButton.setBounds(1100, 550, 200, 50);
|
|
||||||
add(createGameButton);
|
|
||||||
|
|
||||||
// Füge das Textfeld hinzu
|
|
||||||
PlayerTextField.setBounds(50, 650, 250, 50);
|
|
||||||
PlayerTextField.setText(PlayerNickname);
|
|
||||||
add(PlayerTextField);
|
|
||||||
|
|
||||||
// ActionListener für Buttons
|
|
||||||
// SEMESTERBUTTONS
|
|
||||||
semesterUpButton.addActionListener(e -> {
|
|
||||||
if (semesterCounter < 6) {
|
|
||||||
semesterCounter++;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
semesterDownButton.addActionListener(e -> {
|
|
||||||
if (semesterCounter > 1) {
|
|
||||||
semesterCounter--;
|
|
||||||
semesterCounterLabel.setText(String.valueOf(semesterCounter));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// PLAYERTOGGLEBUTTONS
|
|
||||||
PlayerLeftButton.addActionListener(e -> {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
});
|
|
||||||
|
|
||||||
PlayerRightButton.addActionListener(e -> {
|
|
||||||
toggleLeftPlayerIcon();
|
|
||||||
updateTextFields();
|
|
||||||
});
|
|
||||||
|
|
||||||
// ActionListener für den "Back" Button, um zum vorherigen Panel zurückzukehren
|
|
||||||
|
|
||||||
backButton.addActionListener(e -> frame.showPanel("MainMenu"));
|
|
||||||
joinGameButton.addActionListener(e -> frame.showPanel("JoinGame"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TOGGLE METHODEN
|
|
||||||
private void toggleLeftPlayerIcon() {
|
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
PlayerIcon.setIcon(aiPlayerIcon);
|
|
||||||
} else {
|
|
||||||
PlayerIcon.setIcon(humanPlayerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTextFields() {
|
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
|
||||||
PlayerTextField.setText(PlayerNickname);
|
|
||||||
} else {
|
|
||||||
PlayerTextField.setText("Leicht");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue