ScheduleMgr.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using System;
  2. using System.Collections.Generic;
  3. using Schedule;
  4. using UnityEngine;
  5. public class ScheduleMgr : BaseCreatePanel
  6. {
  7. public string CurrentActiveButton { get; set; }
  8. public Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> GetMaidStatusAndTask()
  9. {
  10. return this.m_Ctrl.GetDicMaidStatusAndTask();
  11. }
  12. public ScheduleScene GetScheduleApi()
  13. {
  14. return this.m_scheduleApi;
  15. }
  16. public void SetCurrentDaytimeTaskActiveButton(string taskId)
  17. {
  18. this.currentDaytimeTaskActiveButton = taskId;
  19. }
  20. public void SetCurrentNightTaskActiveButton(string taskId)
  21. {
  22. this.currentNightTaskActiveButton = taskId;
  23. }
  24. public MaidStatusListCtrl MaidStatusListCtrl
  25. {
  26. get
  27. {
  28. return this.m_MaidStatusListCtrl;
  29. }
  30. }
  31. public ScheduleTaskCtrl TaskCtrl
  32. {
  33. get
  34. {
  35. return this.m_TaskCtrl;
  36. }
  37. }
  38. public override void Init()
  39. {
  40. this.m_goPanel = base.GetPanel("SchedulePanel");
  41. this.m_Ctrl = base.GetCtrl<ScheduleCtrl>();
  42. this.m_TaskCtrl = base.GetCtrl<ScheduleTaskCtrl>();
  43. this.m_MaidStatusListCtrl = base.GetCtrl<MaidStatusListCtrl>();
  44. this.m_Ctrl.Init(this, this.m_goPanel);
  45. this.m_TaskCtrl.Init(this, this.m_Ctrl, this.m_goPanel);
  46. this.m_MaidStatusListCtrl.Init(this, this.m_Ctrl, this.m_goPanel);
  47. this.m_goPanel.SetActive(false);
  48. }
  49. protected override void OpenPanel()
  50. {
  51. Debug.Log("スケジュールをオープンしました。");
  52. GameMain.Instance.TutorialPanel.SetImage(TutorialPanel.ImageSet.Schedule, false);
  53. GameMain.Instance.SysShortcut.strSceneHelpName = "SceneSchedule";
  54. this.m_dicMaidStatusAndTask = this.LoadData();
  55. this.CreateSelectedMaidViewer(this.m_dicMaidStatusAndTask);
  56. }
  57. public void CreateSelectedMaidViewer(Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTask)
  58. {
  59. this.CurrentActiveButton = string.Empty;
  60. this.m_Ctrl.CreateSelectedMaidViewer(dicMaidStatusAndTask);
  61. }
  62. public void CheckSelectedDataBeforeClosePanel()
  63. {
  64. if (this.m_Ctrl.ExistSelectedMaid())
  65. {
  66. base.BaseClosePanel();
  67. }
  68. }
  69. public void UpdateMaidStatus()
  70. {
  71. this.m_dicMaidStatusAndTask = this.LoadData();
  72. this.CreateSelectedMaidViewer(this.m_dicMaidStatusAndTask);
  73. if (!DailyMgr.IsLegacy)
  74. {
  75. GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
  76. }
  77. }
  78. public void ClickMaidStatus()
  79. {
  80. string name = UIButton.current.name;
  81. if (UICamera.currentTouchID == -1)
  82. {
  83. if (this.CurrentActiveButton == name)
  84. {
  85. return;
  86. }
  87. Debug.Log(string.Format("{0}ボタンがクリックされました。", name));
  88. this.m_MaidStatusListCtrl.CreateTaskViewer(name);
  89. this.CurrentActiveButton = name;
  90. }
  91. else if (UICamera.currentTouchID == -2)
  92. {
  93. Debug.Log(string.Format("{0}ボタンが右クリックされました。", name));
  94. if (this.m_Ctrl.CanDeleteData(name))
  95. {
  96. this.m_Ctrl.DeleteMaidStatus(this.m_scheduleApi, name);
  97. }
  98. }
  99. }
  100. public void ClickTask(ScheduleMgr.ScheduleTime time)
  101. {
  102. string name = UIButton.current.name;
  103. if (this.CurrentActiveButton == name)
  104. {
  105. return;
  106. }
  107. Debug.Log(string.Format("{0}ボタンがクリックされました。", name));
  108. this.m_TaskCtrl.CreateTaskViewer(name, time);
  109. this.CurrentActiveButton = name;
  110. }
  111. public EventDelegate ClickTaskEvent(ScheduleMgr.ScheduleTime time, ref List<EventDelegate> events)
  112. {
  113. EventDelegate eventDelegate = new EventDelegate(this, "ClickTask");
  114. eventDelegate.parameters[0].value = time;
  115. EventDelegate.Add(events, eventDelegate);
  116. return eventDelegate;
  117. }
  118. public void ClickMaidStatusInListViewer(Maid maid)
  119. {
  120. string guid = maid.status.guid;
  121. this.m_MaidStatusListCtrl.MoveMaidToSlot(this.m_scheduleApi, maid);
  122. }
  123. public void ClickTaskInTaskViewer()
  124. {
  125. string name = UIButton.current.name;
  126. if (this.currentNightTaskActiveButton == name)
  127. {
  128. return;
  129. }
  130. if (this.m_TaskCtrl.CanSetTask(ScheduleTaskCtrl.TaskType.Yotogi, int.Parse(name)))
  131. {
  132. this.m_TaskCtrl.UpdateSelectedMaidTask(name);
  133. }
  134. else
  135. {
  136. this.m_TaskCtrl.UpdateTaskViewer(name);
  137. }
  138. this.currentNightTaskActiveButton = name;
  139. }
  140. public void UpdateTask(string taskId)
  141. {
  142. this.m_TaskCtrl.UpdateSelectedMaidTask(taskId);
  143. }
  144. public void SetActiveSlotNo(string slotNo)
  145. {
  146. this.m_Ctrl.SetActiveSlotNo(slotNo);
  147. }
  148. public Maid GetMaidBySlotNo(string slotNo)
  149. {
  150. return this.m_Ctrl.GetMaidBySlotNo(slotNo);
  151. }
  152. protected override void SetFadeTargetPanel()
  153. {
  154. this.fadeTargetPanel = this.m_goPanel;
  155. }
  156. protected override void AfterFadeOut()
  157. {
  158. DailyMgr manager = base.GetManager<DailyMgr>();
  159. manager.BaseOpenPanel(manager.GetCurrentDaily().ToString());
  160. base.AfterFadeOut();
  161. }
  162. protected override void BeforeClose()
  163. {
  164. UICamera.InputEnable = false;
  165. }
  166. protected override void AfterClose()
  167. {
  168. UICamera.InputEnable = true;
  169. }
  170. private void OnDestroy()
  171. {
  172. if (this.m_scheduleApi != null)
  173. {
  174. this.m_scheduleApi.Dispace();
  175. }
  176. }
  177. private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> LoadData()
  178. {
  179. if (!this.m_initScheduleScene)
  180. {
  181. this.m_scheduleApi = new ScheduleScene();
  182. this.m_initScheduleScene = true;
  183. }
  184. Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dictionary = new Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit>();
  185. if (this.m_scheduleApi.slot == null || this.m_scheduleApi.slot.Length <= 0)
  186. {
  187. return dictionary;
  188. }
  189. foreach (Slot slot2 in this.m_scheduleApi.slot)
  190. {
  191. if (!(slot2.maid == null))
  192. {
  193. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = new ScheduleCtrl.MaidStatusAndTaskUnit();
  194. maidStatusAndTaskUnit.slotNo = slot2.slotId;
  195. maidStatusAndTaskUnit.daytimeTaskId = slot2.noonWorkId.ToString();
  196. maidStatusAndTaskUnit.taskIcon = slot2.noon_icon;
  197. maidStatusAndTaskUnit.daytimeTaskName = this.GetTaskName(slot2, slot2.noonWorkId);
  198. maidStatusAndTaskUnit.daytimeCommu = slot2.noonCommuFlag;
  199. maidStatusAndTaskUnit.nightTaskId = slot2.nightWorkId.ToString();
  200. maidStatusAndTaskUnit.nightTaskIcon = slot2.night_icon;
  201. maidStatusAndTaskUnit.nightTaskName = this.GetTaskName(slot2, slot2.nightWorkId);
  202. maidStatusAndTaskUnit.nightCommu = slot2.nightCommuFlag;
  203. maidStatusAndTaskUnit.maidStatus = new MaidStatusListCtrl.MaidStatusButton
  204. {
  205. maid = slot2.maid,
  206. id = slot2.maid.status.guid,
  207. isReader = slot2.leader,
  208. maidIcon = slot2.icon,
  209. firstName = slot2.first_name,
  210. lastName = slot2.last_name,
  211. Rranking = slot2.popular_rank,
  212. crownIcon = slot2.popular_rank_icon,
  213. contractTypeName = slot2.contract_type_name
  214. };
  215. dictionary.Add(string.Format("slot_{0}", maidStatusAndTaskUnit.slotNo), maidStatusAndTaskUnit);
  216. }
  217. }
  218. return dictionary;
  219. }
  220. private string GetTaskName(Slot slotInfo, int taskId)
  221. {
  222. List<ScheduleBase> noonWorksData = slotInfo.noonWorksData;
  223. foreach (ScheduleBase scheduleBase in noonWorksData)
  224. {
  225. if (scheduleBase.id == taskId)
  226. {
  227. return scheduleBase.name;
  228. }
  229. }
  230. return string.Empty;
  231. }
  232. public const string BUTTON_NAME_TEMPLATE = "slot_{0}";
  233. public const int MAX_SLOT_COUNT = 9;
  234. private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> m_dicMaidStatusAndTask;
  235. private ScheduleCtrl m_Ctrl;
  236. private ScheduleTaskCtrl m_TaskCtrl;
  237. private MaidStatusListCtrl m_MaidStatusListCtrl;
  238. private ScheduleScene m_scheduleApi;
  239. private bool m_initScheduleScene;
  240. private string currentDaytimeTaskActiveButton;
  241. private string currentNightTaskActiveButton;
  242. private const int MIN_MAID_COUNT = 1;
  243. private const int LeftClick = -1;
  244. private const int RightClick = -2;
  245. public enum ScheduleTime
  246. {
  247. DayTime,
  248. Night
  249. }
  250. }