GetSuitItemVIew.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. public override void Dispose()
  14. {
  15. if (_scenePrefab != null)
  16. {
  17. GameObject.Destroy(_scenePrefab);
  18. _scenePrefab = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. _ui = UI_GetSuitItemUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  29. _ui.m_bg.onClick.Add(OnClickBg);
  30. }
  31. protected override void OnShown()
  32. {
  33. base.OnShown();
  34. int itemId = (int)viewData;
  35. UpdateView(itemId);
  36. }
  37. protected override void OnHide()
  38. {
  39. base.OnHide();
  40. if (_sceneObject != null)
  41. {
  42. GameObject.Destroy(_sceneObject);
  43. _sceneObject = null;
  44. }
  45. if (_wrapper != null)
  46. {
  47. _wrapper.wrapTarget = null;
  48. }
  49. if(this.viewCom != null && this.viewCom.root == null)
  50. {
  51. Timers.inst.CallLater((object param) =>
  52. {
  53. GetSuitItemController.TryShow(0);
  54. });
  55. GuideController.HideGuide();
  56. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
  57. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
  58. }
  59. }
  60. private void OnClickBg()
  61. {
  62. int itemId = GetSuitItemController.TryShow(0);
  63. if (itemId > 0)
  64. {
  65. GuideController.HideGuide();
  66. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
  67. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
  68. UpdateView(itemId);
  69. }
  70. else
  71. {
  72. Hide();
  73. }
  74. }
  75. private void UpdateItem(int itemdId)
  76. {
  77. UI_LuckyBoxBonusItem itemUI = _ui.m_item;
  78. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  79. itemUI.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  80. string itemName = itemCfg.name;
  81. itemUI.m_txtName.text = itemName;
  82. RarityIconController.UpdateRarityIcon(itemUI.m_rarity, itemdId, false);
  83. itemUI.target.data = itemdId;
  84. itemUI.target.onClick.Clear();
  85. itemUI.target.onClick.Add(OnClickItemUI);
  86. }
  87. private void OnClickItemUI(EventContext context)
  88. {
  89. GComponent item = context.sender as GComponent;
  90. int itemID = (int)item.data;
  91. GoodsItemTipsController.ShowItemTips(itemID);
  92. }
  93. private void UpdateView(int itemId)
  94. {
  95. int count = 0;
  96. int totalCount = 1;
  97. int suitId = 0;
  98. int[] itemIds = null;
  99. DressUpMenuSuitDataManager.GetSuitProgressByItemId(itemId, out suitId, out count);
  100. totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
  101. itemIds = SuitCfgManager.Instance.GetSuitItems(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.target.y + _ui.m_item.target.height + 50);
  107. if (count == totalCount)
  108. {
  109. GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FULL, 1, false, "恭喜你,集齐了第一套套装,快去换装界面穿上试试吧!点击空白区域继续", targetY);
  110. }
  111. else
  112. {
  113. GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST, 1, false, "恭喜你,获得了一件套装配件,集齐套装有惊喜哦!点击空白区域继续", targetY);
  114. }
  115. }
  116. _ui.m_probar.max = totalCount;
  117. _ui.m_probar.value = count;
  118. UpdateItem(itemId);
  119. if (_sceneObject != null)
  120. {
  121. GameObject.Destroy(_sceneObject);
  122. _sceneObject = null;
  123. }
  124. _sceneObject = GameObject.Instantiate(_scenePrefab);
  125. int scale = 70;
  126. _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
  127. SceneController.UpdateRole(itemIds, _sceneObject);
  128. if (_wrapper == null)
  129. {
  130. _wrapper = new GoWrapper(_sceneObject);
  131. _ui.m_holder.SetNativeObject(_wrapper);
  132. }
  133. else
  134. {
  135. _wrapper.wrapTarget = _sceneObject;
  136. }
  137. }
  138. }
  139. }