GetSuitItemVIew.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 _scenePrefab;
  11. private GameObject _sceneObject;
  12. private GoWrapper _wrapper;
  13. private GameObject _gameObject1;
  14. private GoWrapper _wrapper1;
  15. private DressUpObj _dressUpObj;
  16. public override void Dispose()
  17. {
  18. if (_sceneObject != null)
  19. {
  20. GameObject.Destroy(_sceneObject);
  21. _sceneObject = null;
  22. }
  23. SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
  24. if (_wrapper != null)
  25. {
  26. _wrapper.Dispose();
  27. _wrapper = null;
  28. }
  29. if (_dressUpObj != null)
  30. {
  31. _dressUpObj.Dispose();
  32. _dressUpObj = null;
  33. }
  34. if (_ui != null)
  35. {
  36. _ui.Dispose();
  37. _ui = null;
  38. }
  39. base.Dispose();
  40. }
  41. protected override void OnInit()
  42. {
  43. base.OnInit();
  44. _ui = UI_GetSuitItemUI.Create();
  45. this.viewCom = _ui.target;
  46. isfullScreen = true;
  47. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  48. _dressUpObj = new DressUpObj();
  49. _ui.m_bg.onClick.Add(OnClickBg);
  50. string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_tz");
  51. SceneController.AddObjectToView(null, null, _ui.m_holderEffect, resPath, out _gameObject1, out _wrapper1);
  52. }
  53. protected override void OnShown()
  54. {
  55. base.OnShown();
  56. GRoot.inst.touchable = true;
  57. int suitId = (int)viewData;
  58. UpdateView(suitId);
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. if (_sceneObject != null)
  64. {
  65. GameObject.Destroy(_sceneObject);
  66. _sceneObject = null;
  67. }
  68. if (_wrapper != null)
  69. {
  70. _wrapper.wrapTarget = null;
  71. }
  72. if (this.viewCom == null || this.viewCom.root == null)
  73. {
  74. Timers.inst.CallLater((object param) =>
  75. {
  76. GetSuitItemController.TryShow(0);
  77. });
  78. }
  79. TryCompleteGuide();
  80. }
  81. private void OnClickBg()
  82. {
  83. int suitId = GetSuitItemController.TryShow(0);
  84. if (suitId > 0)
  85. {
  86. UpdateView(suitId);
  87. }
  88. else
  89. {
  90. Hide();
  91. }
  92. }
  93. private void UpdateItem(int itemdId)
  94. {
  95. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item);
  96. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  97. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  98. string itemName = itemCfg.name;
  99. itemUI.m_comIcon.m_txtName.text = itemName;
  100. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false);
  101. itemUI.target.data = itemdId;
  102. itemUI.target.onClick.Clear();
  103. itemUI.target.onClick.Add(OnClickItemUI);
  104. UI_LuckyBoxBonusItem.ProxyEnd();
  105. }
  106. private void OnClickItemUI(EventContext context)
  107. {
  108. GComponent item = context.sender as GComponent;
  109. int itemID = (int)item.data;
  110. GoodsItemTipsController.ShowItemTips(itemID);
  111. }
  112. private void UpdateView(int suitId)
  113. {
  114. _ui.m_holderEffect.visible = true;
  115. int count = 0;//套装当前拥有的部件数量
  116. int totalCount = 1;
  117. // int suitId = 0;
  118. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  119. // totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
  120. if (suitId > 0)
  121. {
  122. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  123. _ui.m_txtName.text = "套装·" + suitCfg.name;
  124. int targetY = (int)(_ui.m_item.y + _ui.m_item.height + 50);
  125. }
  126. _ui.m_probar.max = totalCount;
  127. _ui.m_probar.value = count;
  128. // UpdateItem(itemId);
  129. if (_sceneObject != null)
  130. {
  131. GameObject.Destroy(_sceneObject);
  132. _sceneObject = null;
  133. }
  134. _sceneObject = GameObject.Instantiate(_scenePrefab);
  135. int scale = 70;
  136. _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
  137. _dressUpObj.setSceneObj(_sceneObject, false, true, null, false);
  138. _dressUpObj.PutOnDefaultDressUpData();
  139. _dressUpObj.PutOnSuitCfg(suitId, false, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
  140. if (_wrapper == null)
  141. {
  142. _wrapper = new GoWrapper(_sceneObject);
  143. _ui.m_holder.SetNativeObject(_wrapper);
  144. }
  145. else
  146. {
  147. _wrapper.wrapTarget = _sceneObject;
  148. }
  149. }
  150. }
  151. }