RoleInfoView.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using ET;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.RoleInfo;
  5. namespace GFGGame
  6. {
  7. public class RoleInfoView : BaseWindow
  8. {
  9. private UI_RoleInfoUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. }
  16. _ui = null;
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_RoleInfoUI.PACKAGE_NAME;
  23. _ui = UI_RoleInfoUI.Create();
  24. this.viewCom = _ui.target;
  25. isfullScreen = true;
  26. _ui.m_txtVersion.text = GameGlobal.version;
  27. _ui.m_txtSlogan.maxLength = GlobalCfgArray.globalCfg.maxSloganWordsCount;
  28. _ui.m_btnHelp.onClick.Add(OnClickBtnHelp);
  29. _ui.m_txtSlogan.onFocusOut.Add(OnFocuseOut);
  30. _ui.m_loaChangeName.onClick.Add(OnClickLoaChangeName);
  31. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  32. _ui.m_btnFieldGuide.onClick.Add(OnBtnFieldGuideClick);
  33. _ui.m_btnSkill.onClick.Add(OnBtnSkillClick);
  34. _ui.m_btnSetting.onClick.Add(OnBtnSettingClick);
  35. _ui.m_comHead.onClick.Add(OnComHeadClick);
  36. _ui.m_list.itemRenderer = RenderListItem;
  37. _ui.m_list.onClickItem.Add(OnListItemClick);
  38. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  44. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_HEAD, UpdateHead);
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  50. _ui.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  51. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  52. if (roleLevelCfg.exp > 0)
  53. {
  54. _ui.m_txtExp.text = string.Format("{0}/{1}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp), roleLevelCfg.exp);
  55. }
  56. else
  57. {
  58. _ui.m_txtExp.text = "已满级";
  59. }
  60. _ui.m_txtSlogan.text = RoleDataManager.slogan;
  61. _ui.m_btnFieldGuide.title = string.Format("套装收集度:{0}%", RoleInfoManager.Instance.GetGuideProgress());
  62. _ui.m_list.numItems = RoleDataManager.photoDatas.Count;
  63. UpdateHead();
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. }
  69. private void OnBtnBackClick()
  70. {
  71. ViewManager.GoBackFrom(typeof(RoleInfoView).FullName);
  72. }
  73. protected override void RemoveEventListener()
  74. {
  75. base.RemoveEventListener();
  76. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  77. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_HEAD, UpdateHead);
  78. }
  79. private void UpdateRoleName()
  80. {
  81. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  82. }
  83. private void UpdateHead()
  84. {
  85. RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId);
  86. }
  87. private void RenderListItem(int index, GObject obj)
  88. {
  89. long pictureId = RoleDataManager.photoDatas[index];
  90. PoemPhotoData poemPhotoData = pictureId == 0 ? null : PoemPhotoDataManager.Instance.GetPersonalPhotoDataById(pictureId);
  91. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  92. item.m_comPhoto.m_loaPhoto.texture = poemPhotoData == null ? null : poemPhotoData.Ntexture;
  93. item.target.data = index;
  94. UI_ListPhotoItem.ProxyEnd();
  95. }
  96. private void OnListItemClick(EventContext context)
  97. {
  98. GObject obj = context.data as GObject;
  99. int index = (int)obj.data;
  100. ViewManager.Show<PersonalPhotoView>(null, new object[] { typeof(RoleInfoView).FullName, index });
  101. this.Hide();
  102. }
  103. private void OnClickBtnHelp()
  104. {
  105. if (GameConfig.showGM >= 1)
  106. {
  107. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  108. }
  109. else
  110. {
  111. ViewManager.Show(ViewName.LOG_VIEW);
  112. }
  113. }
  114. private async void OnFocuseOut()
  115. {
  116. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  117. }
  118. private void OnClickLoaChangeName()
  119. {
  120. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  121. }
  122. private void OnBtnFieldGuideClick()
  123. {
  124. this.Hide();
  125. ViewManager.Show<FieldGuideView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  126. }
  127. private void OnBtnSkillClick()
  128. {
  129. ViewManager.Show<PersonalSkillView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  130. }
  131. private void OnBtnSettingClick()
  132. {
  133. ViewManager.Show<SettingView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  134. }
  135. private void OnComHeadClick()
  136. {
  137. ViewManager.Show<ChangeHeadView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  138. }
  139. }
  140. }