Kontakt

Fakturační údaje

IČ: 87189224, BÚ: 1958653063/0800

Contact info in QR code

Siege (Obkličovačka)

Informace

Stáhni a hraj!

  • Spustitelný soubor hry si stáhnou oba hráči
  • Zakladatel hry
    • V nabídce "Game > Create" vytvoří novou hru
    • Pošle protihráči svou IP adresu (zjistí ji v levém dolním rohu okna)
  • Protihráč
    • Jakmile obdrží IP adresu zakladatele hry, v nabídce "Game > Join" se připojí ke hře
  • Cílem je zabrat co nejvíce soupeřových polí.
  • Pozn.: Síťové spojení funguje na LAN (lokální) síťi a na počítačích s veřejnou IP adresou.

Zdrojové kódy (zip)

Zdrojové kódy (prohlížení)

 1: package siege.net;
 2: 
 3: import java.net.MalformedURLException;
 4: import java.rmi.Naming;
 5: import java.rmi.NotBoundException;
 6: import java.rmi.RemoteException;
 7: import siege.core.Game;
 8: import siege.util.Log;
 9: 
10: 
11: /**
12:  * Send queries to server
13:  *
14:  * @author Ondrej Macoszek, ondra@macoszek.cz
15:  */
16: public class Client implements GameCommands
17: {
18:     /**
19:      * Remote server
20:      */
21:     private GameCommands remoteServer;
22: 
23:     /**
24:      * Constructor
25:      *
26:      * @throws java.rmi.NotBoundException
27:      * @throws java.net.MalformedURLException
28:      * @throws java.rmi.RemoteException
29:      */
30:     public Client() throws NotBoundException, MalformedURLException, RemoteException
31:     {
32: 
33:         String address =
34:                 "rmi://" +
35:                 Game.getInstance().getRemotePlayer().getAddress() +
36:                 ":" + Server.getRemotePort() +
37:                 "/" + Server.NAME;
38: 
39:         Log.message(this,"connecting to server on address "+address);
40:         remoteServer = (GameCommands)Naming.lookup(address);
41:         Log.message(this,"connected to server");        
42:     }
43: 
44:     public void saveName(String name) throws RemoteException
45:     {
46:         remoteServer.saveName(name);
47:     }
48: 
49:     public void saveAddress(String address) throws RemoteException
50:     {
51:         remoteServer.saveAddress(address);
52:     }
53: 
54:     public boolean isReady() throws RemoteException
55:     {
56:         return remoteServer.isReady();
57:     }
58: 
59:     public void sendMovement(int x, int y) throws RemoteException
60:     {
61:         remoteServer.sendMovement(x, y);
62:     }
63: 
64:     public void sendMessage(String message) throws RemoteException
65:     {
66:         remoteServer.sendMessage(message);
67:     }
68: 
69:     public void retreat() throws RemoteException
70:     {
71:         remoteServer.retreat();
72:     }
73: 
74: }
75: