GetSuitItemVIew.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. //}
  77. }
  78. private void UpdateItem(int itemdId)
  79. {
  80. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item);
  81. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  82. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  83. string itemName = itemCfg.name;
  84. itemUI.m_comIcon.m_txtName.text = itemName;
  85. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false);
  86. itemUI.target.data = itemdId;
  87. itemUI.target.onClick.Clear();
  88. itemUI.target.onClick.Add(OnClickItemUI);
  89. UI_LuckyBoxBonusItem.ProxyEnd();
  90. }
  91. private void OnClickItemUI(EventContext context)
  92. {
  93. GComponent item = context.sender as GComponent;
  94. int itemID = (int)item.data;
  95. GoodsItemTipsController.ShowItemTips(itemID);
  96. }
  97. private void UpdateView(int suitId)
  98. {
  99. _ui.m_holderEffect.visible = true;
  100. int count = 0;//套装当前拥有的部件数量
  101. int totalCount = 1;
  102. // int suitId = 0;
  103. //_ui.m_bg.url = ResPathUtil.GetBgImgPath("bg_zhuxian");
  104. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  105. // totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
  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. _ui.m_probar.max = totalCount;
  113. _ui.m_probar.value = count;
  114. //_ui.m_probar.visible = false;
  115. //AlertUI.Show(string.Format("套装进度:{0}/{1}", count, totalCount))
  116. //.SetLeftButton(false)
  117. //.SetRightButton(true, "确定");
  118. // UpdateItem(itemId);
  119. _dressUpObjUI.ResetSceneObj(70, false, true, null, false);
  120. _dressUpObjUI.dressUpObj.PutOnSuitCfg(suitId, false, null, false, false);
  121. _dressUpObjUI.UpdateWrapper(_ui.m_holder);
  122. }
  123. }
  124. }