GetSuitItemVIew.cs 5.0 KB

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