DailyCtrl.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using System;
  2. using System.Collections.Generic;
  3. using com.workman.cm3d2.button;
  4. using MaidStatus;
  5. using PlayerStatus;
  6. using Schedule;
  7. using UnityEngine;
  8. using wf;
  9. public class DailyCtrl : MonoBehaviour
  10. {
  11. public void Init(DailyMgr mgr, GameObject goPanel)
  12. {
  13. this.m_mgr = mgr;
  14. this.m_goPanel = goPanel;
  15. }
  16. public void DisplayViewer(DailyMgr.Daily daily)
  17. {
  18. if (!this.m_bInit)
  19. {
  20. this.m_bInit = true;
  21. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  22. {
  23. EventDelegate.Add(buttonData.button.onClick, new EventDelegate.Callback(this.m_mgr.OnClickMenuButton));
  24. }
  25. }
  26. foreach (DailyCtrl.ButtonData buttonData2 in this.menuButtons)
  27. {
  28. buttonData2.active = true;
  29. }
  30. DailyCtrl.ButtonType[] array3;
  31. if (daily == DailyMgr.Daily.Daytime)
  32. {
  33. if (DailyMgr.IsLegacy)
  34. {
  35. array3 = new DailyCtrl.ButtonType[]
  36. {
  37. DailyCtrl.ButtonType.Dance,
  38. DailyCtrl.ButtonType.FacilityManagement,
  39. DailyCtrl.ButtonType.Casino,
  40. DailyCtrl.ButtonType.Trophy,
  41. DailyCtrl.ButtonType.PhotoMode,
  42. DailyCtrl.ButtonType.DeskCustomize,
  43. DailyCtrl.ButtonType.MyRoomCustom,
  44. DailyCtrl.ButtonType.Casino,
  45. DailyCtrl.ButtonType.Shop,
  46. DailyCtrl.ButtonType.FacilityManagement,
  47. DailyCtrl.ButtonType.LegacyMode,
  48. DailyCtrl.ButtonType.Karaoke,
  49. DailyCtrl.ButtonType.EventScenario,
  50. DailyCtrl.ButtonType.ManEdit,
  51. DailyCtrl.ButtonType.Credit
  52. };
  53. }
  54. else
  55. {
  56. array3 = new DailyCtrl.ButtonType[]
  57. {
  58. DailyCtrl.ButtonType.Dance,
  59. DailyCtrl.ButtonType.Casino,
  60. DailyCtrl.ButtonType.CompetitiveShow
  61. };
  62. }
  63. }
  64. else if (DailyMgr.IsLegacy)
  65. {
  66. array3 = new DailyCtrl.ButtonType[]
  67. {
  68. DailyCtrl.ButtonType.Schedule,
  69. DailyCtrl.ButtonType.CompetitiveShow,
  70. DailyCtrl.ButtonType.Trophy,
  71. DailyCtrl.ButtonType.PhotoMode,
  72. DailyCtrl.ButtonType.DeskCustomize,
  73. DailyCtrl.ButtonType.MyRoomCustom,
  74. DailyCtrl.ButtonType.Casino,
  75. DailyCtrl.ButtonType.Shop,
  76. DailyCtrl.ButtonType.FacilityManagement,
  77. DailyCtrl.ButtonType.LegacyMode,
  78. DailyCtrl.ButtonType.Karaoke,
  79. DailyCtrl.ButtonType.EventScenario,
  80. DailyCtrl.ButtonType.ManEdit,
  81. DailyCtrl.ButtonType.Credit,
  82. DailyCtrl.ButtonType.Dance
  83. };
  84. }
  85. else
  86. {
  87. array3 = new DailyCtrl.ButtonType[]
  88. {
  89. DailyCtrl.ButtonType.Schedule,
  90. DailyCtrl.ButtonType.CompetitiveShow,
  91. DailyCtrl.ButtonType.LegacyMode
  92. };
  93. }
  94. foreach (DailyCtrl.ButtonType type in array3)
  95. {
  96. this.GetMenuButton(type).active = false;
  97. }
  98. PlayerStatus.Status status = GameMain.Instance.CharacterMgr.status;
  99. if (!status.isAvailableDance)
  100. {
  101. this.GetMenuButton(DailyCtrl.ButtonType.Dance).active = false;
  102. }
  103. if (!status.isAvailableCompetitiveShow)
  104. {
  105. this.GetMenuButton(DailyCtrl.ButtonType.CompetitiveShow).active = false;
  106. }
  107. if (!status.isAvailableShop)
  108. {
  109. this.GetMenuButton(DailyCtrl.ButtonType.Shop).active = false;
  110. }
  111. if (!KaraokeDataManager.IsExistKaraokeData(false))
  112. {
  113. this.GetMenuButton(DailyCtrl.ButtonType.Karaoke).active = false;
  114. }
  115. this.m_goPanel.SetActive(true);
  116. this.SetAllButtonEnable(true);
  117. if (!CasinoDataMgr.Instance.GetCasinoFacility(true) && !CasinoDataMgr.Instance.GetCasinoFacility(false))
  118. {
  119. this.GetMenuButton(DailyCtrl.ButtonType.Casino).button.isEnabled = false;
  120. }
  121. if (!DailyMgr.IsLegacy && daily == DailyMgr.Daily.Daytime)
  122. {
  123. UIButton button = this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).button;
  124. if (GameUty.IsEnabledCompatibilityMode && PluginData.IsEnabled("Legacy"))
  125. {
  126. EventDelegate.Add(button.onClick, new EventDelegate.Callback(this.BackUpScheduleSlot));
  127. this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).button.isEnabled = this.IsEnabledLegacyMode();
  128. }
  129. else
  130. {
  131. this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).active = false;
  132. }
  133. }
  134. foreach (UITable table in this.m_goPanel.GetComponentsInChildren<UITable>())
  135. {
  136. Utility.ResetNGUI(table);
  137. }
  138. foreach (UIGrid grid in this.m_goPanel.GetComponentsInChildren<UIGrid>())
  139. {
  140. Utility.ResetNGUI(grid);
  141. }
  142. StatusViewer component = UTY.GetChildObject(this.m_goPanel, "StatusViewer", false).GetComponent<StatusViewer>();
  143. component.isEnabledClubNameChangeButton = true;
  144. component.isEnabledMainBusinessChangeButton = false;
  145. }
  146. public DailyCtrl.ButtonData GetMenuButton(DailyCtrl.ButtonType type)
  147. {
  148. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  149. {
  150. if (buttonData.type == type)
  151. {
  152. return buttonData;
  153. }
  154. }
  155. return new DailyCtrl.ButtonData
  156. {
  157. button = null,
  158. type = type
  159. };
  160. }
  161. public DailyCtrl.ButtonData GetMenuButton(UIButton button)
  162. {
  163. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  164. {
  165. if (buttonData.button == button)
  166. {
  167. return buttonData;
  168. }
  169. }
  170. return new DailyCtrl.ButtonData
  171. {
  172. button = null,
  173. type = DailyCtrl.ButtonType.Next
  174. };
  175. }
  176. private bool IsEnabledCompetitiveShow()
  177. {
  178. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Daytime && GameMain.Instance.CharacterMgr.status.isAvailableCompetitiveShow;
  179. }
  180. private bool IsEnabledShop()
  181. {
  182. return GameMain.Instance.CharacterMgr.status.isAvailableShop;
  183. }
  184. private bool IsEnabledDance()
  185. {
  186. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Night && GameMain.Instance.CharacterMgr.status.isAvailableDance;
  187. }
  188. private bool IsEnabledVRCom()
  189. {
  190. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Daytime && false;
  191. }
  192. private bool IsEnabledLegacyMode()
  193. {
  194. List<Maid> stockMaidList = GameMain.Instance.CharacterMgr.GetStockMaidList();
  195. bool result = false;
  196. foreach (Maid maid in stockMaidList)
  197. {
  198. if (maid != null && maid.status.heroineType == HeroineType.Transfer)
  199. {
  200. result = true;
  201. }
  202. }
  203. return result;
  204. }
  205. public void SetAllButtonEnable(bool enable)
  206. {
  207. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  208. {
  209. if (buttonData.button.gameObject.activeSelf)
  210. {
  211. buttonData.button.isEnabled = enable;
  212. }
  213. }
  214. }
  215. public void BackUpScheduleSlot()
  216. {
  217. ScheduleAPI.BackUpScheduleSlot();
  218. }
  219. [SerializeField]
  220. private DailyCtrl.ButtonData[] menuButtons;
  221. private DailyMgr m_mgr;
  222. private Dictionary<DailyCtrl.ButtonType, GameObject> m_dicRank;
  223. private GameObject m_goPanel;
  224. private ButtonEnable m_btnEnable;
  225. private bool m_bInit;
  226. public enum ButtonType
  227. {
  228. Dance,
  229. Schedule,
  230. MaidManagement,
  231. EventScenario,
  232. Shop,
  233. FacilityManagement,
  234. CompetitiveShow,
  235. Casino,
  236. Save,
  237. Load,
  238. Trophy,
  239. FreeMode,
  240. PhotoMode,
  241. DeskCustomize,
  242. ManEdit,
  243. LegacyMode,
  244. Karaoke,
  245. Credit,
  246. Next,
  247. MyRoomCustom
  248. }
  249. [Serializable]
  250. public class ButtonData
  251. {
  252. public bool active
  253. {
  254. get
  255. {
  256. return this.button.gameObject.activeSelf;
  257. }
  258. set
  259. {
  260. this.button.gameObject.SetActive(value);
  261. }
  262. }
  263. [SerializeField]
  264. public DailyCtrl.ButtonType type;
  265. [SerializeField]
  266. public UIButton button;
  267. }
  268. }