/// <summary> /// 设置我的战绩榜信息 /// </summary> private void SetMyGameRank() { string str = ""; if (!isGameRank) { RankTxt.gameObject.SetActive(true); RankImg.SetActive(false); str = "未上榜"; } else { if (ownGame < 3) { RankTxt.gameObject.SetActive(false); RankImg.SetActive(true); string iconName = new StringBuilder().Append("Rank_") .Append(ownGame + 1).ToString(); RankImg.GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_main", iconName); } else { RankTxt.gameObject.SetActive(true); RankImg.SetActive(false); str = (ownGame + 1).ToString(); } } RankTxt.text = str; NameTxt.text = ownGameRank.PlayerName; GoldTxt.text = new StringBuilder().Append(ownGameRank.WinCount) .ToString(); Img.sprite = CommonUtil.getSpriteByBundle("image_main", "win"); RewardBtn.gameObject.SetActive(g2cWeek.IsGetGameRank); HeadManager.setHeadSprite(Icon, PlayerInfoComponent.Instance.GetPlayerInfo().Icon); }
public void SetFlowGame(Actor_GameFlow message, GamerComponent gamerComponent) { Gamer[] gamers = gamerComponent.GetAll(); for (int i = 0; i < gamers.Length; i++) { if (gamers[i] == null) { continue; } if (gamers[i].UserID == PlayerInfoComponent.Instance.uid) { playerList.Insert(i, winPlayer); } } for (int i = 0; i < gamers.Length; i++) { Gamer gamer = gamers[i]; GameObject gameObject = this.playerList[i]; Image headImage = gameObject.transform.Find("head").GetComponent <Image>(); Text nameText = gameObject.transform.Find("name").GetComponent <Text>(); Text goldText = gameObject.transform.Find("Text_gold").GetComponent <Text>(); HeadManager.setHeadSprite(headImage, gamer.PlayerInfo.Icon); nameText.text = gamer.PlayerInfo.Name; goldText.text = 0 + ""; } winPlayer.transform.Find("hupaiType").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_gameresult", "gameresult_liuju"); }
/// <summary> /// 刷新数据 /// </summary> public void refreshUI() { PlayerInfo info = PlayerInfoComponent.Instance.GetPlayerInfo(); HeadManager.setHeadSprite(playerIcon, info.Icon); HeadManager.setHeadSprite(Icon, info.Icon); playerNameTxt.text = info.Name; goldNumTxt.text = info.GoldNum.ToString(); wingNumTxt.text = info.WingNum.ToString(); HuaFeiNumTxt.text = (info.HuaFeiNum / 100.0f).ToString(); ScoreTxt.text = info.Score.ToString(); if (GameUtil.isVIP()) { PlayerInfoBg.transform.Find("HeadKuang").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_main", "touxiangkuang_vip"); } if (PlayerInfoComponent.Instance.GetPlayerInfo().IsRealName) { if (RealNameTip != null) { RealNameTip.transform.localScale = Vector3.zero; } } }
private void CreateItems(List <string> iconNames) { GameObject obj = null; for (int i = 0; i < iconNames.Count; ++i) { if (i < icons.Count) { obj = icons[i]; } else { obj = GameObject.Instantiate(icon, FriendGrid.transform); icons.Add(obj); } HeadManager.setHeadSprite(obj.GetComponent <Image>(), iconNames[i]); } for (int i = iconNames.Count; i < iconCount; ++i) { if (i < icons.Count) { obj = icons[i]; } else { obj = obj = GameObject.Instantiate(icon, FriendGrid.transform); icons.Add(obj); } HeadManager.setHeadSprite(obj.GetComponent <Image>(), "None"); } }
/// <summary> /// 添加玩家 /// </summary> /// <param name="gamer"></param> /// <param name="index"></param> public void AddGamer(Gamer gamer, int index) { try { GetParent <UI>().GetComponent <GamerComponent>().Add(gamer, index); gamer.GetComponent <GamerUIComponent>().SetPanel(this.GamersPanel[index], this.HeadPanel[index], index); HeadManager.setHeadSprite(gamer.GetComponent <GamerUIComponent>().head, gamer.PlayerInfo.Icon); } catch (Exception e) { Log.Error(e); } }
public async void Awake() { ReferenceCollector rc = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); CurIconFrame = rc.Get <GameObject>("CurIconFrame"); returnBtn = rc.Get <GameObject>("ReturnBtn").GetComponent <Button>(); saveBtn = rc.Get <GameObject>("SaveBtn").GetComponent <Button>(); grid = rc.Get <GameObject>("Grid"); curIcon = rc.Get <GameObject>("CurIcon").GetComponent <Image>(); tip = rc.Get <GameObject>("Tip"); sureBtn = rc.Get <GameObject>("SureBtn").GetComponent <Button>(); iconObj = CommonUtil.getGameObjByBundle(UIType.UIIconItem); curIconStr = Game.Scene.GetComponent <PlayerInfoComponent>().GetPlayerInfo().Icon; // 设置头像 { HeadManager.setHeadSprite(curIcon, PlayerInfoComponent.Instance.GetPlayerInfo().Icon); } GetOwnIcon(); CreatePlayerIconList(); returnBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIIcon); }); saveBtn.onClick.Add(() => { tip.SetActive(true); UpdateIcon(); }); sureBtn.onClick.Add(() => { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIIcon); }); if (GameUtil.isVIP()) { CurIconFrame.transform.Find("HeadKuang").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_main", "touxiangkuang_vip"); } }
public void Update() { HeadManager.setHeadSprite(playerIcon.GetComponent <Image>(), PlayerInfoComponent.Instance.GetPlayerInfo().Icon); nameTxt.text = PlayerInfoComponent.Instance.GetPlayerInfo().Name; if (PlayerInfoComponent.Instance.GetPlayerInfo().RestChangeNameCount <= 0) { changeNameBtn.gameObject.SetActive(false); changeNameBtn.transform.parent.gameObject.SetActive(false); } if (GameUtil.isVIP()) { VipTimeTxt.text = $"过期时间:{CommonUtil.splitStr_Start_str(PlayerInfoComponent.Instance.GetPlayerInfo().VipTime, ' ')}"; } else { VipTimeTxt.text = ""; } changeNameBtn.gameObject.SetActive(PlayerInfoComponent.Instance.GetPlayerInfo().RestChangeNameCount > 0); changeNameBtn.transform.parent.gameObject.SetActive(PlayerInfoComponent.Instance.GetPlayerInfo().RestChangeNameCount > 0); realNameBtn.gameObject.SetActive(!PlayerInfoComponent.Instance.GetPlayerInfo().IsRealName&& !OtherData.getIsShiedRealName()); realNameBtn.transform.parent.gameObject.SetActive(!PlayerInfoComponent.Instance.GetPlayerInfo().IsRealName&& !OtherData.getIsShiedRealName()); realNameTxt.gameObject.SetActive(!OtherData.getIsShiedRealName()); noBindPhoneTxt.gameObject.SetActive(!OtherData.getIsShiedBindPhone()); if (PlayerInfoComponent.Instance.GetPlayerInfo().IsRealName) { realNameTxt.text = "已实名"; realNameBtn.gameObject.SetActive(false); realNameBtn.transform.parent.gameObject.SetActive(false); } if (!string.IsNullOrEmpty(PlayerInfoComponent.Instance.GetPlayerInfo().Phone)) { noBindPhoneTxt.text = "已绑定"; bindPhoneBtn.gameObject.SetActive(false); bindPhoneBtn.transform.parent.gameObject.SetActive(false); } GoldNumTxt.text = PlayerInfoComponent.Instance.GetPlayerInfo().GoldNum.ToString(); }
/// <summary> /// 设置用户信息 /// </summary> private async Task SetPlayerInfo() { long uid = PlayerInfoComponent.Instance.uid; G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo() { uid = uid }); if (g2CPlayerInfo == null) { Debug.Log("用户信息错误"); return; } PlayerInfoComponent.Instance.SetPlayerInfo(g2CPlayerInfo.PlayerInfo); refreshUI(); // 设置头像 { HeadManager.setHeadSprite(playerIcon, PlayerInfoComponent.Instance.GetPlayerInfo().Icon); } }
public void SetGameItem(GameRank gameRank, int index) { RankImg.gameObject.SetActive(index < 3); RankTxt.gameObject.SetActive(index >= 3); NameTxt.text = gameRank.PlayerName; Img.sprite = CommonUtil.getSpriteByBundle("image_main", "win"); GoldTxt.text = new StringBuilder().Append(gameRank.WinCount) .ToString(); if (RankTxt.gameObject.activeInHierarchy) { RankTxt.text = (index + 1).ToString(); } HeadManager.setHeadSprite(Icon, gameRank.Icon); string rIcon = new StringBuilder().Append("Rank_") .Append(index + 1) .ToString(); if (RankImg.gameObject.activeInHierarchy) { RankImg.sprite = CommonUtil.getSpriteByBundle("image_main", rIcon); } }
public void SetGoldItem(WealthRank wealth, int index) { RankImg.gameObject.SetActive(index < 3); RankTxt.gameObject.SetActive(index >= 3); if (RankTxt.gameObject.activeInHierarchy) { RankTxt.text = (index + 1).ToString(); } NameTxt.text = wealth.PlayerName; GoldTxt.text = new StringBuilder().Append(wealth.GoldNum) .ToString(); Img.sprite = CommonUtil.getSpriteByBundle("image_shop", "icon_jinbi"); HeadManager.setHeadSprite(Icon, wealth.Icon); string rIcon = new StringBuilder().Append("Rank_") .Append(index + 1) .ToString(); if (RankImg.gameObject.activeInHierarchy) { RankImg.sprite = CommonUtil.getSpriteByBundle("image_main", rIcon); } }
public void setData(Actor_GamerHuPai data, GamerComponent gamerComponent, int BeiLv) { this.huPaiNeedData = data; Gamer[] gamers = gamerComponent.GetAll(); Gamer huPaiGamer = gamerComponent.Get(data.Uid); for (int i = 0; i < gamers.Length; i++) { if (gamers[i] == null) { continue; } if (gamers[i].UserID == data.Uid) { playerList.Insert(i, winPlayer); } } int huaCount = 0; //设置胡牌的花数 List <int> dataHuPaiTypes = data.HuPaiTypes; for (int j = 0; j < dataHuPaiTypes.Count; j++) { Consts.HuPaiType huPaiType = (Consts.HuPaiType)dataHuPaiTypes[j]; int count; Logic_NJMJ.getInstance().HuPaiHuaCount.TryGetValue(huPaiType, out count); //胡牌花 huaCount += count; } //硬花 huaCount += data.YingHuaCount; //软花 huaCount += data.RuanHuaCount; huaCount += data.BixiaHuCount; //基数 huaCount += 20; //砸2 huaCount *= 2; //设置胡牌的人 for (int i = 0; i < gamers.Length; i++) { Gamer gamer = gamers[i]; GameObject gameObject = this.playerList[i]; Image headImage = gameObject.transform.Find("head").GetComponent <Image>(); Text nameText = gameObject.transform.Find("name").GetComponent <Text>(); Text goldText = gameObject.transform.Find("Text_gold").GetComponent <Text>(); //headImage.sprite = CommonUtil.getSpriteByBundle("playericon", gamer.PlayerInfo.Icon); HeadManager.setHeadSprite(headImage, gamer.PlayerInfo.Icon); nameText.text = gamer.PlayerInfo.Name + ""; //胡牌的ui if (gamer.UserID == data.Uid) { Text huaCountText = gameObject.Get <GameObject>("Text").GetComponent <Text>(); GameObject allhuashutype = gameObject.Get <GameObject>("Allhuashutype"); Text obj1 = allhuashutype.transform.GetChild(0).GetComponent <Text>(); Text obj2 = allhuashutype.transform.GetChild(1).GetComponent <Text>(); Text obj3 = allhuashutype.transform.GetChild(2).GetComponent <Text>(); obj1.gameObject.SetActive(true); obj2.gameObject.SetActive(true); obj3.gameObject.SetActive(true); obj1.text = $"硬花{data.YingHuaCount}"; obj2.text = $"软花{data.RuanHuaCount}"; obj3.text = $"基数{20}"; //胡牌类型 for (int j = 0; j < dataHuPaiTypes.Count; j++) { Consts.HuPaiType huPaiType = (Consts.HuPaiType)dataHuPaiTypes[j]; int count; string name; Logic_NJMJ.getInstance().HuPaiHuaCount.TryGetValue(huPaiType, out count); Logic_NJMJ.getInstance().HuPaiHuaName.TryGetValue(huPaiType, out name); Text obj = allhuashutype.transform.GetChild(j + 3).gameObject.GetComponent <Text>(); obj.gameObject.SetActive(true); obj.text = $"{name}{count}"; } if (data.BixiaHuCount > 0) { Text obj4 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 3).GetComponent <Text>(); obj4.gameObject.SetActive(true); obj4.text = $"比下胡{data.BixiaHuCount}"; Text obj5 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 4).GetComponent <Text>(); obj5.gameObject.SetActive(true); obj5.text = "砸2"; } else { Text obj4 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 3).GetComponent <Text>(); obj4.gameObject.SetActive(true); obj4.text = "砸2"; } huaCountText.text = huaCount + ""; if (data.IsZiMo) { goldText.text = BeiLv * huaCount * 3 + ""; } else { goldText.text = BeiLv * huaCount + ""; } } else { if (data.IsZiMo) { if (BeiLv * huaCount == 0) { goldText.text = "0"; } else { goldText.text = "-" + BeiLv * huaCount + ""; } } else { if (gamer.UserID == data.FangPaoUid) { if (BeiLv * huaCount == 0) { goldText.text = "0"; } else { goldText.text = "-" + BeiLv * huaCount + ""; } nameText.color = Color.yellow; } } } } if (huPaiNeedData.IsZiMo) { winPlayer.transform.Find("hupaiType").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_gameresult", "gameresult_hu"); } SetHuPaiPlayerData(); }
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 void ShowPlayerIcon() { PlayerInfo playerInfo = this.GetParent <Gamer>().PlayerInfo; HeadManager.setHeadSprite(head, playerInfo.Icon); }
// 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); } }