|
|
@ -12,15 +12,18 @@ import javax.swing.JLabel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.border.MatteBorder; |
|
|
|
|
|
|
|
import de.tims.fleetstorm.ai.Logic; |
|
|
|
import de.tims.fleetstorm.matchfield.Matchfield; |
|
|
|
|
|
|
|
public class Logic extends JPanel { |
|
|
|
public class GameLogic extends JPanel { |
|
|
|
|
|
|
|
// GameManager stuff |
|
|
|
private int gameState; |
|
|
|
private Matchfield matchfield; |
|
|
|
private Matchfield enemyMatchfield; |
|
|
|
private int matchfieldSize = 10; |
|
|
|
private boolean playerMove = true; |
|
|
|
private Logic aiLogic; |
|
|
|
|
|
|
|
public static final int PREPARATION = 1; |
|
|
|
public static final int RUNNING = 2; |
|
|
@ -39,7 +42,7 @@ public class Logic extends JPanel { |
|
|
|
private JLabel enemy4Ship; |
|
|
|
private JLabel enemy5Ship; |
|
|
|
|
|
|
|
public Logic(int gapToFrameBorder, int fieldWidth, int spaceBetween) { |
|
|
|
public GameLogic(int gapToFrameBorder, int fieldWidth, int spaceBetween) { |
|
|
|
this.fields = new ArrayList<>(); |
|
|
|
setSize(640, 480); |
|
|
|
|
|
|
@ -248,7 +251,7 @@ public class Logic extends JPanel { |
|
|
|
*/ |
|
|
|
public static void main(String[] args) { |
|
|
|
JFrame frame = new JFrame("Test GUI"); |
|
|
|
Logic gui = new Logic(15, 28, 1); |
|
|
|
GameLogic gui = new GameLogic(15, 28, 1); |
|
|
|
frame.setContentPane(gui); |
|
|
|
frame.setSize(640, 480); |
|
|
|
frame.setResizable(true); |
|
|
@ -256,9 +259,15 @@ public class Logic extends JPanel { |
|
|
|
} |
|
|
|
|
|
|
|
public void start() { |
|
|
|
this.gameState = Logic.PREPARATION; |
|
|
|
this.gameState = GameLogic.PREPARATION; |
|
|
|
|
|
|
|
// create player matchfield |
|
|
|
this.matchfield = new Matchfield(matchfieldSize); |
|
|
|
|
|
|
|
// create enemy matchfield and initialize AI (with player's matchfield) |
|
|
|
this.enemyMatchfield = new Matchfield(matchfieldSize); |
|
|
|
this.aiLogic = new Logic(); |
|
|
|
this.aiLogic.setMatchfield(this.matchfield); |
|
|
|
} |
|
|
|
|
|
|
|
public void nextMove() { |