GetSuitItemVIew.cs 5.3 KB

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