public void updateClientList(ArrayList<ClientInfo> clients) { for (int i = 0; i < clients.size(); i++) { ClientInfo ci = clients.get(i); if (ci.getName().equals(name)) { view.setName(name + " - (" + ci.getPoints() + ")"); break; } } view.setClientList(clients); }
// Constructor to initialize client name and server location public C_GameClient(String name, String serverLoc) throws RemoteException, MalformedURLException, NotBoundException { model = new M_GameClient(name, this); Naming.rebind("client", model); this.name = name; SERVER_STUB_LOC = serverLoc; setSize(400, 400); setVisible(true); setTitle("Game Client - " + this.name); addWindowListener(this); view = new V_GameClient(); view.setName(name); view.setMouseListener(gameMouseListener); add(view); model.login(name, model); state = STATE.CONNECTED; }
@Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub if (state == STATE.DISCONNECTED) { System.out.println("server is disconnected!"); return; } Rectangle rect = view.getFlyDimension(); if (rect.contains(e.getPoint())) { System.out.println(name.toString() + " hit the fly!!"); try { model.sendFlyHitConfirmation(name); } catch (Exception ex) { ex.printStackTrace(); } } }
public void promptServerShutdown() { state = STATE.DISCONNECTED; view.disableGame(); view.setStatus("Server is disconnected!"); }
public void updateFlyPosition(Point p) { view.setFlyPosition(p); }
public void updateWindowSetting(int gameWidth, int gameHeight) { setSize(gameWidth + 150, gameHeight + 50); view.repaint(); }