Esempio n. 1
0
        private async void Init()
        {
            ReferenceCollector rc = this.GetEntity <UI>().GameObject.GetComponent <ReferenceCollector>();

            //添加事件
            rc.Get <GameObject>("StartMatch").GetComponent <Button>().onClick.Add(OnStartMatch);

            //获取玩家数据
            long           userId         = ClientComponent.Instance.LocalPlayer.UserID;
            GetUserInfo_RT getUserInfo_RT = new GetUserInfo_RT()
            {
                UserID = userId
            };
            GetUserInfo_RE getUserInfoRE = await SessionComponent.Instance.Session.Call <GetUserInfo_RE>(getUserInfo_RT);

            if (getUserInfoRE.Error == ErrorCode.ERR_QueryUserInfoError)
            {
                Log.Error("获取玩家信息异常 << " + MongoHelper.ToJson(getUserInfo_RT));
                return;
            }
            else
            {
                rc.Get <GameObject>("NickName").GetComponent <Text>().text = getUserInfoRE.NickName;
                rc.Get <GameObject>("Money").GetComponent <Text>().text    = getUserInfoRE.Money.ToString();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 设置用户信息
        /// </summary>
        /// <param name="id"></param>
        private async void SetUserInfo()
        {
            GetUserInfo_RE getUserInfoRE = await SessionComponent.Instance.Session.Call <GetUserInfo_RE>(new GetUserInfo_RT()
            {
                UserID = this.GetEntity <Gamer>().UserID
            });

            if (getUserInfoRE.Error == ErrorCode.ERR_QueryUserInfoError)
            {
                return;
            }

            name.text  = getUserInfoRE.NickName;
            money.text = getUserInfoRE.Money.ToString();
        }