Exemple #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);
        });
    }
Exemple #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);
        });
    }
Exemple #3
0
    protected override void InitComponents()
    {
        FindWidget <Text>("textAvatarname").text = URemoteData.AvatarName;
        FindWidget <Text>("textLevel").text      = URemoteData.AvatarLevel;

        expProgress  = FindWidget <Image>("expProgress");
        textExp      = FindWidget <Text>("textExp");
        textExp.text = "";

        inputAnswer = FindWidget <InputField>("inputAnswer");

        btnGetQuestion = FindWidget <Button>("btnGetQuestion");
        btnGetQuestion.onClick.AddListener(() =>
        {
            btnGetQuestion.gameObject.SetActive(false);
            UStaticWebRequests.OnWebRequest("Question/GetOne", "username="******"&token=" + UILogin.token, jobj =>
            {
                ShowWidget("question", true);
                FindWidget <Text>("textQuestion").text = jobj["q"].ToString();
            },
                                            jfail =>
            {
                ShowWidget("question", false);
                btnGetQuestion.gameObject.SetActive(true);
            });
        });

        ShowWidget("question", false);
        btnAnswer = FindWidget <Button>("btnAnswer");
        btnAnswer.onClick.AddListener(() =>
        {
            if (string.IsNullOrEmpty(inputAnswer.text))
            {
                return;
            }
            UStaticWebRequests.OnWebRequest("Question/Answer", "username="******"&token=" + UILogin.token + "&answer=" + inputAnswer.text, jobj =>
            {
                if (jobj.ContainsKey("avatar"))
                {
                    ShowWidget("question", false);
                    URemoteData.OnReceiveAvatarData(jobj["avatar"].ToString());
                    UIAlert.Show("回答正确!");
                    btnGetQuestion.gameObject.SetActive(true);
                }
                else
                {
                    UIAlert.Show("回答错误,再好好想想吧。");
                }
            },
                                            jfail =>
            {
                UIAlert.Show("回答错误,再好好想想吧。");
            });
        });

        URemoteData.ListeningParam(InfoNameDefs.CurExp, ShowCurExp);
        URemoteData.ListeningParam(InfoNameDefs.MaxExp, ShowCurExp);
        ShowCurExp();
    }
Exemple #4
0
    protected override void InitComponents()
    {
        btnReturn = FindWidget <Button>("btnReturn");
        btnReturn.onClick.AddListener((UnityEngine.Events.UnityAction)(() =>
        {
            base.OnUnloadThis();

            URemoteData.OnLogout();
            AHotBase.LoadUI <UILogin>();
        }));

        inputNickname      = FindWidget <InputField>("inputNickname");
        inputNickname.text = "";

        btnMale = FindWidget <Button>("btnMale");
        btnMale.onClick.AddListener(() =>
        {
            bMale = true;
        });
        selMale   = FindWidget <Transform>(btnMale.transform, "sel");
        btnFemale = FindWidget <Button>("btnFemale");
        btnFemale.onClick.AddListener(() =>
        {
            bMale = false;
        });
        selFemale = FindWidget <Transform>(btnFemale.transform, "sel");
        bMale     = true;

        btnCreate = FindWidget <Button>("btnCreate");
        btnCreate.onClick.AddListener((UnityEngine.Events.UnityAction)(() =>
        {
            var nickname = inputNickname.text;
            if (string.IsNullOrEmpty(nickname))
            {
                return;
            }
            UStaticWebRequests.DoCreateAvatar(UILogin.CachedUsername, UILogin.token, nickname, bMale ? "1" : "0", (Action <Newtonsoft.Json.Linq.JObject>)(jsuccess =>
            {
                URemoteData.OnReceiveAvatarData(jsuccess["avatar"].ToString());
                base.OnUnloadThis();

                AHotBase.LoadUI <UIMain>();
            }));
        }));
    }
Exemple #5
0
    protected override void InitComponents()
    {
        btnReturn = FindWidget <Button>("btnReturn");
        btnReturn.onClick.AddListener(() =>
        {
            OnUnloadThis();

            LoadAnotherUI <UILogin>();
        });

        inputNickname      = FindWidget <InputField>("inputNickname");
        inputNickname.text = "";

        btnMale = FindWidget <Button>("btnMale");
        btnMale.onClick.AddListener(() =>
        {
            bMale = true;
        });
        selMale   = FindWidget <Transform>(btnMale.transform, "sel");
        btnFemale = FindWidget <Button>("btnFemale");
        btnFemale.onClick.AddListener(() =>
        {
            bMale = false;
        });
        selFemale = FindWidget <Transform>(btnFemale.transform, "sel");
        bMale     = true;

        btnCreate = FindWidget <Button>("btnCreate");
        btnCreate.onClick.AddListener(() =>
        {
            var nickname = inputNickname.text;
            if (string.IsNullOrEmpty(nickname))
            {
                return;
            }
            UStaticWebRequests.DoCreateAvatar(UILogin.CachedUsername, UILogin.token, nickname, bMale ? "1" : "0", jsuccess =>
            {
                URemoteData.OnReceiveAvatarData(jsuccess["avatar"].ToString());
                OnUnloadThis();

                LoadAnotherUI <UIMain>();
            });
        });
    }
Exemple #6
0
 public static void OnWebRequest(string reqUrl, string content
                                 , Action <JObject> onSuccess = null, Action <string> onFail = null, Action <string> onErr = null)
 {
     UWebSender.OnRequest(Utils.BaseURL_APIs + reqUrl, content, (res) =>
     {
         var jres = res;
         var err  = jres["err"].ToString();
         if (err == "0")
         {
             onSuccess?.Invoke(jres);
             if (jres.ContainsKey("avatar") && jres["avatar"] != null)
             {
                 URemoteData.OnReceiveAvatarData(jres["avatar"]);
             }
         }
         else
         {
             onFail?.Invoke(err);
         }
     }, (err) =>
     {
         onErr?.Invoke(err);
     });
 }
    protected override void InitComponents()
    {
        Cave0 = FindWidget <Transform>("Cave0");
        var actionHandler = new ActionHandler(Cave0.gameObject);

        actionHandler.AddAction(new ActionRun(actionHandler.handler));
        addUpdateAction(() =>
        {
            if (Input.GetMouseButtonDown(0))
            {
                actionHandler.Do <ActionRun>().Play();
            }
            if (Input.GetMouseButtonUp(0))
            {
                actionHandler.Do <ActionRun>().Stop();
            }
            return(false);
        });

        var tr = FindWidget <Transform>("expBg");

        expSlider = new WExpSlider();
        expSlider.SetGameObj(tr.gameObject);

        FindWidget <Text>("textAvatarname").text = URemoteData.AvatarName;
        ShowLevel();

        inputAnswer = FindWidget <InputField>("inputAnswer");

        btnReturn = FindWidget <Button>("btnReturn");
        btnReturn.onClick.AddListener(() =>
        {
            OnUnloadThis();

            LoadAnotherUI <UIMain>();
        });

        btnGetQuestion = FindWidget <Button>("btnGetQuestion");
        btnGetQuestion.onClick.AddListener(() =>
        {
            btnGetQuestion.gameObject.SetActive(false);
            UStaticWebRequests.OnWebRequest("Question/GetOne", "username="******"&token=" + UILogin.token, jobj =>
            {
                ShowWidget("question", true);
                FindWidget <Text>("textQuestion").text = jobj["q"].ToString();
            },
                                            jfail =>
            {
                ShowWidget("question", false);
                btnGetQuestion.gameObject.SetActive(true);
            });
        });

        ShowWidget("question", false);
        btnAnswer = FindWidget <Button>("btnAnswer");
        btnAnswer.onClick.AddListener(() =>
        {
            if (string.IsNullOrEmpty(inputAnswer.text))
            {
                return;
            }
            UStaticWebRequests.OnWebRequest("Question/Answer", "username="******"&token=" + UILogin.token + "&answer=" + inputAnswer.text, jobj =>
            {
                if (jobj.ContainsKey("avatar"))
                {
                    ShowWidget("question", false);
                    URemoteData.OnReceiveAvatarData(jobj["avatar"].ToString());
                    UIAlert.Show("回答正确!");
                    btnGetQuestion.gameObject.SetActive(true);
                }
                else
                {
                    UIAlert.Show("回答错误,再好好想想吧。");
                }
            },
                                            jfail =>
            {
                UIAlert.Show("回答错误,再好好想想吧。");
            });
        });


        URemoteData.ListeningParam(InfoNameDefs.AvatarLevel, ShowLevel);
    }
Exemple #8
0
    protected override void InitComponents()
    {
        var textUsername = FindWidget <Text>("textUsername");

        textUsername.text = URemoteData.AvatarName;
        textGold          = FindWidget <Text>("textGold");
        RefreshGold();

        var menuCell = FindWidget <Button>("menuCell");

        menuCell.gameObject.SetActive(false);

        var btnRank = FindWidget <Button>("btnRank");

        btnRank.onClick.AddListener(() =>
        {
            LoadAnotherUI <UIRank>();
        });

        var btnCheck = FindWidget <Button>("btnCheck");

        btnCheck.onClick.AddListener(() =>
        {
            UStaticWebRequests.OnWebRequest("Avatar/DailyCheck", $"username={UILogin.CachedUsername}&token={UILogin.token}", jobj =>
            {
                URemoteData.OnReceiveAvatarData(jobj["avatar"]);
            });
        });

        var btnLogout = FindWidget <Button>("btnLogout");

        btnLogout.onClick.AddListener(() =>
        {
            UStaticWebRequests.DoLogout(UILogin.CachedUsername, UILogin.token
                                        , (jres) =>
            {
                OnUnloadThis();
                LoadAnotherUI <UILogin>();
            }, (err) =>
            {
                UIAlert.Show("注销失败:" + Utils.ErrorFormat(err));
            }, (err) =>
            {
                UIAlert.Show("web error:" + err);
            });
        });

        foreach (var g in dGames)
        {
            var menu = GameObject.Instantiate(menuCell, menuCell.transform.parent);
            menu.gameObject.SetActive(true);
            menu.GetComponentInChildren <Text>().text = g.Key;
            menu.onClick.AddListener(() =>
            {
                OnUnloadThis();
                g.Value();
            });
        }

        URemoteData.ListeningParam(InfoNameDefs.AvatarGold, RefreshGold);
    }