DailyCtrl.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. using System;
  2. using System.Collections.Generic;
  3. using com.workman.cm3d2.button;
  4. using PlayerStatus;
  5. using PrivateMaidMode;
  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. DailyCtrl.ButtonType.NPCEdit,
  53. DailyCtrl.ButtonType.PrivateMaidModeSetting
  54. };
  55. }
  56. else
  57. {
  58. array3 = new DailyCtrl.ButtonType[]
  59. {
  60. DailyCtrl.ButtonType.Dance,
  61. DailyCtrl.ButtonType.Casino,
  62. DailyCtrl.ButtonType.CompetitiveShow
  63. };
  64. }
  65. }
  66. else if (DailyMgr.IsLegacy)
  67. {
  68. array3 = new DailyCtrl.ButtonType[]
  69. {
  70. DailyCtrl.ButtonType.Schedule,
  71. DailyCtrl.ButtonType.CompetitiveShow,
  72. DailyCtrl.ButtonType.Trophy,
  73. DailyCtrl.ButtonType.PhotoMode,
  74. DailyCtrl.ButtonType.DeskCustomize,
  75. DailyCtrl.ButtonType.MyRoomCustom,
  76. DailyCtrl.ButtonType.Casino,
  77. DailyCtrl.ButtonType.Shop,
  78. DailyCtrl.ButtonType.FacilityManagement,
  79. DailyCtrl.ButtonType.LegacyMode,
  80. DailyCtrl.ButtonType.Karaoke,
  81. DailyCtrl.ButtonType.EventScenario,
  82. DailyCtrl.ButtonType.ManEdit,
  83. DailyCtrl.ButtonType.Credit,
  84. DailyCtrl.ButtonType.Dance,
  85. DailyCtrl.ButtonType.NPCEdit,
  86. DailyCtrl.ButtonType.PrivateMaidModeSetting
  87. };
  88. }
  89. else
  90. {
  91. array3 = new DailyCtrl.ButtonType[]
  92. {
  93. DailyCtrl.ButtonType.Schedule,
  94. DailyCtrl.ButtonType.CompetitiveShow,
  95. DailyCtrl.ButtonType.LegacyMode
  96. };
  97. }
  98. this.GetMenuButton(DailyCtrl.ButtonType.NPCEdit).active = (!Product.isPublic && PluginData.IsEnabled("GP001"));
  99. this.GetMenuButton(DailyCtrl.ButtonType.PrivateMaidModeSetting).active = PluginData.IsEnabled("GP002");
  100. foreach (DailyCtrl.ButtonType type in array3)
  101. {
  102. this.GetMenuButton(type).active = false;
  103. }
  104. Status status = GameMain.Instance.CharacterMgr.status;
  105. if (!status.isAvailableDance)
  106. {
  107. this.GetMenuButton(DailyCtrl.ButtonType.Dance).active = false;
  108. }
  109. if (!status.isAvailableCompetitiveShow)
  110. {
  111. this.GetMenuButton(DailyCtrl.ButtonType.CompetitiveShow).active = false;
  112. }
  113. if (!status.isAvailableShop)
  114. {
  115. this.GetMenuButton(DailyCtrl.ButtonType.Shop).active = false;
  116. }
  117. if (!KaraokeDataManager.IsExistKaraokeData(false))
  118. {
  119. this.GetMenuButton(DailyCtrl.ButtonType.Karaoke).active = false;
  120. }
  121. this.m_goPanel.SetActive(true);
  122. this.SetAllButtonEnable(true);
  123. if (!CasinoDataMgr.Instance.GetCasinoFacility(true) && !CasinoDataMgr.Instance.GetCasinoFacility(false))
  124. {
  125. this.GetMenuButton(DailyCtrl.ButtonType.Casino).button.isEnabled = false;
  126. }
  127. if (!DailyMgr.IsLegacy && daily == DailyMgr.Daily.Daytime)
  128. {
  129. UIButton button = this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).button;
  130. if (GameUty.IsEnabledCompatibilityMode && PluginData.IsEnabled("Legacy"))
  131. {
  132. EventDelegate.Add(button.onClick, new EventDelegate.Callback(this.BackUpScheduleSlot));
  133. this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).button.isEnabled = this.IsEnabledLegacyMode();
  134. }
  135. else
  136. {
  137. this.GetMenuButton(DailyCtrl.ButtonType.LegacyMode).active = false;
  138. }
  139. }
  140. this.GetMenuButton(DailyCtrl.ButtonType.DeskCustomize).button.isEnabled = (PrivateModeMgr.Instance.PrivateMaid == null);
  141. foreach (UITable table in this.m_goPanel.GetComponentsInChildren<UITable>())
  142. {
  143. Utility.ResetNGUI(table);
  144. }
  145. foreach (UIGrid grid in this.m_goPanel.GetComponentsInChildren<UIGrid>())
  146. {
  147. Utility.ResetNGUI(grid);
  148. }
  149. StatusViewer component = UTY.GetChildObject(this.m_goPanel, "StatusViewer", false).GetComponent<StatusViewer>();
  150. component.isEnabledClubNameChangeButton = true;
  151. component.isEnabledMainBusinessChangeButton = false;
  152. if (daily == DailyMgr.Daily.Daytime && !DailyMgr.IsLegacy && (PluginData.IsEnabled("GP001") || PluginData.IsEnabled("GP002")))
  153. {
  154. component.isEnabledGameModeChangeButton = true;
  155. }
  156. else
  157. {
  158. component.isEnabledGameModeChangeButton = false;
  159. }
  160. }
  161. public DailyCtrl.ButtonData GetMenuButton(DailyCtrl.ButtonType type)
  162. {
  163. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  164. {
  165. if (buttonData.type == type)
  166. {
  167. return buttonData;
  168. }
  169. }
  170. return new DailyCtrl.ButtonData
  171. {
  172. button = null,
  173. type = type
  174. };
  175. }
  176. public DailyCtrl.ButtonData GetMenuButton(UIButton button)
  177. {
  178. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  179. {
  180. if (buttonData.button == button)
  181. {
  182. return buttonData;
  183. }
  184. }
  185. return new DailyCtrl.ButtonData
  186. {
  187. button = null,
  188. type = DailyCtrl.ButtonType.Next
  189. };
  190. }
  191. private bool IsEnabledCompetitiveShow()
  192. {
  193. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Daytime && GameMain.Instance.CharacterMgr.status.isAvailableCompetitiveShow;
  194. }
  195. private bool IsEnabledShop()
  196. {
  197. return GameMain.Instance.CharacterMgr.status.isAvailableShop;
  198. }
  199. private bool IsEnabledDance()
  200. {
  201. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Night && GameMain.Instance.CharacterMgr.status.isAvailableDance;
  202. }
  203. private bool IsEnabledVRCom()
  204. {
  205. return this.m_mgr.GetCurrentDaily() == DailyMgr.Daily.Daytime && false;
  206. }
  207. private bool IsEnabledLegacyMode()
  208. {
  209. List<Maid> stockMaidList = GameMain.Instance.CharacterMgr.GetStockMaidList();
  210. bool result = false;
  211. foreach (Maid maid in stockMaidList)
  212. {
  213. if (maid != null && maid.status.isCompatiblePersonality)
  214. {
  215. result = true;
  216. }
  217. }
  218. return result;
  219. }
  220. public void SetAllButtonEnable(bool enable)
  221. {
  222. foreach (DailyCtrl.ButtonData buttonData in this.menuButtons)
  223. {
  224. if (buttonData.button.gameObject.activeSelf)
  225. {
  226. buttonData.button.isEnabled = enable;
  227. }
  228. }
  229. }
  230. public void BackUpScheduleSlot()
  231. {
  232. ScheduleAPI.BackUpScheduleSlot();
  233. }
  234. [SerializeField]
  235. private DailyCtrl.ButtonData[] menuButtons;
  236. private DailyMgr m_mgr;
  237. private Dictionary<DailyCtrl.ButtonType, GameObject> m_dicRank;
  238. private GameObject m_goPanel;
  239. private ButtonEnable m_btnEnable;
  240. private bool m_bInit;
  241. public enum ButtonType
  242. {
  243. Dance,
  244. Schedule,
  245. MaidManagement,
  246. EventScenario,
  247. Shop,
  248. FacilityManagement,
  249. CompetitiveShow,
  250. Casino,
  251. Save,
  252. Load,
  253. Trophy,
  254. FreeMode,
  255. PhotoMode,
  256. DeskCustomize,
  257. ManEdit,
  258. LegacyMode,
  259. Karaoke,
  260. Credit,
  261. Next,
  262. MyRoomCustom,
  263. NPCEdit,
  264. PrivateMaidModeSetting
  265. }
  266. [Serializable]
  267. public class ButtonData
  268. {
  269. public bool active
  270. {
  271. get
  272. {
  273. return this.button.gameObject.activeSelf;
  274. }
  275. set
  276. {
  277. this.button.gameObject.SetActive(value);
  278. }
  279. }
  280. [SerializeField]
  281. public DailyCtrl.ButtonType type;
  282. [SerializeField]
  283. public UIButton button;
  284. }
  285. }