OtherRoleInfoView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ET;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.RoleInfo;
  5. namespace GFGGame
  6. {
  7. public class OtherRoleInfoView : BaseWindow
  8. {
  9. private UI_OtherRoleInfoUI _ui;
  10. private OtherRoleInfoData _roleInfo;
  11. private OtherRoleInfoDetailData _roleDetailInfo;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. }
  18. _ui = null;
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_OtherRoleInfoUI.PACKAGE_NAME;
  25. _ui = UI_OtherRoleInfoUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  29. _ui.m_list.itemRenderer = RenderListItem;
  30. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  31. }
  32. protected override void AddEventListener()
  33. {
  34. base.AddEventListener();
  35. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  36. }
  37. protected override async void OnShown()
  38. {
  39. base.OnShown();
  40. _roleInfo = (this.viewData as object[])[0] as OtherRoleInfoData;
  41. _roleDetailInfo = (this.viewData as object[])[1] as OtherRoleInfoDetailData;
  42. _ui.m_txtRoleName.text = _roleInfo.roleName;
  43. _ui.m_txtLvl.text = _roleInfo.roleLv.ToString();
  44. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(_roleInfo.roleHead);
  45. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(_roleInfo.roleHeadBorder);
  46. UI_ComHead comHead = UI_ComHead.Proxy(_ui.m_comHead);
  47. comHead.m_loaIcon.url = ResPathUtil.GetHeadPath(headCfg.res);
  48. comHead.m_loaBorder.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  49. UI_ComHead.ProxyEnd();
  50. OtherRoleInfoDetailData roleInfoDetail = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_roleInfo.roleId);
  51. if (roleInfoDetail != null)
  52. {
  53. Timers.inst.StartCoroutine(PictureStorageHelper.Download(roleInfoDetail.showPhotoList));
  54. }
  55. }
  56. protected override void OnHide()
  57. {
  58. base.OnHide();
  59. }
  60. private void OnBtnBackClick()
  61. {
  62. ViewManager.GoBackFrom(typeof(OtherRoleInfoData).FullName);
  63. }
  64. protected override void RemoveEventListener()
  65. {
  66. base.RemoveEventListener();
  67. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  68. }
  69. private void UpdateView()
  70. {
  71. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(_roleInfo.roleLv);
  72. if (roleLevelCfg.exp > 0)
  73. {
  74. _ui.m_txtExp.text = string.Format("{0}/{1}", _roleDetailInfo.RoleExp, roleLevelCfg.exp);
  75. }
  76. else
  77. {
  78. _ui.m_txtExp.text = "已满级";
  79. }
  80. _ui.m_txtSlogan.text = _roleDetailInfo.slogan;
  81. _ui.m_btnFieldGuide.title = string.Format("套装收集度:{0}", _roleDetailInfo.SuitCollectPer);
  82. _ui.m_list.numItems = _roleDetailInfo.showPhotoList.Count;
  83. }
  84. private void RenderListItem(int index, GObject obj)
  85. {
  86. PoemPhotoData poemPhotoData = _roleDetailInfo.showPhotoList[index];
  87. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  88. item.m_comPhoto.m_loaPhoto.texture = poemPhotoData == null ? null : poemPhotoData.Ntexture;
  89. item.target.data = index;
  90. UI_ListPhotoItem.ProxyEnd();
  91. }
  92. }
  93. }