uGUICharacterSelectManager.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using MaidStatus;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using wf;
  8. public class uGUICharacterSelectManager : MonoBehaviour
  9. {
  10. public static void DefaultMaidList(List<Maid> drawList)
  11. {
  12. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  13. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  14. {
  15. drawList.Add(characterMgr.GetStockMaid(i));
  16. }
  17. }
  18. public static void PrivateMaidList(List<Maid> drawList)
  19. {
  20. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  21. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  22. {
  23. Maid stockMaid = characterMgr.GetStockMaid(i);
  24. Status status = stockMaid.status;
  25. if (status.specialRelation == SpecialRelation.Married)
  26. {
  27. drawList.Add(stockMaid);
  28. }
  29. }
  30. }
  31. public void Awake()
  32. {
  33. NDebug.AssertNull(this.MaidPlateParentGrid != null);
  34. this.tabPanel = this.MaidPlateParentGrid.gameObject.GetComponent<uGUITabPanel>();
  35. }
  36. public void Create(uGUICharacterSelectManager.Type type)
  37. {
  38. if (this.callBackMaidList == null)
  39. {
  40. if (uGUICharacterSelectManager.<>f__mg$cache0 == null)
  41. {
  42. uGUICharacterSelectManager.<>f__mg$cache0 = new uGUICharacterSelectManager.CallBackMaidList(uGUICharacterSelectManager.DefaultMaidList);
  43. }
  44. this.callBackMaidList = uGUICharacterSelectManager.<>f__mg$cache0;
  45. }
  46. this.m_type = type;
  47. Transform transform = this.MaidPlateParentGrid.transform;
  48. for (int i = 0; i < transform.childCount; i++)
  49. {
  50. UnityEngine.Object.Destroy(transform.GetChild(i).gameObject);
  51. }
  52. transform.DetachChildren();
  53. this.maidList = new List<Maid>();
  54. this.callBackMaidList(this.maidList);
  55. this.buttonList = new List<uGUITabButton>();
  56. if (type == uGUICharacterSelectManager.Type.Private)
  57. {
  58. GameObject f_goParent = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "ScenePrivate/NoSelect", true);
  59. uGUITabButton component = UTY.GetChildObject(f_goParent, "Plate", false).GetComponent<uGUITabButton>();
  60. this.buttonList.Add(component);
  61. if (this.maidList.Count > 0)
  62. {
  63. GameObject f_goParent2 = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "ScenePrivate/RandomButton", true);
  64. uGUITabButton component2 = UTY.GetChildObject(f_goParent2, "Plate", false).GetComponent<uGUITabButton>();
  65. this.buttonList.Add(component2);
  66. }
  67. }
  68. for (int j = 0; j < this.maidList.Count; j++)
  69. {
  70. GameObject gameObject = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "ScenePrivate/MaidStatus", true);
  71. gameObject.GetComponent<uGUIMaidPlate>().SetMaidData(this.maidList[j]);
  72. uGUITabButton component3 = UTY.GetChildObject(gameObject, "Plate", false).GetComponent<uGUITabButton>();
  73. EventDelegate.Add(component3.onSelectEvent, new EventDelegate.Callback(this.OnSelect));
  74. this.buttonList.Add(component3);
  75. }
  76. if (this.tabPanel == null)
  77. {
  78. this.tabPanel = this.MaidPlateParentGrid.gameObject.AddComponent<uGUITabPanel>();
  79. }
  80. this.tabPanel.UpdateChildren();
  81. uGUITabButton component4 = UTY.GetChildObject(this.MaidPlateParentGrid.transform.GetChild(0).gameObject, "Plate", false).GetComponent<uGUITabButton>();
  82. this.tabPanel.Select(component4);
  83. }
  84. public void SelectMaid(Maid maid)
  85. {
  86. if (maid == null)
  87. {
  88. return;
  89. }
  90. Transform transform = this.MaidPlateParentGrid.transform;
  91. for (int i = 0; i < transform.childCount; i++)
  92. {
  93. uGUIMaidPlate component = transform.GetChild(i).GetComponent<uGUIMaidPlate>();
  94. if (component != null && component.maid == maid)
  95. {
  96. uGUITabButton component2 = UTY.GetChildObject(component.gameObject, "Plate", false).GetComponent<uGUITabButton>();
  97. this.tabPanel.Select(component2);
  98. return;
  99. }
  100. }
  101. }
  102. public void UpdateMaidPlate(Maid maid)
  103. {
  104. Transform transform = this.MaidPlateParentGrid.transform;
  105. for (int i = 0; i < transform.childCount; i++)
  106. {
  107. uGUIMaidPlate component = transform.GetChild(i).GetComponent<uGUIMaidPlate>();
  108. if (component != null && component.maid == maid)
  109. {
  110. component.SetMaidData(maid);
  111. return;
  112. }
  113. }
  114. }
  115. private void OnSelect()
  116. {
  117. GameObject gameObject = uGUITabButton.current.transform.parent.gameObject;
  118. uGUIMaidPlate component = gameObject.GetComponent<uGUIMaidPlate>();
  119. bool selected = uGUITabButton.selected;
  120. if (selected && this.callBackOnSelect != null)
  121. {
  122. this.callBackOnSelect(component.maid);
  123. }
  124. }
  125. public List<uGUITabButton> GetButtonList()
  126. {
  127. if (this.buttonList != null)
  128. {
  129. return this.buttonList;
  130. }
  131. return null;
  132. }
  133. public List<Maid> GetMaidList()
  134. {
  135. if (this.maidList != null)
  136. {
  137. return this.maidList;
  138. }
  139. return null;
  140. }
  141. public void SetCallBackMaidList(uGUICharacterSelectManager.CallBackMaidList callBack)
  142. {
  143. this.callBackMaidList = callBack;
  144. }
  145. public void SetCallBackOnSelect(uGUICharacterSelectManager.CallBackOnSelect callBack)
  146. {
  147. this.callBackOnSelect = callBack;
  148. }
  149. public GridLayoutGroup MaidPlateParentGrid;
  150. private uGUICharacterSelectManager.CallBackMaidList callBackMaidList;
  151. private uGUICharacterSelectManager.CallBackOnSelect callBackOnSelect;
  152. private uGUICharacterSelectManager.Type m_type;
  153. private uGUITabPanel tabPanel;
  154. private uGUIMaidPlate[] selectList;
  155. private List<uGUITabButton> buttonList;
  156. private List<Maid> maidList;
  157. [CompilerGenerated]
  158. private static uGUICharacterSelectManager.CallBackMaidList <>f__mg$cache0;
  159. public delegate void CallBackMaidList(List<Maid> drawList);
  160. public delegate void CallBackOnSelect(Maid selectMaid);
  161. public delegate void CallBackOnSelectNoSelect();
  162. public enum Type
  163. {
  164. Default,
  165. Private
  166. }
  167. }