Пример #1
0
 /**
  * This method updates the relevant sections of the GUI when a new LookReply and RenderHint are
  * received from the server.
  */
 public void updateGUI(char[][] newCells, String[] newRenderHint, boolean ourTurn) {
   char[] playerDirections = processRenderHint(newRenderHint);
   boolean hasLantern = (newCells[0].length == 7); // the size of the lookreply determines whether
   // the player has a lantern
   dungeonPanel.updateCells(newCells, hasLantern, playerDirections); // updates the map panel
   int goldHeld = client.getGoldHeld();
   int goldNeeded = client.getGoldNeeded();
   dungeonPanelOverlay.updateOverlay(hasLantern, ourTurn, goldHeld, goldNeeded);
   // updates the overlay
 }
Пример #2
0
 /**
  * This method takes in the raw renderHint and splits it into usable information, returning an
  * array of the player directions and updating the bars in the overlay when the line referring to
  * this player is read.
  */
 public char[] processRenderHint(String[] renderHint) {
   int numberOfLines = renderHint.length;
   char[] playerDirections = new char[numberOfLines];
   for (int i = 0; i < numberOfLines; i++) {
     String[] components = renderHint[i].split(" ");
     if (renderHint[i].startsWith("0 0") && (components.length == 5)) {
       // this refers to the current player
       dungeonPanelOverlay.updateBars(components[3], components[4]);
     }
     playerDirections[i] = components[2].charAt(0);
   }
   return playerDirections;
 }
Пример #3
0
 /**
  * This method changes all of the GUI components depending on whether the player is connected to a
  * server, because different functionality is needed when we're connected from when we're not.
  */
 public void toggleGUIStates(boolean gameRunning) {
   serverSettings.flipButtonStates(gameRunning);
   chatPanel.setConnected(gameRunning);
   dungeonPanelOverlay.toggleGameStarted(gameRunning);
   dungeonPanel.setVisible(gameRunning);
 }