Exemple #1
0
    protected void Awake()
    {
        //Bind it
        SocketController.BindEvent(MsgType.Disconnect, OnDisconnect);


        //Load the resources here but soon move it to the loading thing
        //GameData.Initialize();
    }
Exemple #2
0
    /// <summary>
    /// Enables the login panel and binds
    /// </summary>
    private void ShowLoginPanel()
    {
        //Show the UI
        LoginPanel.SetActive(true);

        //Bind login opcodes events
        SocketController.BindEvent(NetworkInstructions.LOGIN_FAIL, OnLoginFail);
        SocketController.BindEvent(NetworkInstructions.LOGIN_SUCCESS, OnLoginSuccess);

        //Destroy the loading box
        Destroy(GameObject.Find("LoadingBox"));
    }
Exemple #3
0
    /// <summary>
    /// Initializes objects and binds
    /// </summary>
    protected void Start()
    {
        //Reference validation
        if (UI == null)
        {
            UI = GameObject.FindWithTag("UI").gameObject;
        }
        if (LoginPanel == null)
        {
            Debug.LogError("LoginPanel is missing from login.cs");
        }
        if (remmeber == null)
        {
            Debug.LogError("remmeber is missing from login.cs");
        }
        if (submitBtn == null)
        {
            Debug.LogError("submitBtn is missing from login.cs");
        }
        if (usrField == null)
        {
            Debug.LogError("usrField is missing from login.cs");
        }
        if (pwdField == null)
        {
            Debug.LogError("pwdField is missing from login.cs");
        }

        //Unity Binds
        submitBtn.onClick.AddListener(SubmitValidation);
        remmeber.onValueChanged.AddListener(delegate { OnRemmeberChange(remmeber); });
        usrField.onValueChanged.AddListener(delegate { OnUsernameChange(usrField); });
        pwdField.onValueChanged.AddListener(delegate { OnPasswordChange(pwdField); });

        //Start the network area
        SocketController.Initialize();
        SocketController.BindEvent(NetworkInstructions.Disconnect, OnServerOffline);
        SocketController.BindEvent(NetworkInstructions.Connect, OnConnectionEstablished);
        SocketController.BindEvent(NetworkInstructions.ServerOffline, OnServerOffline);

        //Hide login panel till we get a connection with the remote server
        HideLoginPanel();

        //Disable submit until we get data
        submitBtn.interactable = false;

        //Lets see if the user has saved or asked to
        if (PlayerPrefs.GetInt("login_remmeber") == 1)
        {
            remmeber.isOn = true;

            //Remmeber me input load
            if (!String.IsNullOrWhiteSpace(PlayerPrefs.GetString("login_username")))
            {
                usrField.text = PlayerPrefs.GetString("login_username");
            }
            else if (!String.IsNullOrWhiteSpace(PlayerPrefs.GetString("login_password")))
            {
                pwdField.text = PlayerPrefs.GetString("login_password");
            }
        }
    }