LeagueChangeNameView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using ET;
  2. using FairyGUI;
  3. using UI.League;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. //修改联盟名称、徽章
  8. public class LeagueChangeNameView : BaseWindow
  9. {
  10. private UI_LeagueChangeNameUI _ui;
  11. public override void Dispose()
  12. {
  13. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. packageName = UI_LeagueChangeNameUI.PACKAGE_NAME;
  24. _ui = UI_LeagueChangeNameUI.Create();
  25. this.viewCom = _ui.target;
  26. isfullScreen = true;
  27. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  28. _ui.m_c1.onChanged.Add(UpdateView);
  29. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  30. _ui.m_listIcon.itemRenderer = RenderListItem;
  31. }
  32. protected override void AddEventListener()
  33. {
  34. base.AddEventListener();
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. _ui.m_c1.selectedIndex = 0;
  40. _ui.m_listIcon.numItems = GlobalCfgArray.globalCfg.badgeResArr.Length;
  41. UpdateView();
  42. }
  43. protected override void OnHide()
  44. {
  45. base.OnHide();
  46. }
  47. protected override void RemoveEventListener()
  48. {
  49. base.RemoveEventListener();
  50. }
  51. private void UpdateView()
  52. {
  53. _ui.m_txtName.text = "";
  54. if (_ui.m_listIcon.numItems > 0)
  55. {
  56. _ui.m_listIcon.selectedIndex = 0;
  57. _ui.m_listIcon.ScrollToView(0);
  58. }
  59. if (_ui.m_c1.selectedIndex == 0)
  60. {
  61. ItemUtil.UpdateItemNeedNum(_ui.m_comCost, GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][0], GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][1]);
  62. }
  63. else
  64. {
  65. ItemUtil.UpdateItemNeedNum(_ui.m_comCost, GlobalCfgArray.globalCfg.consumeChangeNameArr[0][0], GlobalCfgArray.globalCfg.consumeChangeNameArr[0][1]);
  66. }
  67. }
  68. private void RenderListItem(int index, GObject obj)
  69. {
  70. UI_ListIconItem item = UI_ListIconItem.Proxy(obj);
  71. item.m_loaIcon.url = ResPathUtil.GetLeagueIconPath(GlobalCfgArray.globalCfg.badgeResArr[index]);
  72. UI_ListIconItem.ProxyEnd();
  73. }
  74. private void OnBtnChangeClick()
  75. {
  76. if (LeagueDataManager.Instance.LeagueData.LeagueMemberDatas[RoleDataManager.roleId].Pos != LeaguePos.Owner)
  77. {
  78. PromptController.Instance.ShowFloatTextPrompt("权限不足");
  79. return;
  80. }
  81. if (_ui.m_c1.selectedIndex == 0)
  82. {
  83. int needCount = GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][1];
  84. long hasCount = ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][0]);
  85. if (needCount > hasCount)
  86. {
  87. PromptController.Instance.ShowFloatTextPrompt("消耗不足");
  88. return;
  89. }
  90. LeagueSproxy.ReqChangeLeagueNameOrIcon(2, GlobalCfgArray.globalCfg.badgeResArr[_ui.m_listIcon.selectedIndex]).Coroutine();
  91. }
  92. else
  93. {
  94. int needCount = GlobalCfgArray.globalCfg.consumeChangeNameArr[0][1];
  95. long hasCount = ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.consumeChangeNameArr[0][0]);
  96. if (needCount > hasCount)
  97. {
  98. PromptController.Instance.ShowFloatTextPrompt("消耗不足");
  99. return;
  100. }
  101. LeagueSproxy.ReqChangeLeagueNameOrIcon(1, _ui.m_txtName.text).Coroutine();
  102. }
  103. }
  104. }
  105. }