public void Direct()
    {
        Camera.main.GetComponent <AudioSource>().PlayOneShot(menuClick, (float)Game.GetSetting("audio"));
        Regex  format  = new Regex("[^0-9.:]");
        string address = format.Replace(direct.text, "");

        if (address.Length > 2 && address.Contains(":") && address.IndexOf(":") > address.LastIndexOf(".") && address.IndexOf(':') == address.LastIndexOf(':'))
        {
            string[] info = address.Split(':');
            if (info[1].Length > 0)
            {
                Net.client.Shutdown("Joining Game");

                string countDownTimer       = Net.AddConnKey(Net.ComboWombo(Application.cloudProjectId, MasterServer.MasterKey));
                NetPeerConfiguration config = new NetPeerConfiguration(countDownTimer);
                config.ConnectionTimeout = 0;
                Net.client = new NetClient(new NetPeerConfiguration(countDownTimer));

                Net.client.Start();
                Net.client.Connect(info[0], int.Parse(info[1]));

                StartCoroutine(ConnectToServer(info[0] + ":" + info[1]));
            }
        }
    }
    void Start()
    {
        loadingText.text = "reaching query server...";
        string gameId = Net.AddConnKey(Net.ComboWombo(Application.cloudProjectId, MasterServer.MasterKey));

        Net.client = new NetClient(new NetPeerConfiguration(gameId));
        Net.client.Start();
        Net.client.Connect(MasterServer.MasterIP, MasterServer.MasterPort);

        if (Game.isServer)
        {
            HostPort     = (int.TryParse(new Regex("[^0-9]").Replace(Game.GetServerPort(), ""), out HostPort)) ? HostPort : 7777;
            HostAddress  = new Regex("[^0-9.]").Replace(Game.GetServerIP(), "").Replace('`', ' ').Replace(';', ' ').Trim();
            HostName     = Game.GetServerTitle().Truncate(35).Replace('`', ' ').Replace(';', ' ').Trim();
            HostPassword = Game.GetServerPassword().Replace('`', ' ').Replace(';', ' ').Trim();
            MaxPlayers   = (int.TryParse(Game.GetServerMax(), out MaxPlayers)) ? MaxPlayers : 30;

            if (HostPort < 100000 && HostPort > 0 && HostAddress.IndexOf('.') > -1 && HostAddress.IndexOf('.') < HostAddress.LastIndexOf('.') && HostAddress.Length > 4 && HostAddress.Length < 18)
            {
                NetPeerConfiguration config = new NetPeerConfiguration(gameId);
                config.LocalAddress       = System.Net.IPAddress.Parse(HostAddress);
                config.Port               = HostPort;
                config.MaximumConnections = MaxPlayers;

                Net.server = new NetServer(config);
                Net.server.Start();
            }
        }

        StartCoroutine(WaitForConnection());
    }
    IEnumerator ConnectToServer(string ip)
    {
        connecting.SetActive(true);

        connecting.transform.GetChild(0).GetComponent <Text>().text = ip;
        connecting.transform.GetChild(1).GetComponent <Text>().text = "...";

        float time  = 0.0f;
        int   count = 0;

        while (true)
        {
            time += Time.deltaTime;

            if (time > 1)
            {
                count++;
                connecting.transform.GetChild(2).GetComponent <Text>().text += ".";
                if (count == 3)
                {
                    connecting.transform.GetChild(2).GetComponent <Text>().text = "connecting.";
                }
            }

            if (cancelConnect == true)
            {
                Net.client.Shutdown("Joining Game");
                Net.client = new NetClient(new NetPeerConfiguration(Net.AddConnKey(Net.ComboWombo(Application.cloudProjectId, MasterServer.MasterKey))));
                Net.client.Start();
                Net.client.Connect(MasterServer.MasterIP, MasterServer.MasterPort);
                cancelConnect = false;
                yield break;
            }

            if (Net.client.ConnectionStatus == NetConnectionStatus.Connected)
            {
                connecting.transform.GetChild(2).GetComponent <Text>().text = "connected!";
                NetOutgoingMessage message = Net.client.CreateMessage();
                message.Write("RequestEntrance");
                message.Write("");
                Net.client.SendMessage(message, Net.client.ServerConnection, NetDeliveryMethod.ReliableSequenced);
                break;
            }
            yield return(null);
        }
    }