Пример #1
0
 @Override
 public void handle(Packet packet) {
   if (packet instanceof StartGamePacket) {
     if (!isServer) {
       StartGamePacket sgPacker = (StartGamePacket) packet;
       synchronizer.onStartGamePacket(sgPacker);
       TitleMenu.difficulty = DifficultyList.getDifficulties().get(sgPacker.getDifficulty());
       createLevel(sgPacker.getLevelFile(), TitleMenu.defaultGameMode);
     }
   } else if (packet instanceof TurnPacket) {
     synchronizer.onTurnPacket((TurnPacket) packet);
   } else if (packet instanceof StartGamePacketCustom) {
     if (!isServer) {
       StartGamePacketCustom sgPacker = (StartGamePacketCustom) packet;
       synchronizer.onStartGamePacket((StartGamePacket) packet);
       TitleMenu.difficulty = DifficultyList.getDifficulties().get(sgPacker.getDifficulty());
       level = sgPacker.getLevel();
       paused = false;
       initLevel();
     }
   } else if (packet instanceof PingPacket) {
     PingPacket pp = (PingPacket) packet;
     synchronizer.onPingPacket(pp);
     if (pp.getType() == PingPacket.TYPE_ACK) {
       addToLatencyCache(pp.getLatency());
     }
   }
 }
Пример #2
0
 @Override
 public void handle(Packet packet) {
   if (packet instanceof StartGamePacket) {
     if (!isServer) {
       StartGamePacket sgPacker = (StartGamePacket) packet;
       synchronizer.onStartGamePacket(sgPacker.getGameSeed());
       TitleMenu.difficulty = DifficultyList.getDifficulties().get(sgPacker.getDifficulty());
       createLevel(sgPacker.getLevelFile());
     }
   } else if (packet instanceof TurnPacket) {
     synchronizer.onTurnPacket((TurnPacket) packet);
   } else if (packet instanceof StartGamePacketCustom) {
     if (!isServer) {
       StartGamePacketCustom sgPacker = (StartGamePacketCustom) packet;
       synchronizer.onStartGamePacket(sgPacker.getGameSeed());
       TitleMenu.difficulty = DifficultyList.getDifficulties().get(sgPacker.getDifficulty());
       level = sgPacker.getLevel();
       paused = false;
       initLevel();
     }
   }
 }