GetSuitItemVIew.cs 4.1 KB

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