GetSuitItemVIew.cs 4.1 KB

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