Example #1
0
 //Events subscribed by Inspector
 public void OnServerNameChanged()
 {
     ServerNameSelected = ServerNameInputField.text;
     TextInputValidator.SanitiseText(ref ServerNameSelected, TextType.Filename);
     ServerNameInputField.text      = ServerNameSelected;
     StartServerButton.Interactable = TextInputValidator.IsTextLengthValid(ServerNameSelected);
 }
Example #2
0
    public void OnStartServer()
    {
        bool successStart;

        if (!InternetServerSelected)
        {
            throw new NotImplementedException();
            //int port = 28025; //TODO: Make so not hardcoded, maybe player assigns their own?
            //successStart = ServerProgram.StartServerProgram(ServerNameSelected, MaxPlayerSelected, MapSelected, port);
            //Instantiate(ServerGameObject);
            //Client.Instance.ConnectToServer("127.0.0.1", port);
        }
        else
        {
            ServerMenu.Instance.HideServerMenu();
            ServerNameSelected = TextInputValidator.TrimAllSpaces(ServerNameSelected);
            successStart       = InternetServerScanner.Instance.ContactMainServerToAddOwnServer(ServerNameSelected, MaxPlayerSelected, MapSelected, Client.PortNumInternetToConnectTo);
            //Waiting for response packet from MainServer
        }
        //TODO: Implement the Public/Private servers

        if (!successStart)
        {
            Output.WriteLine($"Error, {(InternetServerSelected ? "Internet" : "LAN" )} server not started...");
            return;
        }
    }