123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package bswfx;
- import bs.Create;
- import bswfx.handler.*;
- import bs.Game;
- import bs.Join;
- import bs.Menu;
- import org.json.JSONObject;
- import rsx.BomberStudentClient;
- import wfx.WebFx;
- /**
- *
- * @author Loquicom <contact@loquicom.fr>
- */
- public class BomberStudent {
-
- public static WebFx wfx = new WebFx();
- public static BomberStudentClient bsc = new BomberStudentClient();
- public static Game game;
- public static Menu menu;
- public static Create create;
- public static Join join;
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- //Change passage de ligne du systeme
- System.setProperty("line.separator", "\n");
-
- //Variables
- JSONObject param;
- JSONObject res;
-
- //Lancement Thread affichage
- Thread twfx = new Thread(wfx);
- twfx.start();
-
- //Ajout handler
- bsc.addHandler("server/end", new HandlerServerEnd());
- bsc.addHandler("player/position/update", new HandlerPlayerMove());
- bsc.addHandler("game/newplayer", new HandlerPlayerJoin());
- bsc.addHandler("game/quit", new HandlerPlayerQuit());
- bsc.addHandler("attack/newbomb", new HandlerAttackBomb());
- bsc.addHandler("attack/explose", new HandlerAttackExplose());
- bsc.addHandler("attack/affect", new HandlerAttackAffect());
- bsc.addHandler("player/major/end", new HandlerMajorEnd());
-
- //Recherche serveur actif
- int nbRes = bsc.findServer();
- if (nbRes == 0) {
- wfx.alert("Erreur", "Aucun serveur trouvé");
- waitWfx();
- wfx.end();
- System.exit(0);
- }
- System.out.println("Nombre serveur : " + nbRes);
-
- //Connexion serveur et recup liste des games
- bsc.selectServer(0);
-
- //Verif affichage ok
- while(!WebFx.ini.get());
-
- //Affichage menu
- menu = new Menu();
- menu.show();
- }
-
- public static void updateWindow(){
- wfx.loadHtml(game.toHtml());
- }
-
- public static void end(){
- wfx.end();
- bsc.close();
- System.exit(0);
- }
-
- public static void waitWfx(){
- while(wfx.wait.get()){
- try{
- Thread.sleep(1000);
- } catch(Exception ex) {
-
- }
- }
- }
- }
|