示例#1
0
        /// <summary>
        /// Begins the process of connecting to the server
        /// </summary>
        public void Connect(string serverAddress, string playerName)
        {
            int port = 11000;

            this.playerName = playerName;
            Networking.ConnectToServer(OnConnect, serverAddress, port);
        }
示例#2
0
 /// <summary>
 /// Method for initializing the connection
 /// </summary>
 /// <param name="ipAddress"></param>
 /// <param name="playerName"></param>
 public void Connect(string ipAddress, string playerName)
 {
     ClearWorldObjects();   // Clears all the world objects from respective dictionaries
     userName = playerName; // Saving the player name sent from the user
     ipAddr   = ipAddress;  // saving the ip address
     Networking.ConnectToServer(FirstContact, ipAddress, Constant.PortNum);
 }
示例#3
0
 /// <summary>
 /// Begins the handshake process of connecting to a TankWars server.
 /// if any errors occur during the connection process, the view will display an informative error message
 /// and the user can try again.
 /// </summary>
 public void ConnectToServer(string hostName, string playerName)
 {
     if (PlayerNameIsValid(playerName))
     {
         this.playerName = playerName;
         int portNumber = 11000;  // networking protocol requires port number to always be 11000
         Networking.ConnectToServer(OnFirstConnect, hostName, portNumber);
     }
     else
     {
         ShowErrorMessageEvent?.Invoke("name must be 16 characters or less. please enter a new name.", "invalid name");
     }
 }
示例#4
0
        /// <summary>
        /// Connects to the server
        /// </summary>
        public void Connect(string address, string name)
        {
            //Sets the player's name as the name
            playerName = name;

            //If the player's name is less than 16, then it shows an error
            if (playerName.Length > 16)
            {
                Error("Name has to be less than 16 characters");
                return;
            }
            //Connects to the server
            Networking.ConnectToServer(OnConnect, address, 11000);
        }
示例#5
0
        /// <summary>
        /// This method tries to start the connection with the server given a specified player name, server
        /// address and port.
        /// </summary>
        /// <param name="name">Player name</param>
        /// <param name="server">Server address</param>
        /// <param name="port">Port to connect to the server</param>
        public void TryConnect(string name, string server, int port)
        {
            //Keeps track of the name
            if (name.Length <= 16)
            {
                tankName = name;
            }
            //If the name is too long it triggers an event
            else
            {
                ErrorEvent("Name is longer than 16 characters");
                return;
            }

            Networking.ConnectToServer(SendName, server, port);
        }
示例#6
0
 /// <summary>
 /// This is a connect method for the view once the player presses the
 /// connect button.
 /// <parameter> serverName gives the names of the server to connect to</parameter>
 /// </summary>
 public void Connect(string serverName, string name)
 {
     playerName = name;
     Networking.ConnectToServer(OnConnect, serverName, 11000);
 }
示例#7
0
 /// <summary>
 /// Begins connection with host.
 /// </summary>
 public void Connect(string hostName, string playerName)
 {
     PlayerName = playerName;
     Networking.ConnectToServer(FirstContact, hostName, 11000);
 }
示例#8
0
 /// <summary>
 /// Begins the process of connecting to the server
 /// </summary>
 /// <param name="addr"></param>
 public void Connect(string address, string name)
 {
     PlayerName = name;
     Networking.ConnectToServer(OnConnect, address, 11000);
 }