protected override void InitComponents()
    {
        var tr = FindWidget <Transform>("expBg");

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

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

            LoadAnotherUI <UIMain>();
        });

        textNovel      = FindWidget <Text>("textNovel");
        textNovel.text = GetCurPage();

        btnLeft = FindWidget <Button>("btnLeft");
        btnLeft.gameObject.SetActive(iCurPage > 0);
        btnLeft.onClick.AddListener(() =>
        {
            var c = Novels.GetContent(iCurSection, iCurPage - 1);
            if (c == null)
            {
                UIAlert.Show("已到达本章第一页。");
                btnLeft.gameObject.SetActive(true);
                return;
            }
            textNovel.text = c;
            iCurPage--;
            btnRight.gameObject.SetActive(true);
        });
        btnRight = FindWidget <Button>("btnRight");
        btnRight.gameObject.SetActive(!Novels.IsLastPage(iCurSection, iCurPage));
        btnRight.onClick.AddListener(() =>
        {
            var c = Novels.GetContent(iCurSection, iCurPage + 1);
            if (c == null)
            {
                UIAlert.Show("已到达本章最后一页。");
                btnRight.gameObject.SetActive(false);
                return;
            }
            textNovel.text = c;
            iCurPage++;
            btnLeft.gameObject.SetActive(true);
        });
    }
示例#2
0
    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);
    }