DailyCtrl.cs 7.1 KB

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