Exemplo n.º 1
0
    // generates the room code from the ip address
    public string GenerateRoomCode()
    {
        // gets the system ip
        string roomCode = IPCryptor.EncryptSystemIP();

        // TODO: randomize the room code so that the ip addres sisn't set.

        return(roomCode);
    }
Exemplo n.º 2
0
    // finds the room (runs client)
    public void FindRoom()
    {
        // search for room code input field.
        if (roomCodeInputField.text == "")
        {
            Debug.LogError("No Room Code Set.");
            return;
        }

        // checks to see if the host is already running.
        if (lobbyManager.IsHostRunning())
        {
            Debug.LogAssertion("Tried to run the host to find a room, but the host was already running.");
            return;
        }

        // checks to see if the room is open.
        bool searchStarted = false;

        // sets ip address.
        lobbyManager.isMaster  = false;
        lobbyManager.ipAddress = IPCryptor.DecryptIP(roomCodeInputField.text);

        // ip address parse failed.
        if (lobbyManager.ipAddress == "")
        {
            // ip address not set
            Debug.LogError("IPAddress not set.");
            return;
        }

        // runs host
        searchStarted = lobbyManager.RunHost();

        // room has been opened.
        if (searchStarted)
        {
            roomIndict.color = roomIndictOn; // on colour
        }
        else
        {
            roomIndict.color = roomIndictOff; // off colour
        }


        // disables host button
        {
            // if the host button is saved, use it.
            if (hostButton != null)
            {
                hostButton.interactable = false;
            }
            else
            {
                // looks for the host button
                GameObject go = GameObject.Find("Host Button");

                // if the host button was found, disable it.
                if (go != null)
                {
                    hostButton = go.GetComponent <Button>(); // gets the button component.

                    // makes the button non-interactable
                    if (hostButton != null)
                    {
                        hostButton.interactable = false;
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    // opens the room (runs server)
    public void OpenRoom()
    {
        // checks to see if the host is already running.
        if (lobbyManager.IsHostRunning())
        {
            Debug.LogAssertion("Tried to open the room, but the host was already running.");
            return;
        }

        // checks to see if the room is open.
        bool roomOpened = false;

        // if ip has not been set.
        if (roomCodeInputField.text == "")
        {
            GenerateAndSetRoomCode();
        }

        // sets ip address.
        lobbyManager.isMaster  = true;
        lobbyManager.ipAddress = IPCryptor.DecryptIP(roomCodeInputField.text);
        roomOpened             = lobbyManager.RunHost();

        // room has been opened.
        if (roomOpened)
        {
            roomIndict.color = roomIndictOn; // on colour
        }
        else
        {
            roomIndict.color = roomIndictOff; // off colour
        }


        // disables join button
        {
            // if the join button is saved, use it.
            if (joinButton != null)
            {
                joinButton.interactable = false;
            }
            else
            {
                // looks for the join button
                GameObject go = GameObject.Find("Join Button");

                // if the join button was found, disable it.
                if (go != null)
                {
                    joinButton = go.GetComponent <Button>(); // gets the button component.

                    // makes the button non-interactable
                    if (joinButton != null)
                    {
                        joinButton.interactable = false;
                    }
                }
            }
        }


        // disables the room size slider.
        if (roomSizeSlider != null)
        {
            roomSizeSlider.interactable = false;
        }
    }
Exemplo n.º 4
0
 // sets the ip address
 public void ApplySystemIPAddress()
 {
     // applies system ip
     ipAddressInput.text = IPCryptor.GetSystemIPAddress();
 }