Esempio n. 1
0
    private void OnSelectAvatar()
    {
        UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token
                                          , (jsel) =>
        {
            OnUnloadThis();

            URemoteData.OnReceiveAvatarData(jsel["avatar"].ToString());
            LoadAnotherUI <UIMain>();
        }, (err) =>
        {
            if (err == "3")
            {
                OnUnloadThis();

                LoadAnotherUI <UICreateAvatar>();
            }
            else
            {
                UIAlert.Show("选择角色失败," + err);
            }
        }, (err) =>
        {
            UIAlert.Show("选择角色失败," + err);
        });
    }
Esempio n. 2
0
    private void OnSelectAvatar()
    {
        UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token
                                          , (Action <JObject>)((jsel) =>
        {
            base.OnUnloadThis();

            URemoteData.OnReceiveAvatarData(jsel["avatar"].ToString());
            AHotBase.LoadUI <UIMain>();
        }), (Action <string>)((err) =>
        {
            if (err == "3")
            {
                base.OnUnloadThis();

                AHotBase.LoadUI <UICreateAvatar>();
            }
            else
            {
                UIAlert.Show("选择角色失败," + err);
            }
        }), (err) =>
        {
            UIAlert.Show("选择角色失败," + err);
        });
    }
Esempio n. 3
0
    protected override void InitComponents()
    {
        UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token
                                          , (jres) =>
        {
            var data = new UMRemoteAvatarData();
            data.OnFormat(jres);
            UMRemoteDataManager.Instance.OnAdd(data);

            UnloadThis();
            LoadAnother <UMUIMain>();
        }, (err) =>
        {
            if (err == "3")
            {
                UnloadThis();
                LoadAnother <UMUICreateAvatar>();
            }
            else
            {
                UIAlert.Show("选择角色失败," + err);
            }
        }, (err) =>
        {
            UIAlert.Show("选择角色失败," + err);
        });
    }
Esempio n. 4
0
    protected override void InitComponents()
    {
        var inputUsername = FindWidget <InputField>("inputUsername");

        if (!string.IsNullOrEmpty(CachedUsername))
        {
            inputUsername.text = CachedUsername;
        }

        var inputPassword = FindWidget <InputField>("inputPassword");
        var btnLogin      = FindWidget <Button>("btnLogin");

        btnLogin.onClick.AddListener(() =>
        {
            if (string.IsNullOrEmpty(inputUsername.text))
            {
                return;
            }
            if (string.IsNullOrEmpty(inputPassword.text))
            {
                return;
            }
            btnLogin.enabled = false;
            var username     = inputUsername.text;
            var password     = inputPassword.text;

            UStaticWebRequests.DoLogin(username, Utils.MD5Hash(password),
                                       (jres) =>
            {
                btnLogin.enabled = true;
                CachedUsername   = jres["username"].ToString();
                token            = jres["token"].ToString();

                UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token
                                                  , (jsel) =>
                {
                    var data = new UMRemoteAvatarData();
                    data.OnFormat(jsel);
                    UMRemoteDataManager.Instance.OnAdd(data);

                    UnloadThis();
                    LoadAnother <UIMain>();
                }, (err) =>
                {
                    if (err == "3")
                    {
                        UnloadThis();
                        LoadAnother <UMUICreateAvatar>();
                    }
                    else
                    {
                        UIAlert.Show("选择角色失败," + err);
                    }
                }, (err) =>
                {
                    UIAlert.Show("选择角色失败," + err);
                });
            }
                                       , (err) =>
            {
                btnLogin.enabled = true;
                UIAlert.Show("登录失败," + err);
            }
                                       , (error) =>
            {
                btnLogin.enabled = true;
                UIAlert.Show("登录失败,网络错误:" + error);
            });
        });
        var btnRegister = FindWidget <Button>("btnRegister");

        btnRegister.onClick.AddListener(() =>
        {
            UnloadThis();

            LoadAnother <UIRegister>();
        });
    }
Esempio n. 5
0
    protected override void InitComponents()
    {
        var inputNickname = FindWidget <InputField>("inputNickname");
        var bfemale       = false;
        var btnMale       = FindWidget <Button>("btnMale");
        var maleSel       = FindWidget <Image>(btnMale.transform, "sel");
        var btnFemale     = FindWidget <Button>("btnFemale");
        var femaleSel     = FindWidget <Image>(btnFemale.transform, "sel");

        btnMale.onClick.AddListener(() =>
        {
            bfemale           = false;
            femaleSel.enabled = bfemale;
            maleSel.enabled   = !bfemale;
        });
        btnFemale.onClick.AddListener(() =>
        {
            bfemale           = true;
            femaleSel.enabled = bfemale;
            maleSel.enabled   = !bfemale;
        });
        var btnCreate = FindWidget <Button>("btnCreate");

        btnCreate.onClick.AddListener(() =>
        {
            if (string.IsNullOrEmpty(inputNickname.text))
            {
                return;
            }

            UStaticWebRequests.DoCreateAvatar(UILogin.CachedUsername, UILogin.token, inputNickname.text, bfemale ? "1" : "0"
                                              , (jcreateres) =>
            {
                UIAlert.Show("创建角色成功,正在进入游戏。", null, null, true, true);
                DelayDoSth(() =>
                {
                    UIAlert.Hide();
                    UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token
                                                      , (jselres) =>
                    {
                        var data = new UMRemoteAvatarData();
                        data.OnFormat(jselres);
                        UMRemoteDataManager.Instance.OnAdd(data);
                        UnloadThis();

                        LoadAnother <UMUIMain>();
                    }, (err) =>
                    {
                        UIAlert.Show("进入游戏失败," + err);
                    }, (err) =>
                    {
                        UIAlert.Show("进入游戏失败," + err);
                    });
                }, 3);
            }, (err) =>
            {
                UIAlert.Show("创建角色失败," + err);
            }, (err) =>
            {
                UIAlert.Show("创建角色失败," + err);
            });
        });
        var btnReturn = FindWidget <Button>("btnReturn");

        btnReturn.onClick.AddListener(() =>
        {
            UnloadThis();
            LoadAnother <UIMain>();
        });
    }