GetSuitItemVIew.cs 5.6 KB

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