GetSuitItemVIew.cs 3.9 KB

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