GetSuitItemVIew.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using UI.CommonGame;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using static UnityEditor.Progress;
  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 int guideId = 0;//0:没有引导 1:首次获得套装2:首次获得套装部件
  14. public override void Dispose()
  15. {
  16. if (_scenePrefab != null)
  17. {
  18. GameObject.Destroy(_scenePrefab);
  19. _scenePrefab = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. _ui = UI_GetSuitItemUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  30. _ui.m_bg.onClick.Add(OnClickBg);
  31. _ui.m_mov00.onPlayEnd.Add(() =>
  32. {
  33. _ui.m_mov00.visible = false;
  34. _ui.m_mov01.visible = true;
  35. _ui.m_mov01.SetPlaySettings(0, -1, 1, -1);
  36. });
  37. _ui.m_mov01.onPlayEnd.Add(() =>
  38. {
  39. _ui.m_mov01.visible = false;
  40. _ui.m_mov02.visible = true;
  41. _ui.m_mov02.SetPlaySettings(0, -1, 1, -1);
  42. });
  43. _ui.m_mov02.onPlayEnd.Add(() =>
  44. {
  45. _ui.m_mov02.visible = false;
  46. _ui.m_mov03.visible = true;
  47. _ui.m_mov03.SetPlaySettings(0, -1, 1, -1);
  48. });
  49. _ui.m_mov03.onPlayEnd.Add(() =>
  50. {
  51. _ui.m_mov03.visible = false;
  52. });
  53. _ui.m_mov10.onPlayEnd.Add(() =>
  54. {
  55. _ui.m_mov10.visible = false;
  56. _ui.m_mov11.visible = true;
  57. _ui.m_mov11.SetPlaySettings(0, -1, 1, -1);
  58. });
  59. _ui.m_mov11.onPlayEnd.Add(() =>
  60. {
  61. _ui.m_mov11.visible = false;
  62. _ui.m_mov12.visible = true;
  63. _ui.m_mov12.SetPlaySettings(0, -1, 1, -1);
  64. });
  65. _ui.m_mov12.onPlayEnd.Add(() =>
  66. {
  67. _ui.m_mov12.visible = false;
  68. _ui.m_mov13.visible = true;
  69. _ui.m_mov13.SetPlaySettings(0, -1, 1, -1);
  70. });
  71. _ui.m_mov03.onPlayEnd.Add(() =>
  72. {
  73. _ui.m_mov03.visible = false;
  74. });
  75. }
  76. protected override void OnShown()
  77. {
  78. base.OnShown();
  79. int itemId = (int)viewData;
  80. guideId = 0;
  81. UpdateView(itemId);
  82. }
  83. protected override void OnHide()
  84. {
  85. base.OnHide();
  86. if (_sceneObject != null)
  87. {
  88. GameObject.Destroy(_sceneObject);
  89. _sceneObject = null;
  90. }
  91. if (_wrapper != null)
  92. {
  93. _wrapper.wrapTarget = null;
  94. }
  95. if (this.viewCom == null || this.viewCom.root == null)
  96. {
  97. Timers.inst.CallLater((object param) =>
  98. {
  99. GetSuitItemController.TryShow(0);
  100. });
  101. }
  102. TryCompleteGuide();
  103. }
  104. private void OnClickBg()
  105. {
  106. int itemId = GetSuitItemController.TryShow(0);
  107. if (itemId > 0)
  108. {
  109. UpdateView(itemId);
  110. }
  111. else
  112. {
  113. Hide();
  114. }
  115. }
  116. private void UpdateItem(int itemdId)
  117. {
  118. UI_LuckyBoxBonusItem itemUI = _ui.m_item;
  119. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  120. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  121. string itemName = itemCfg.name;
  122. itemUI.m_comIcon.m_txtName.text = itemName;
  123. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false);
  124. itemUI.target.data = itemdId;
  125. itemUI.target.onClick.Clear();
  126. itemUI.target.onClick.Add(OnClickItemUI);
  127. }
  128. private void OnClickItemUI(EventContext context)
  129. {
  130. GComponent item = context.sender as GComponent;
  131. int itemID = (int)item.data;
  132. GoodsItemTipsController.ShowItemTips(itemID);
  133. }
  134. private void UpdateView(int itemId)
  135. {
  136. // _ui.m_mov0.visible = false;
  137. // _ui.m_mov1.visible = false;
  138. for (int i = 0; i < 4; i++)
  139. {
  140. _ui.target.GetChild("mov0" + i).asMovieClip.visible = false;
  141. _ui.target.GetChild("mov1" + i).asMovieClip.visible = false;
  142. }
  143. int count = 0;
  144. int totalCount = 1;
  145. int suitId = 0;
  146. int[] itemIds = null;
  147. DressUpMenuSuitDataManager.GetSuitProgressByItemId(itemId, out suitId, out count);
  148. totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
  149. itemIds = SuitCfgManager.Instance.GetSuitItems(suitId);
  150. if (suitId > 0)
  151. {
  152. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  153. _ui.m_txtName.text = "套装·" + suitCfg.name;
  154. int targetY = (int)(_ui.m_item.target.y + _ui.m_item.target.height + 50);
  155. if (count == totalCount)
  156. {
  157. guideId = 1;
  158. }
  159. else
  160. {
  161. guideId = 2;
  162. }
  163. }
  164. _ui.m_probar.max = totalCount;
  165. _ui.m_probar.value = count;
  166. UpdateItem(itemId);
  167. if (_sceneObject != null)
  168. {
  169. GameObject.Destroy(_sceneObject);
  170. _sceneObject = null;
  171. }
  172. _sceneObject = GameObject.Instantiate(_scenePrefab);
  173. int scale = 70;
  174. _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
  175. SceneController.UpdateRole(itemIds, _sceneObject);
  176. if (_wrapper == null)
  177. {
  178. _wrapper = new GoWrapper(_sceneObject);
  179. _ui.m_holder.SetNativeObject(_wrapper);
  180. }
  181. else
  182. {
  183. _wrapper.wrapTarget = _sceneObject;
  184. }
  185. _ui.m_mov00.visible = true;
  186. _ui.m_mov10.visible = true;
  187. _ui.m_mov00.SetPlaySettings(0, -1, 1, -1);
  188. _ui.m_mov10.SetPlaySettings(0, -1, 1, -1);
  189. }
  190. protected override void UpdateToCheckGuide(object param)
  191. {
  192. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  193. if (guideId == 1) GuideController.TryGuide(null, ConstGuideId.GET_SUIT_ITEM_FULL, 1, "恭喜你,集齐了第一套套装,快去换装界面穿上试试吧!点击空白区域继续", -1, true, (int)(this.viewCom.height - 150));
  194. if (guideId == 2) GuideController.TryGuide(null, ConstGuideId.GET_SUIT_ITEM_FIRST, 1, "恭喜你,获得了一件套装配件,集齐套装有惊喜哦!点击空白区域继续", -1, true, (int)(this.viewCom.height - 150));
  195. }
  196. protected override void TryCompleteGuide()
  197. {
  198. GuideCfg cfg;
  199. cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.GET_SUIT_ITEM_FULL);
  200. GuideController.TryCompleteGuideIndex(cfg.id, 1);
  201. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_FULL, 1);
  202. cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.GET_SUIT_ITEM_FIRST);
  203. GuideController.TryCompleteGuideIndex(cfg.id, 1);
  204. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_FIRST, 1);
  205. }
  206. }
  207. }