public void regularUpdate()
 {
     if (h != null)
     {
         h.regularUpdate();
     }
     else if (g != null)
     {
         g.regularUpdate();
         if (g.isBecomeHost())
         {
             h = new HostNetwork(username, g.getMatch(), g.isRoleHider());
             h.StartLobby();
             int timeout = 10;
             while (timeout-- > 0)
             {
                 Thread.Sleep(1000);
             }
             if (g.getMatch() != null)
             {
                 h.startMatch(g.getMatch().getState());
             }
             g = null;
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Shutdown the current game.
 /// </summary>
 /// <returns>If the game was stopped.</returns>
 public bool Stop()
 {
     Playable = false;
     if (HostNetwork != null)
     {
         HostNetwork.Close();
     }
     if (LocalPlayers != null)
     {
         foreach (ClientNetworking playerNetwork in LocalPlayers)
         {
             playerNetwork.NextCommand = "EXIT";
             playerNetwork.NewCommand  = true;
         }
     }
     return(true);
 }
 public void Guest(string hostIP)
 {
     h = null;
     g = new GuestNetwork(username);
     g.ConnectToHost(hostIP);
 }
 public void Host()
 {
     g = null;
     h = new HostNetwork(username);
     h.StartLobby();
 }