Exemplo n.º 1
0
    // button that logs player in
    public void Button_Login()
    {
        ServerResponse response = UserRequestLibrary.LoginRequest(m_NameText, m_PasswordText);

        // if response is positive, save name and password, and load next scene
        if (response.ResponseType == EServerResponseType.OK)
        {
            // save name and password
            PlayerData.playerName     = m_NameText.text.Remove(m_NameText.text.Length - 1);
            PlayerData.playerPassword = m_PasswordText.text.Remove(m_PasswordText.text.Length - 1);

            LoginBanner.gameObject.SetActive(true);
            LoginBannerText.text = response.Text;
            StartCoroutine(LoadStoryScene());
            return;
        }

        // if response is error, print out error message
        if (response.ResponseType == EServerResponseType.ERROR)
        {
            LoginBanner.gameObject.SetActive(true);
            LoginBannerText.text = response.Text;
            Invoke("DisableLoginBanner", 2.0f);
            return;
        }
    }
Exemplo n.º 2
0
    public void Login()
    {
        // Set IP to the current ip text if not empty
        if (m_NewIPText.text == "")
        {
            return;
        }

        PlayerData.IP = m_NewIPText.text.Remove(m_NewIPText.text.Length - 1);

        ServerResponse sr = UserRequestLibrary.LoginRequest(m_NameText, m_PasswordText);

        // if response is positive, save name and password, and load next scene
        if (sr.ResponseType == EServerResponseType.OK)
        {
            // save name and password
            PlayerData.playerName     = m_NameText.text.Remove(m_NameText.text.Length - 1);
            PlayerData.playerPassword = m_PasswordText.text.Remove(m_PasswordText.text.Length - 1);

            LoginBanner.gameObject.SetActive(true);
            LoginBannerText.text = sr.Text;
            StartCoroutine(LoadMainScene());
            return;
        }

        // if response is error, print out error message
        if (sr.ResponseType == EServerResponseType.ERROR)
        {
            LoginBanner.gameObject.SetActive(true);
            LoginBannerText.text = sr.Text;
            Invoke("DisableLoginBanner", 2.0f);
            return;
        }
    }