Exemplo n.º 1
0
    /// <summary>
    /// Method called when the screen is switched to; creates MapUI and assigns controlling player
    /// </summary>
    /// <param id="screenParams">Parameters passed from the last screen, WildmenGame, NetworkServer, NetworkClient and Player in this order</param>
    public override void OnActivate(object[] screenParams)
    {
      game = screenParams[0] as WildmenGame;
      server = screenParams[1] as NetworkServer;
      client = screenParams[2] as NetworkClient;
      player = screenParams[3] as Player;

      serverView = player == null;

      currentClientGameState = GameState.Started;

      MakeMapUI(game);

      mapUI.AssignControllingPlayer(player);

      messageQueue.Clear();

      if (serverView)
      {
        sm.CallSubscreen("escapemenu", client, server, player);
      }
    }
Exemplo n.º 2
0
 /// <summary>
 /// Method called when the screen is switched to; creates MapUI and assigns controlling player
 /// </summary>
 /// <param id="screenParams">Parameters passed from the last screen, NetworkClient, NetworkServer and Player in this order</param>
 public override void OnActivate(object[] screenParams)
 {
   client = screenParams[0] as NetworkClient;
   server = screenParams[1] as NetworkServer;
   player = screenParams[2] as Player;
 }
Exemplo n.º 3
0
    /// <summary>
    /// Switches to the game screen
    /// </summary>
    /// <param id="targetGame">Game to use</param>
    private void SwitchToGameScreen(WildmenGame targetGame)
    {
      // Copy values to local variables
      var game2 = targetGame;
      var server2 = server;
      var client2 = client;
      var player2 = player;

      // Detach all references from current screen
      //    (switching screen calls OnDeactivate that would dispose these variables)
      game = null;
      server = null;
      client = null;
      player = null;

      // Switch active screen
      sm.SwitchScreen("game", game2, server2, client2, player2);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Stops the server
   /// </summary>
    /// <param id="sender">User control that invoked this method</param>
    private void StopServer(object sender)
    {
      if (server != null)
      {
        server.Stop();
        server = null;
        cm.GetControl("stopServer").Enabled = false;

        ClearUserlist();

        if (client != null)
        {
          UseClientUserlist();
        }
      }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Starts the server
    /// </summary>
    /// <param id="sender">User control that invoked this method</param>
    private void StartServer(object sender)
    {
      if (server == null && currentClientGameState == GameState.NotConnected)
      {
        server = new NetworkServer();
        server.Start();
        cm.GetControl("startServer").Enabled = false;

        if (client == null)
        {
          UseServerUserlist();
        }
      }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Method called when the screen is switched from
 /// </summary>
 public override void OnDeactivate()
 {
   if (server != null)
   {
     StopServer(null);
     server.Dispose();
     server = null;
   }
   if (client != null)
   {
     Disconnect(null);
     client.Dispose();
     client = null;
   }
   if (game != null)
   {
     game.Dispose();
     game = null;
     player = null;
   }
 }