/// <summary> /// 设置用户信息 /// </summary> /// <param name="id"></param> private async void SetUserInfo() { PlayerInfo playerInfo = this.GetParent <Gamer>().PlayerInfo; if (this.Panel != null || playerInfo == null) { name.text = playerInfo.Name; head.sprite = Game.Scene.GetComponent <UIIconComponent>().GetSprite(playerInfo.Icon); if (Index != 0) { uidText.text = playerInfo.Name; if (UIRoomComponent.IsFriendRoom) { jinbiText.text = $"积 分:<color=#FFF089FF>{playerInfo.Score}</color>"; } else { jinbiText.text = $"金 币:<color=#FFF089FF>{playerInfo.GoldNum}</color>"; } float i; if (playerInfo.TotalGameCount == 0) { i = 0; } else { i = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount); } shengLvText.text = $"胜 率:<color=#FFF089FF>{i}%</color>"; if (GameUtil.isVIP(playerInfo)) { head.transform.Find("vip").transform.localScale = Vector3.one; } else { head.transform.Find("vip").transform.localScale = Vector3.zero; } } } }
public async void Awake() { ReferenceCollector rc = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); nameTxt = rc.Get <GameObject>("NameTxt").GetComponent <Text>(); uIDTxt = rc.Get <GameObject>("UIDTxt").GetComponent <Text>(); realNameTxt = rc.Get <GameObject>("RealNameTxt").GetComponent <Text>(); noBindPhoneTxt = rc.Get <GameObject>("NoBindPhoneTxt").GetComponent <Text>(); HuafeiNumTxt = rc.Get <GameObject>("HuafeiNumTxt").GetComponent <Text>(); AlPlayTxt = rc.Get <GameObject>("AlPlayTxt").GetComponent <Text>(); WinGameTxt = rc.Get <GameObject>("WinGameTxt").GetComponent <Text>(); SuccessRateTxt = rc.Get <GameObject>("SuccessRateTxt").GetComponent <Text>(); MaxSuccessTxt = rc.Get <GameObject>("MaxSuccessTxt").GetComponent <Text>(); VipTimeTxt = rc.Get <GameObject>("VipTimeTxt").GetComponent <Text>(); returnBtn = rc.Get <GameObject>("ReturnBtn").GetComponent <Button>(); playerIcon = rc.Get <GameObject>("PlayerIcon").GetComponent <Button>(); changeNameBtn = rc.Get <GameObject>("ChangeNameBtn").GetComponent <Button>(); realNameBtn = rc.Get <GameObject>("RealNameBtn").GetComponent <Button>(); bindPhoneBtn = rc.Get <GameObject>("BindPhoneBtn").GetComponent <Button>(); ChangeAccountBtn = rc.Get <GameObject>("ChangeAccountBtn").GetComponent <Button>(); DuihuanBtn = rc.Get <GameObject>("DuihuanBtn").GetComponent <Button>(); De = rc.Get <GameObject>("De").GetComponent <Button>(); GoldNumTxt = rc.Get <GameObject>("GoldNumTxt").GetComponent <Text>(); WingNumTxt = rc.Get <GameObject>("WingNumTxt").GetComponent <Text>(); AddBtn = rc.Get <GameObject>("AddBtn").GetComponent <Button>(); DuihuanBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Create(UIType.UIUseHuaFei); }); AddBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIPlayerInfo); Game.Scene.GetComponent <UIComponent>().Create(UIType.UIShop); }); PlayerFrame = rc.Get <GameObject>("PlayerFrame"); bindPhoneBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Create(UIType.UIBindPhone); }); realNameBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Create(UIType.UIRealName); }); returnBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Get(UIType.UIMain).GetComponent <UIMainComponent>().SetUIHideOrOpen(true); Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIPlayerInfo); if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIVIP) != null) { if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIVIP).GameObject.activeInHierarchy) { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIVIP); } } }); changeNameBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Create(UIType.UIChangeName); }); ChangeAccountBtn.onClick.Add(() => { onClickChangeAccount(); }); De.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Create(UIType.UIVIP); }); PlayerInfoComponent pc = Game.Scene.GetComponent <PlayerInfoComponent>(); PlayerInfo playerInfo = pc.GetPlayerInfo(); nameTxt.text = playerInfo.Name; uIDTxt.text = pc.uid.ToString(); AlPlayTxt.text = $"已玩牌局:{ playerInfo.TotalGameCount}"; string winRate = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount).ToString(); if (winRate.Equals(0)) { SuccessRateTxt.text = $"胜 率:{0}%"; } else { SuccessRateTxt.text = $"胜 率:{winRate}%"; } MaxSuccessTxt.text = $"最大赢取:{playerInfo.MaxHua}"; WinGameTxt.text = $"获胜局数:{ playerInfo.WinGameCount}"; if (playerInfo.IsRealName) { realNameTxt.text = "已实名"; } if (!string.IsNullOrEmpty(playerInfo.Phone)) { noBindPhoneTxt.text = "已绑定"; } // 设置头像 { HeadManager.setHeadSprite(playerIcon.GetComponent <Image>(), PlayerInfoComponent.Instance.GetPlayerInfo().Icon); } playerIcon.onClick.Add(() => { CommonUtil.ShowUI(UIType.UIIcon); }); Init(); }
// public async Task GetPlayerInfo() // { // tokenSource = new CancellationTokenSource(); // try // { // Gamer gamer = this.GetParent<Gamer>(); // Log.Debug("请求gamer信息:" + gamer.UserID); // G2C_PlayerInfo playerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo() { uid = gamer.UserID }, tokenSource.Token); // gamer.PlayerInfo = playerInfo.PlayerInfo; // } // catch (Exception e) // { // Log.Error(e); // tokenSource.Cancel(); // } // } /// <summary> /// 设置准备界面 /// </summary> /// <param name="gameObject"></param> public void SetHeadPanel(GameObject gameObject, int index) { try { if (gameObject == null) { return; } Index = index; Gamer gamer = this.GetParent <Gamer>(); this.readyHead = gameObject.Get <GameObject>("Image").GetComponent <Image>(); this.readyName = gameObject.Get <GameObject>("Name").GetComponent <Text>(); this.readyText = gameObject.Get <GameObject>("Text").GetComponent <Text>(); this.vip = gameObject.Get <GameObject>("vip"); PlayerInfo playerInfo = gamer.PlayerInfo; if (readyName == null) { return; } readyName.text = playerInfo.Name + ""; HeadManager.setHeadSprite(readyHead, playerInfo.Icon); if (gamer.IsReady) { gameObject.transform.Find("Text").GetComponent <Text>().text = "已准备"; } else { readyText.text = ""; } if (GameUtil.isVIP(playerInfo)) { vip.transform.localScale = Vector3.one; } else { vip.transform.localScale = Vector3.zero; } #region 准备界面信息框 // if(Index != 0) { this.headReadyInfo = gameObject.Get <GameObject>("HeadInfo"); Image kickOffImage = this.headReadyInfo.Get <GameObject>("KickOffImage").GetComponent <Image>(); Text uidReadyText = this.headReadyInfo.Get <GameObject>("Uid").GetComponent <Text>(); Text shenglvReadyText = this.headReadyInfo.Get <GameObject>("Shenglv").GetComponent <Text>(); Text jinbiReadyText = this.headReadyInfo.Get <GameObject>("Jinbi").GetComponent <Text>(); this.headReadyInfo.SetActive(false); this.headReadyInfo.GetComponentInParent <Button>().onClick.RemoveAllListeners(); this.headReadyInfo.GetComponentInParent <Button>().onClick.Add(() => { if (this.headReadyInfo.activeSelf) { this.headReadyInfo.SetActive(false); } else { this.headReadyInfo.SetActive(true); } }); uidReadyText.text = playerInfo.Name; UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); this.uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); if (UIRoomComponent.IsFriendRoom) { shenglvReadyText.text = $"积 分:<color=#FFF089FF>{playerInfo.Score}</color>"; } else { shenglvReadyText.text = $"金 币:<color=#FFF089FF>{playerInfo.GoldNum}</color>"; } float i; if (playerInfo.TotalGameCount == 0) { i = 0; } else { i = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount); } jinbiReadyText.text = $"胜 率:<color=#FFF089FF>{i}%</color>"; //踢人 if (uiRoomComponent.masterUserId != 0 && uiRoomComponent.masterUserId == PlayerInfoComponent.Instance.uid && Index != 0) { kickOffImage.gameObject.SetActive(true); } else { kickOffImage.gameObject.SetActive(false); } kickOffImage.gameObject.GetComponent <Button>().onClick.Add(() => { SessionComponent.Instance.Session.Send(new Actor_GamerKickOff() { KickedUserId = gamer.UserID }); }); } #endregion } catch (Exception e) { Log.Error(e); } }