Ejemplo 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);
      }
    }
Ejemplo 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;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Method called when the screen is switched from
 /// </summary>
 public override void OnDeactivate()
 {
   client = null;
   player = null;
 }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Disconnects from the server
    /// </summary>
    /// <param id="sender">User control that invoked this method</param>
    private void Disconnect(object sender)
    {
      if (client != null)
      {
        client.Close("User invoked");
        client = null;

        ClearUserlist();

        if (server != null)
        {
          UseServerUserlist();
        }

        cm.GetControl("disconnect").Enabled = false;
      }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Connects to a server
    /// </summary>
    /// <param id="sender">User control that invoked this method</param>
    private void JoinServer(object sender)
    {
      if (client == null && currentClientGameState == GameState.NotConnected)
      {
        UpdateIp(cm.GetControl("ipTextbox"));
        client = new NetworkClient(currentUserName);
        client.Start(lastIp);

        UseClientUserlist();

        cm.GetControl("disconnect").Enabled = true;
      }
    }
Ejemplo n.º 7
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;
   }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Method called when the screen is switched from
 /// </summary>
 public override void OnDeactivate()
 {
   if (mapUI != null)
     mapUI.Dispose();
   mapUI = null;
   if (game != null)
     game.Dispose();
   game = null;
   player = null;
   if (client != null)
     client.Dispose();
   client = null;
   if (server != null)
     server.Dispose();
 }