GetSuitItemVIew.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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_loaBg.onClick.Add(OnClickBg);
  41. _ui.m_btnShare.onClick.Add(OnClickShare);
  42. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderEffect, "ui_ck", "ui_ck_tz");
  43. }
  44. void onShowAction()
  45. {
  46. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. GRoot.inst.touchable = true;
  52. _ui.m_loaBg.touchable = false;
  53. int suitId = (int)viewData;
  54. if(suitId == 202025)
  55. {
  56. _ui.m_icon.x = -600;
  57. }
  58. else
  59. {
  60. _ui.m_icon.x = 0;
  61. }
  62. if (!GetSuitItemController.isAuto)
  63. {
  64. _ui.m_btnShare.visible = true;
  65. }
  66. else
  67. {
  68. _ui.m_btnShare.visible = false;
  69. }
  70. UpdateView(suitId);
  71. Timers.inst.Add(0.5f, 1, OnTimerClick);
  72. }
  73. protected override void OnHide()
  74. {
  75. base.OnHide();
  76. if (this.viewCom == null || this.viewCom.root == null)
  77. {
  78. Timers.inst.CallLater((object param) =>
  79. {
  80. GetSuitItemController.TryShow(0);
  81. });
  82. }
  83. TryCompleteGuide();
  84. Timers.inst.Remove(OnTimerClick);
  85. _ui.m_loaBg.touchable = true;
  86. }
  87. private void OnTimerClick(object param)
  88. {
  89. _ui.m_loaBg.touchable = true;
  90. }
  91. private void OnClickBg()
  92. {
  93. if (!GetSuitItemController.isAuto)
  94. {
  95. Hide();
  96. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  97. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  98. }
  99. }
  100. private void OnClickShare()
  101. {
  102. ShareDataManager.Instance.CaptureCameraToImage();
  103. }
  104. private void UpdateItem(int itemdId)
  105. {
  106. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item);
  107. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  108. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  109. string itemName = itemCfg.name;
  110. itemUI.m_comIcon.m_txtName.text = itemName;
  111. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false);
  112. itemUI.target.data = itemdId;
  113. itemUI.target.onClick.Clear();
  114. itemUI.target.onClick.Add(OnClickItemUI);
  115. UI_LuckyBoxBonusItem.ProxyEnd();
  116. }
  117. private void OnClickItemUI(EventContext context)
  118. {
  119. GComponent item = context.sender as GComponent;
  120. int itemID = (int)item.data;
  121. GoodsItemTipsController.ShowItemTips(itemID);
  122. }
  123. private void UpdateView(int suitId)
  124. {
  125. _ui.m_holderEffect.visible = true;
  126. int count = 0;//套装当前拥有的部件数量
  127. int totalCount = 1;
  128. // int suitId = 0;
  129. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_zhuxian");
  130. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  131. if (suitId > 0)
  132. {
  133. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  134. _ui.m_txtName.text = "套装·" + suitCfg.name;
  135. int targetY = (int)(_ui.m_item.y + _ui.m_item.height + 50);
  136. }
  137. // UpdateItem(itemId);
  138. bool showAction = SuitCfgArray.Instance.CheckSuitHasAction(suitId) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(suitId);
  139. _dressUpObjUI.ResetSceneObj(115, false, true, null, false);
  140. _dressUpObjUI.dressUpObj.PutOnSuitCfg(suitId, showAction, null, false, false);
  141. _dressUpObjUI.UpdateWrapper(_ui.m_holder);
  142. }
  143. }
  144. }