DailyCtrl.cs 7.7 KB

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