Ejemplo n.º 1
0
 public void CreateServer()
 {
     if (!Network.isClient)
     {
         m_iMaxPlayerCount = 2;
         string szFilePath = Application.persistentDataPath + "/Levels/" + m_szMapName + ".lvl";
         if (File.Exists(szFilePath))
         {
             BinaryReader br;
             //create the file reader
             try
             {
                 br = new BinaryReader(new FileStream(szFilePath, FileMode.Open));
             }
             catch (IOException e)
             {
                 Debug.Log(e.Message + "\n Cannot open file.");
                 return;
             }
             //read the file
             try
             {
                 int iMapWidth  = br.ReadInt32();
                 int iMapHeight = br.ReadInt32();
                 m_iMaxPlayerCount = br.ReadInt32();
             }
             catch (IOException e)
             {
                 Debug.Log(e.Message + "\n Cannot read file.");
                 return;
             }
             br.Close();
         }
         m_PlayerList = new Player[m_iMaxPlayerCount];
         m_MultiplayerLobby.Reset(m_iMaxPlayerCount);
         Network.InitializeServer(m_iMaxPlayerCount - 1, 6000, true);
         MasterServer.RegisterHost("WeatherTactics", "Tsan game", "open");
         GlobalVariables.m_szPseudo = "Tsan";
         SetPlayerID(CreatePlayer("Tsan", Network.player));
         m_bReady = true;
         SetPlayerReady(GlobalVariables.m_iCurrentPlayerId - 1, true);
     }
     else
     {
         Debug.Log("can't start server you are already connected to a server");
     }
 }