GetSuitItemVIew.cs 4.5 KB

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