lucasjoshua #12
|
@ -11,7 +11,8 @@ public class MainFrame extends JFrame {
|
||||||
// Von startMultiplayerGame an JoinGame
|
// Von startMultiplayerGame an JoinGame
|
||||||
int localMult;
|
int localMult;
|
||||||
|
|
||||||
// Von startLocalGame an GameBoard
|
// Von startLocalGame an startLocalGameLoadingScreen
|
||||||
|
// Von startLocalGameLoadingScreen an GameBoard
|
||||||
int semesterCounter;
|
int semesterCounter;
|
||||||
// ---------- //
|
// ---------- //
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@ import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// Evtl. ist Namen selber setzten noch unmöglich
|
||||||
|
//
|
||||||
|
|
||||||
public class startLocalGame extends JPanel {
|
public class startLocalGame extends JPanel {
|
||||||
// Player
|
// Player
|
||||||
//Player p1;
|
//Player p1;
|
||||||
|
@ -118,7 +122,7 @@ public class startLocalGame extends JPanel {
|
||||||
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
leftPlayerLeftButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
toggleLeftPlayerIcon();
|
toggleLeftPlayerIconLeft();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -126,7 +130,7 @@ public class startLocalGame extends JPanel {
|
||||||
leftPlayerRightButton.addActionListener(new ActionListener() {
|
leftPlayerRightButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
toggleLeftPlayerIcon();
|
toggleLeftPlayerIconRight();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -134,7 +138,7 @@ public class startLocalGame extends JPanel {
|
||||||
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
rightPlayerLeftButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
toggleRightPlayerIcon();
|
toggleRightPlayerIconLeft();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,7 +146,7 @@ public class startLocalGame extends JPanel {
|
||||||
rightPlayerRightButton.addActionListener(new ActionListener() {
|
rightPlayerRightButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
toggleRightPlayerIcon();
|
toggleRightPlayerIconRight();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -193,7 +197,19 @@ public class startLocalGame extends JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleLeftPlayerIcon() {
|
private void toggleLeftPlayerIconLeft() {
|
||||||
|
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
|
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) {
|
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
|
@ -205,7 +221,17 @@ public class startLocalGame extends JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleRightPlayerIcon() {
|
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) {
|
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||||
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetSocketAddress;
|
// TODO
|
||||||
|
// Evtl. ist Namen selber setzten noch unmöglich
|
||||||
|
//
|
||||||
|
|
||||||
public class startMultiplayerGame extends JPanel {
|
public class startMultiplayerGame extends JPanel {
|
||||||
// Funktionshilfen
|
// Funktionshilfen
|
||||||
|
@ -9,7 +11,9 @@ public class startMultiplayerGame extends JPanel {
|
||||||
// Grafiken
|
// Grafiken
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.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
|
// Labels
|
||||||
JLabel frameTitle = new JLabel("Multiplayer Spiel");
|
JLabel frameTitle = new JLabel("Multiplayer Spiel");
|
||||||
|
@ -105,12 +109,12 @@ public class startMultiplayerGame extends JPanel {
|
||||||
|
|
||||||
// PLAYERTOGGLEBUTTONS
|
// PLAYERTOGGLEBUTTONS
|
||||||
PlayerLeftButton.addActionListener(e -> {
|
PlayerLeftButton.addActionListener(e -> {
|
||||||
toggleLeftPlayerIcon();
|
togglePlayerIconLeft();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerRightButton.addActionListener(e -> {
|
PlayerRightButton.addActionListener(e -> {
|
||||||
toggleLeftPlayerIcon();
|
togglePlayerIconRight();
|
||||||
updateTextFields();
|
updateTextFields();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,19 +126,39 @@ public class startMultiplayerGame extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOGGLE METHODEN
|
// TOGGLE METHODEN
|
||||||
private void toggleLeftPlayerIcon() {
|
private void togglePlayerIconLeft() {
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerIcon);
|
PlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
} else {
|
} 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);
|
PlayerIcon.setIcon(humanPlayerIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTextFields() {
|
private void updateTextFields() {
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
PlayerTextField.setText(PlayerNickname);
|
PlayerTextField.setText("Spieler 1");
|
||||||
} else {
|
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
PlayerTextField.setText("Leicht");
|
PlayerTextField.setText("Einfach");
|
||||||
|
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
|
PlayerTextField.setText("Mittel");
|
||||||
|
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
|
PlayerTextField.setText("Schwer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue