GetSuitItemVIew.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using UI.CommonGame;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using UI.LuckyBox;
  5. namespace GFGGame
  6. {
  7. public class GetSuitItemVIew : BaseWindow
  8. {
  9. private UI_GetSuitItemUI _ui;
  10. private EffectUI _effectUI1;
  11. private DressUpObjUI _dressUpObjUI;
  12. public override void Dispose()
  13. {
  14. EffectUIPool.Recycle(_effectUI1);
  15. _effectUI1 = null;
  16. if (_dressUpObjUI != null)
  17. {
  18. _dressUpObjUI.Dispose();
  19. _dressUpObjUI = null;
  20. }
  21. if (_dressUpObjUI != null)
  22. {
  23. _dressUpObjUI.Dispose();
  24. _dressUpObjUI = null;
  25. }
  26. if (_ui != null)
  27. {
  28. _ui.Dispose();
  29. _ui = null;
  30. }
  31. base.Dispose();
  32. }
  33. protected override void OnInit()
  34. {
  35. base.OnInit();
  36. _ui = UI_GetSuitItemUI.Create();
  37. this.viewCom = _ui.target;
  38. isfullScreen = true;
  39. _dressUpObjUI = new DressUpObjUI("SceneDressUp",onShowAction);
  40. _ui.m_bg.onClick.Add(OnClickBg);
  41. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderEffect, "ui_ck", "ui_ck_tz");
  42. }
  43. void onShowAction()
  44. {
  45. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. GRoot.inst.touchable = true;
  51. int suitId = (int)viewData;
  52. if(suitId == 202025)
  53. {
  54. _ui.m_icon.x = -600;
  55. }
  56. else
  57. {
  58. _ui.m_icon.x = 0;
  59. }
  60. UpdateView(suitId);
  61. }
  62. protected override void OnHide()
  63. {
  64. base.OnHide();
  65. if (this.viewCom == null || this.viewCom.root == null)
  66. {
  67. Timers.inst.CallLater((object param) =>
  68. {
  69. GetSuitItemController.TryShow(0);
  70. });
  71. }
  72. TryCompleteGuide();
  73. }
  74. private void OnClickBg()
  75. {
  76. if (!GetSuitItemController.isAuto)
  77. {
  78. Hide();
  79. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  80. }
  81. }
  82. private void UpdateItem(int itemdId)
  83. {
  84. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item);
  85. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  86. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  87. string itemName = itemCfg.name;
  88. itemUI.m_comIcon.m_txtName.text = itemName;
  89. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false);
  90. itemUI.target.data = itemdId;
  91. itemUI.target.onClick.Clear();
  92. itemUI.target.onClick.Add(OnClickItemUI);
  93. UI_LuckyBoxBonusItem.ProxyEnd();
  94. }
  95. private void OnClickItemUI(EventContext context)
  96. {
  97. GComponent item = context.sender as GComponent;
  98. int itemID = (int)item.data;
  99. GoodsItemTipsController.ShowItemTips(itemID);
  100. }
  101. private void UpdateView(int suitId)
  102. {
  103. _ui.m_holderEffect.visible = true;
  104. int count = 0;//套装当前拥有的部件数量
  105. int totalCount = 1;
  106. // int suitId = 0;
  107. _ui.m_bg.url = ResPathUtil.GetBgImgPath("bg_zhuxian");
  108. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  109. if (suitId > 0)
  110. {
  111. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  112. _ui.m_txtName.text = "套装·" + suitCfg.name;
  113. int targetY = (int)(_ui.m_item.y + _ui.m_item.height + 50);
  114. }
  115. // UpdateItem(itemId);
  116. bool showAction = SuitCfgArray.Instance.CheckSuitHasAction(suitId) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(suitId);
  117. _dressUpObjUI.ResetSceneObj(115, false, true, null, false);
  118. _dressUpObjUI.dressUpObj.PutOnSuitCfg(suitId, showAction, null, false, false);
  119. _dressUpObjUI.UpdateWrapper(_ui.m_holder);
  120. }
  121. }
  122. }