SuitShowView.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using UI.FieldGuide;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class SuitShowView : BaseWindow
  8. {
  9. private UI_SuitShowUI _ui;
  10. private int _suitTypeId;
  11. private int _suitId;
  12. private DressUpObjUI _dressUpObjUI;
  13. private bool _actionIsPic;
  14. private List<int> _suitIds;
  15. public override void Dispose()
  16. {
  17. if (_dressUpObjUI != null)
  18. {
  19. _dressUpObjUI.Dispose();
  20. _dressUpObjUI = null;
  21. }
  22. if (_dressUpObjUI != null)
  23. {
  24. _dressUpObjUI.Dispose();
  25. _dressUpObjUI = null;
  26. }
  27. if (_ui != null)
  28. {
  29. _ui.Dispose();
  30. _ui = null;
  31. }
  32. base.Dispose();
  33. }
  34. protected override void OnInit()
  35. {
  36. base.OnInit();
  37. packageName = UI_SuitShowUI.PACKAGE_NAME;
  38. _ui = UI_SuitShowUI.Create();
  39. this.viewCom = _ui.target;
  40. isfullScreen = true;
  41. //isReturnView = true;
  42. this.clickBlankToClose = false;
  43. _dressUpObjUI = new DressUpObjUI("SceneDressUp");
  44. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  45. _ui.m_imgBonusBox.target.onClick.Add(OnClickImgBonusBox);
  46. _ui.m_btnChangeAction.visible = false;
  47. _ui.m_btnLeft.onClick.Add(OnClickBtnLeft);
  48. _ui.m_btnRight.onClick.Add(OnClickBtnRight);
  49. }
  50. protected override void OnShown()
  51. {
  52. base.OnShown();
  53. object[] datas = this.viewData as object[];
  54. _suitTypeId = (int)datas[0];
  55. _suitId = (int)datas[1];
  56. List<int> suitIds = datas[2] as List<int>;
  57. _ui.m_imgBonusBox.target.visible = datas.Length >= 4 ? (bool)datas[3] : true;
  58. _suitIds = new List<int>();
  59. foreach (int suitId in suitIds)
  60. {
  61. if (DressUpMenuSuitDataManager.CheckHaveSuit(suitId))
  62. {
  63. _suitIds.Add(suitId);
  64. }
  65. }
  66. SuitGuideMenuCfg cfg = SuitGuideMenuCfgArray.Instance.GetCfg(_suitTypeId);
  67. if (cfg == null)
  68. {
  69. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  70. _ui.m_txtSuitName.text = suitCfg.name;
  71. }
  72. else
  73. {
  74. _ui.m_txtTypeName.text = cfg.name;
  75. }
  76. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjtj_bjbj");
  77. UpdateArrows();
  78. UpdateSuitView();
  79. UpdateSuitBoxStatus();
  80. }
  81. protected override void AddEventListener()
  82. {
  83. base.AddEventListener();
  84. EventAgent.AddEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
  85. }
  86. protected override void OnHide()
  87. {
  88. base.OnHide();
  89. }
  90. protected override void RemoveEventListener()
  91. {
  92. base.RemoveEventListener();
  93. EventAgent.RemoveEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
  94. }
  95. private void OnClickBtnBack()
  96. {
  97. this.Hide();
  98. }
  99. private void OnClickImgBonusBox()
  100. {
  101. SuitUtil.ShowSuitGuideBonus(_suitId);
  102. }
  103. private void UpdateSuitView(bool isPic = true)
  104. {
  105. _actionIsPic = isPic;
  106. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  107. _ui.m_txtSuitName.text = suitCfg.name;
  108. _dressUpObjUI.ResetSceneObj(100, false, true, null, false);
  109. _dressUpObjUI.dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING }, true, false);
  110. _dressUpObjUI.UpdateWrapper(_ui.m_holder);
  111. UpdateSuitBoxStatus();
  112. }
  113. private void UpdateArrows()
  114. {
  115. int index = _suitIds.IndexOf(_suitId);
  116. int count = _suitIds.Count;
  117. _ui.m_btnRight.visible = (index + 1 < count);
  118. _ui.m_btnLeft.visible = (index - 1 >= 0);
  119. }
  120. private void OnClickBtnLeft()
  121. {
  122. int index = _suitIds.IndexOf(_suitId);
  123. int targetIndex = index - 1;
  124. if (targetIndex >= 0)
  125. {
  126. _suitId = _suitIds[targetIndex];
  127. UpdateArrows();
  128. UpdateSuitView();
  129. }
  130. UpdateSuitBoxStatus();
  131. }
  132. private void OnClickBtnRight()
  133. {
  134. int index = _suitIds.IndexOf(_suitId);
  135. int targetIndex = index + 1;
  136. if (targetIndex < _suitIds.Count)
  137. {
  138. _suitId = _suitIds[targetIndex];
  139. UpdateArrows();
  140. UpdateSuitView();
  141. }
  142. UpdateSuitBoxStatus();
  143. }
  144. private void UpdateSuitBoxStatus(EventContext eventContext = null)
  145. {
  146. if (eventContext == null || _suitId == (int)eventContext.data)
  147. {
  148. int status = DressUpMenuSuitDataManager.GetSuitGuideBonusStatus(_suitId);
  149. RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, false);
  150. RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, status == ConstBonusStatus.CAN_GET);
  151. if (status == ConstBonusStatus.CAN_GET)
  152. {
  153. _ui.m_imgBonusBox.m_c1.selectedIndex = 1;
  154. }
  155. else
  156. {
  157. _ui.m_imgBonusBox.m_c1.selectedIndex = 0;
  158. }
  159. }
  160. }
  161. }
  162. }