GetSuitItemVIew.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. GetSuitItemController.TryShow(0);
  50. });
  51. GuideController.HideGuide();
  52. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
  53. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
  54. }
  55. private void OnClickBg()
  56. {
  57. int itemId = GetSuitItemController.TryShow(0);
  58. if (itemId > 0)
  59. {
  60. GuideController.HideGuide();
  61. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
  62. GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
  63. UpdateView(itemId);
  64. }
  65. else
  66. {
  67. Hide();
  68. }
  69. }
  70. private void UpdateItem(int itemdId)
  71. {
  72. UI_LuckyBoxBonusItem itemUI = _ui.m_item;
  73. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
  74. itemUI.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  75. string itemName = itemCfg.name;
  76. itemUI.m_txtName.text = itemName;
  77. RarityIconController.UpdateRarityIcon(itemUI.m_rarity, itemdId, false);
  78. itemUI.target.data = itemdId;
  79. itemUI.target.onClick.Clear();
  80. itemUI.target.onClick.Add(OnClickItemUI);
  81. }
  82. private void OnClickItemUI(EventContext context)
  83. {
  84. GComponent item = context.sender as GComponent;
  85. int itemID = (int)item.data;
  86. GoodsItemTipsController.ShowItemTips(itemID);
  87. }
  88. private void UpdateView(int itemId)
  89. {
  90. int count = 0;
  91. int totalCount = 1;
  92. int suitId = 0;
  93. int[] itemIds = null;
  94. DressUpMenuSuitDataManager.GetSuitProgressByItemId(itemId, out suitId, out count);
  95. totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
  96. itemIds = SuitCfgManager.Instance.GetSuitItems(suitId);
  97. if (suitId > 0)
  98. {
  99. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  100. _ui.m_txtName.text = "套装·" + suitCfg.name;
  101. int targetY = (int)(_ui.m_item.target.y + _ui.m_item.target.height + 50);
  102. if(count == totalCount)
  103. {
  104. GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FULL, 1, false, "恭喜你,集齐了第一套套装,快去换装界面穿上试试吧!点击空白区域继续", targetY);
  105. }
  106. else
  107. {
  108. GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST, 1, false, "恭喜你,获得了一件套装配件,集齐套装有惊喜哦!点击空白区域继续", targetY);
  109. }
  110. }
  111. _ui.m_probar.max = totalCount;
  112. _ui.m_probar.value = count;
  113. UpdateItem(itemId);
  114. if(_sceneObject != null)
  115. {
  116. GameObject.Destroy(_sceneObject);
  117. _sceneObject = null;
  118. }
  119. _sceneObject = GameObject.Instantiate(_scenePrefab);
  120. int scale = 70;
  121. _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
  122. SceneController.UpdateRole(itemIds, _sceneObject);
  123. if(_wrapper == null)
  124. {
  125. _wrapper = new GoWrapper(_sceneObject);
  126. _ui.m_holder.SetNativeObject(_wrapper);
  127. }
  128. else
  129. {
  130. _wrapper.wrapTarget = _sceneObject;
  131. }
  132. }
  133. }
  134. }