コード例 #1
0
 public static void DoLogout(string username, string token
                             , Action <JObject> onSuccess = null, Action <string> onFail = null, Action <string> onErr = null)
 {
     URemoteData.OnRemoveAvatarData();
     OnWebRequest("Login/Logout", "username="******"&token=" + token
                  , onSuccess, onFail, onErr);
 }
コード例 #2
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);
        });
    }
コード例 #3
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);
        });
    }
コード例 #4
0
ファイル: UMMO.cs プロジェクト: miuleung/ILRuntime_HotGames
    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();
    }
コード例 #5
0
    protected override void InitComponents()
    {
        expProgress  = FindWidget <Image>("expProgress");
        textExp      = FindWidget <Text>("textExp");
        textExp.text = "";

        URemoteData.ListeningParam(InfoNameDefs.CurExp, ShowCurExp);
        URemoteData.ListeningParam(InfoNameDefs.MaxExp, ShowCurExp);

        RefreshUI();

        gameObj.AddComponent <UOnDestroy>().actionOnDestroy = () =>
        {
            URemoteData.CancelListeningParam(InfoNameDefs.CurExp, ShowCurExp);
            URemoteData.CancelListeningParam(InfoNameDefs.MaxExp, ShowCurExp);
        };
    }
コード例 #6
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>();
            }));
        }));
    }
コード例 #7
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>();
            });
        });
    }
コード例 #8
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);
     });
 }
コード例 #9
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);
    }
コード例 #10
0
 protected override void OnDestroy()
 {
     URemoteData.CancelListeningParam(InfoNameDefs.AvatarLevel, ShowLevel);
 }
コード例 #11
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);
    }
コード例 #12
0
 private void RefreshGold()
 {
     textGold.text = URemoteData.OnGetParam(InfoNameDefs.AvatarGold);
 }
コード例 #13
0
 protected override void OnDestroy()
 {
     URemoteData.CancelListeningParam(InfoNameDefs.AvatarGold, RefreshGold);
 }
コード例 #14
0
    protected override void InitComponents()
    {
        textAvatarname      = FindWidget <Text>("textAvatarname");
        textAvatarname.text = URemoteData.AvatarName;

        textGold = FindWidget <Text>("textGold");
        ShowGold();

        btnReturn = FindWidget <Button>("btnReturn");
        btnReturn.onClick.AddListener((UnityEngine.Events.UnityAction)(() =>
        {
            base.OnUnloadThis();

            AHotBase.LoadUI <UIMain>();
        }));

        var bbig       = false;
        var bsmall     = false;
        var bigorsmall = FindWidget <Transform>("bigorsmall");
        var big        = FindWidget <Toggle>(bigorsmall.transform, "big");

        big.onValueChanged.AddListener(value => { bbig = value; });
        var small = FindWidget <Toggle>(bigorsmall.transform, "small");

        small.onValueChanged.AddListener(value => { bsmall = value; });

        var multis   = FindWidget <Transform>("multis");
        var curMulti = 0;

        foreach (var w in ClientValueDefs.CaiDaXiaoMultis)
        {
            var t  = FindWidget <Toggle>(multis, $"m{w}");
            var tw = w;
            t.onValueChanged.AddListener((value) =>
            {
                if (value)
                {
                    curMulti = tw;
                }
                else if (curMulti == tw)
                {
                    curMulti = 0;
                }
            });
        }

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

        btnConfirm.onClick.AddListener(() =>
        {
            if (!bbig && !bsmall)
            {
                return;
            }
            if (curMulti == 0)
            {
                return;
            }
            UStaticWebRequests.OnWebRequest("Avatar/CaiDaXiao", $"{UILogin.CachedUsernameAndTokenArguments}&multi={curMulti}&isBig={(bbig ? "1" : "0")}", jobj =>
            {
                var res = jobj["res"].ToString();
                UIAlert.Show($"猜大小结果:{res}");
            });
        });

        URemoteData.ListeningParam(InfoNameDefs.AvatarGold, ShowGold);
    }
コード例 #15
0
 protected override void OnDestroy()
 {
     URemoteData.CancelListeningParam(InfoNameDefs.CurExp, ShowCurExp);
     URemoteData.CancelListeningParam(InfoNameDefs.MaxExp, ShowCurExp);
 }
コード例 #16
0
    protected override void InitComponents()
    {
        mycard = FindWidget <RawImage>("mycard");
        mycard.gameObject.SetActive(false);
        var btn = mycard.gameObject.AddComponent <Button>();

        btn.onClick.AddListener(() =>
        {
            if (whosTurn != UILogin.CachedUsername)
            {
                UICommonTips.AddTip("还没轮到你出牌。");
                return;
            }
            mycard.color = Color.grey;
            WebSocketConnector.Instance.OnRemoteCall("roomOp", "");
        });
        othercard = FindWidget <RawImage>("othercard");
        othercard.gameObject.SetActive(false);
        var bgpath = new string[] { "Images/Pai/bg1", "Images/Pai/bg2" };

        UHotAssetBundleLoader.Instance.OnDownloadResources(() =>
        {
            mycard.texture    = UHotAssetBundleLoader.Instance.OnLoadAsset <Texture2D>(bgpath[random.Next(bgpath.Length)]);
            othercard.texture = UHotAssetBundleLoader.Instance.OnLoadAsset <Texture2D>(bgpath[random.Next(bgpath.Length)]);
        }, bgpath);

        textMyCardCount      = FindWidget <Text>("textMyCardCount");
        textMyCardCount.text = "0";

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

        textMyLevel = FindWidget <Text>("textMyLevel");
        ShowLevel();

        textOtherCardCount      = FindWidget <Text>("textOtherCardCount");
        textOtherCardCount.text = "0";

        textOtherLevel      = FindWidget <Text>("textOtherLevel");
        textOtherAvatarname = FindWidget <Text>("textOtherAvatarname");

        RegisterReturnButton();

        btnJoinRoom = FindWidget <Button>("btnJoinRoom");
        btnJoinRoom.onClick.AddListener(() =>
        {
            WebSocketConnector.Instance.OnRemoteCall("joinRoom", "老牛赶大车");
        });

        cardcell = FindWidget <Transform>("cardcell");
        cardcell.gameObject.SetActive(false);

        otherinfo = FindWidget <Transform>("otherinfo");
        otherinfo.gameObject.SetActive(false);
        URemoteData.ListeningParam(InfoNameDefs.AvatarLevel, ShowLevel);

        UICommonWait.Show();
        WebSocketConnector.Instance.OnInit(Utils.WebSocketURL + UILogin.CachedUsernameAndTokenArguments, evt =>
        {
            UICommonWait.Hide();
        }, msgEvt =>
        {
        }, errEvt =>
        {
        }, closeEvt =>
        {
        });

        WebSocketConnector.Instance.OnRegisterResponse("enter", OnJoinRoomCB);
        WebSocketConnector.Instance.OnRegisterResponse("cardsync", OnCardsSync);
        WebSocketConnector.Instance.OnRegisterResponse("result", OnResult);
        WebSocketConnector.Instance.OnRegisterResponse("dismissed", OnDismissed);
    }
コード例 #17
0
 protected override void OnDestroy()
 {
     URemoteData.CancelListeningParam(InfoNameDefs.AvatarLevel, ShowLevel);
     WebSocketConnector.Instance.OnCloseImmediately();
 }
コード例 #18
0
 public void OnSetParam(string param, string value)
 {
     dParams[param] = value;
     URemoteData.OnParamChnaged(param);
 }