ScheduleCtrl.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Schedule;
  5. using UnityEngine;
  6. public class ScheduleCtrl : BaseCreateViewerCtrl
  7. {
  8. public Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> GetDicMaidStatusAndTask()
  9. {
  10. return this.m_dicMaidStatusAndTask;
  11. }
  12. public Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject> DicExclusiveViewer { get; set; }
  13. public Color GetActiveColor()
  14. {
  15. return this.activeColor;
  16. }
  17. public Color GetInActiveColor()
  18. {
  19. return this.inActiveColor;
  20. }
  21. public Color GetDisableColor()
  22. {
  23. return this.disableColor;
  24. }
  25. public string GetMaidId()
  26. {
  27. return this.m_maidId;
  28. }
  29. public string GetActiveSlotNo()
  30. {
  31. return this.m_activeSlotNo;
  32. }
  33. public void SetActiveSlotNo(string slotNo)
  34. {
  35. this.m_activeSlotNo = slotNo;
  36. }
  37. public GameObject GetUnitParent
  38. {
  39. get
  40. {
  41. return this.m_goUnitParent;
  42. }
  43. }
  44. public Maid SelectedMaid
  45. {
  46. get
  47. {
  48. return this.selectedMaid;
  49. }
  50. }
  51. public void Init(ScheduleMgr scheduleMgr, GameObject goPanel)
  52. {
  53. this.m_scheduleMgr = scheduleMgr;
  54. this.m_goPanel = goPanel;
  55. }
  56. private void InitViewer()
  57. {
  58. GameObject childObject = UTY.GetChildObject(this.m_goPanel, "ScheduleTaskViewer", false);
  59. GameObject childObject2 = UTY.GetChildObject(this.m_goPanel, "CharacterSelectPanel", false);
  60. UIButton component = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Ok", false).GetComponent<UIButton>();
  61. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_scheduleMgr.CheckSelectedDataBeforeClosePanel));
  62. this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
  63. this.inActiveColor = component.defaultColor;
  64. this.disableColor = new Color(0.7f, 0.7f, 0.7f, 1f);
  65. this.m_unitPrefabPath = "SceneDaily/Schedule/Prefab/MaidStatusUnit";
  66. this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Contents/SelectedMaidUnitParent", false);
  67. this.DicExclusiveViewer = new Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject>();
  68. this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.MaidStatusList, childObject2);
  69. this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.Task, childObject);
  70. GameObject x = GameObject.Find("__GameMain__/SystemUI Root");
  71. NDebug.Assert(x != null, string.Format("{0}が見つかりませんでした。", "UI Root"));
  72. ScheduleCtrl.m_readerIcon = Resources.Load<Texture2D>("SceneDaily/Schedule/Texture/cm3d2_management_maidchou");
  73. this.m_charSelMgr = UTY.GetChildObject(this.m_goPanel, "CharacterSelectPanel", false).GetComponent<CharacterSelectManager>();
  74. }
  75. public void CreateRoomViewer()
  76. {
  77. }
  78. public void CreateSelectedMaidViewer(Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTaskInfo)
  79. {
  80. if (!this.m_bInit)
  81. {
  82. this.InitViewer();
  83. this.m_bInit = true;
  84. }
  85. this.m_dicMaidStatusAndTask = dicMaidStatusAndTaskInfo;
  86. this.SetViewerActive(ScheduleCtrl.ExclusiveViewer.None);
  87. base.CreateViewerWhenDataNotExist<string, ScheduleCtrl.MaidStatusAndTaskUnit>(dicMaidStatusAndTaskInfo);
  88. }
  89. protected override void SetDataForViewer()
  90. {
  91. for (int i = 0; i < 40; i++)
  92. {
  93. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
  94. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  95. if (this.m_dicMaidStatusAndTask.TryGetValue(string.Format("slot_{0}", i), out maidStatusAndTaskUnit))
  96. {
  97. if (maidStatusAndTaskUnit.isEmpty)
  98. {
  99. maidStatusAndTaskUnit = this.CreateEmptyUnit(i);
  100. ScheduleCtrl.SetEmptyMaidStatus(gameObject);
  101. }
  102. else
  103. {
  104. ScheduleCtrl.SetMaidStatus(UTY.GetChildObject(gameObject, "MaidStatus", false), maidStatusAndTaskUnit);
  105. }
  106. }
  107. else
  108. {
  109. maidStatusAndTaskUnit = this.CreateEmptyUnit(i);
  110. ScheduleCtrl.SetEmptyMaidStatus(gameObject);
  111. }
  112. gameObject.name = string.Format("slot_{0}", i);
  113. base.SetTransformInfo(gameObject);
  114. GameObject childObject = UTY.GetChildObject(gameObject, "MaidStatus", false);
  115. UIButton component = childObject.GetComponent<UIButton>();
  116. maidStatusAndTaskUnit.uiBtnMaidStatus = component;
  117. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_scheduleMgr.ClickMaidStatus));
  118. GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
  119. childObject2.SetActive(false);
  120. maidStatusAndTaskUnit.goSelectCursorMaidStatus = childObject2;
  121. childObject.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.MaidStatus, i);
  122. GameObject childObject3 = UTY.GetChildObject(gameObject, "DaytimeTask", false);
  123. UIButton component2 = childObject3.GetComponent<UIButton>();
  124. maidStatusAndTaskUnit.uiBtnDaytimeTask = component2;
  125. this.m_scheduleMgr.ClickTaskEvent(ScheduleMgr.ScheduleTime.DayTime, ref component2.onClick);
  126. if (!string.IsNullOrEmpty(maidStatusAndTaskUnit.daytimeTaskId))
  127. {
  128. UITexture component3 = childObject3.GetComponent<UITexture>();
  129. component3.mainTexture = maidStatusAndTaskUnit.taskIcon;
  130. maidStatusAndTaskUnit.uiDaytimeTaskIcon = component3;
  131. }
  132. Maid scheduleSlot = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(i);
  133. GameObject childObject4 = UTY.GetChildObject(childObject3, "SelectCursor", false);
  134. childObject4.SetActive(false);
  135. maidStatusAndTaskUnit.goSelectCursorDaytimeTask = childObject4;
  136. OnHoverTaskIcon component4 = childObject3.GetComponent<OnHoverTaskIcon>();
  137. component4.Init(maidStatusAndTaskUnit.daytimeTaskName, scheduleSlot, ScheduleMgr.ScheduleTime.DayTime);
  138. childObject3.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.DaytimeTask, i);
  139. GameObject childObject5 = UTY.GetChildObject(gameObject, "NightTask", false);
  140. UIButton component5 = childObject5.GetComponent<UIButton>();
  141. maidStatusAndTaskUnit.uiBtnNightTask = component5;
  142. this.m_scheduleMgr.ClickTaskEvent(ScheduleMgr.ScheduleTime.Night, ref component5.onClick);
  143. if (!string.IsNullOrEmpty(maidStatusAndTaskUnit.nightTaskId))
  144. {
  145. UITexture component6 = childObject5.GetComponent<UITexture>();
  146. component6.mainTexture = maidStatusAndTaskUnit.nightTaskIcon;
  147. maidStatusAndTaskUnit.uiNightTaskIcon = component6;
  148. }
  149. GameObject childObject6 = UTY.GetChildObject(childObject5, "SelectCursor", false);
  150. childObject6.SetActive(false);
  151. maidStatusAndTaskUnit.goSelectCursorNightTask = childObject6;
  152. OnHoverTaskIcon component7 = childObject5.GetComponent<OnHoverTaskIcon>();
  153. component7.Init(maidStatusAndTaskUnit.nightTaskName, scheduleSlot, ScheduleMgr.ScheduleTime.Night);
  154. childObject5.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.NightTask, i);
  155. GameObject childObject7 = UTY.GetChildObject(gameObject, "CommuNoon", false);
  156. maidStatusAndTaskUnit.uiTglCommuDaytime = this.SettingToggle(childObject7, ScheduleMgr.ScheduleTime.DayTime, maidStatusAndTaskUnit);
  157. if (!maidStatusAndTaskUnit.uiTglCommuDaytime)
  158. {
  159. childObject7.SetActive(false);
  160. }
  161. GameObject childObject8 = UTY.GetChildObject(gameObject, "CommuNight", false);
  162. maidStatusAndTaskUnit.uiTglCommuNight = this.SettingToggle(childObject8, ScheduleMgr.ScheduleTime.Night, maidStatusAndTaskUnit);
  163. if (!maidStatusAndTaskUnit.uiTglCommuNight)
  164. {
  165. childObject8.SetActive(false);
  166. }
  167. }
  168. }
  169. private UIToggle SettingToggle(GameObject obj, ScheduleMgr.ScheduleTime time, ScheduleCtrl.MaidStatusAndTaskUnit unit)
  170. {
  171. if (unit.isEmpty)
  172. {
  173. return null;
  174. }
  175. int key = 0;
  176. Maid scheduleSlot = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(unit.slotNo);
  177. if (time == ScheduleMgr.ScheduleTime.DayTime)
  178. {
  179. if (!int.TryParse(unit.daytimeTaskId, out key))
  180. {
  181. scheduleSlot.status.noonCommu = false;
  182. return null;
  183. }
  184. }
  185. else if (time == ScheduleMgr.ScheduleTime.Night && !int.TryParse(unit.nightTaskId, out key))
  186. {
  187. scheduleSlot.status.nightCommu = false;
  188. return null;
  189. }
  190. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[key];
  191. if (!scheduleBase.isCommu)
  192. {
  193. if (time == ScheduleMgr.ScheduleTime.DayTime)
  194. {
  195. scheduleSlot.status.noonCommu = false;
  196. }
  197. if (time == ScheduleMgr.ScheduleTime.Night)
  198. {
  199. scheduleSlot.status.nightCommu = false;
  200. }
  201. return null;
  202. }
  203. UIToggle component = obj.GetComponent<UIToggle>();
  204. if (time == ScheduleMgr.ScheduleTime.DayTime)
  205. {
  206. component.startsActive = unit.daytimeCommu;
  207. }
  208. if (time == ScheduleMgr.ScheduleTime.Night)
  209. {
  210. component.startsActive = unit.nightCommu;
  211. }
  212. component.optionCanBeNone = true;
  213. component.group = (int)(1 + time);
  214. EventDelegate eventDelegate = new EventDelegate(this, "ClickCommu");
  215. eventDelegate.parameters[0].value = time;
  216. eventDelegate.parameters[1].value = unit.maidStatus.id;
  217. eventDelegate.parameters[2].obj = component;
  218. EventDelegate.Add(component.onChange, eventDelegate);
  219. return component;
  220. }
  221. private void ClickCommu(ScheduleMgr.ScheduleTime time, string guid, UIToggle toggle)
  222. {
  223. if (toggle != UIToggle.current)
  224. {
  225. return;
  226. }
  227. this.m_scheduleMgr.TaskCtrl.SetCommu(time, guid, toggle.value);
  228. }
  229. private ScheduleCtrl.MaidStatusAndTaskUnit CreateEmptyUnit(int slotNo)
  230. {
  231. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = new ScheduleCtrl.MaidStatusAndTaskUnit();
  232. maidStatusAndTaskUnit.slotNo = slotNo;
  233. maidStatusAndTaskUnit.isEmpty = true;
  234. MaidStatusListCtrl.MaidStatusButton maidStatus = new MaidStatusListCtrl.MaidStatusButton();
  235. maidStatusAndTaskUnit.maidStatus = maidStatus;
  236. this.m_dicMaidStatusAndTask[string.Format("slot_{0}", maidStatusAndTaskUnit.slotNo)] = maidStatusAndTaskUnit;
  237. return maidStatusAndTaskUnit;
  238. }
  239. public static void SetMaidStatus(GameObject maidStatus, ScheduleCtrl.MaidStatusAndTaskUnit unit = null)
  240. {
  241. UILabel component = UTY.GetChildObject(maidStatus, "Ranking/Value", false).GetComponent<UILabel>();
  242. if (unit != null)
  243. {
  244. component.text = ScheduleCtrl.ConvertValueWhenDefault(unit.maidStatus.Rranking, "-");
  245. }
  246. else
  247. {
  248. component.text = null;
  249. }
  250. UITexture component2 = UTY.GetChildObject(maidStatus, "Ranking/Icon", false).GetComponent<UITexture>();
  251. if (unit != null)
  252. {
  253. component2.mainTexture = unit.maidStatus.crownIcon;
  254. }
  255. else
  256. {
  257. component2.mainTexture = null;
  258. }
  259. GameObject childObject = UTY.GetChildObject(maidStatus, "Status", false);
  260. UILabel component3 = UTY.GetChildObject(childObject, "Name/FirstName", false).GetComponent<UILabel>();
  261. if (unit != null)
  262. {
  263. component3.text = unit.maidStatus.firstName;
  264. }
  265. else
  266. {
  267. component3.text = null;
  268. }
  269. UILabel component4 = UTY.GetChildObject(childObject, "Name/LastName", false).GetComponent<UILabel>();
  270. if (unit != null)
  271. {
  272. component4.text = unit.maidStatus.lastName;
  273. }
  274. else
  275. {
  276. component4.text = null;
  277. }
  278. UILabel component5 = UTY.GetChildObject(childObject, "ContractType/Value", false).GetComponent<UILabel>();
  279. if (unit != null)
  280. {
  281. component5.text = unit.maidStatus.contractTypeName;
  282. }
  283. else
  284. {
  285. component5.text = null;
  286. }
  287. UITexture component6 = UTY.GetChildObject(maidStatus, "Figure/Icon", false).GetComponent<UITexture>();
  288. if (unit != null)
  289. {
  290. component6.mainTexture = unit.maidStatus.maidIcon;
  291. unit.maidStatus.uiMaidIcon = component6;
  292. }
  293. else
  294. {
  295. component6.mainTexture = null;
  296. }
  297. UITexture component7 = UTY.GetChildObject(maidStatus, "Status/Reader", false).GetComponent<UITexture>();
  298. if (unit != null)
  299. {
  300. if (unit.maidStatus.isReader)
  301. {
  302. component7.mainTexture = ScheduleCtrl.m_readerIcon;
  303. }
  304. else
  305. {
  306. component7.mainTexture = null;
  307. }
  308. }
  309. else
  310. {
  311. component7.mainTexture = null;
  312. }
  313. }
  314. public static string ConvertValueWhenDefault(int input, string output)
  315. {
  316. if (input == 0)
  317. {
  318. return output;
  319. }
  320. return input.ToString();
  321. }
  322. public static void SetEmptyMaidStatus(GameObject maidStatusUnit)
  323. {
  324. GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
  325. UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
  326. UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
  327. UTY.GetChildObject(childObject, "Status", false).SetActive(false);
  328. GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "DaytimeTask", false);
  329. childObject2.SetActive(false);
  330. GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "NightTask", false);
  331. childObject3.SetActive(false);
  332. }
  333. public static void SetEmptyMaidStatusResult(GameObject maidStatusUnit)
  334. {
  335. GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
  336. childObject.SetActive(false);
  337. UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
  338. UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
  339. UTY.GetChildObject(childObject, "Status", false).SetActive(false);
  340. GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "Task", false);
  341. childObject2.SetActive(false);
  342. GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "CommuNoon", false);
  343. childObject3.SetActive(false);
  344. }
  345. public void SetViewerActive(ScheduleCtrl.ExclusiveViewer viewer)
  346. {
  347. foreach (KeyValuePair<ScheduleCtrl.ExclusiveViewer, GameObject> keyValuePair in this.DicExclusiveViewer)
  348. {
  349. ScheduleCtrl.ExclusiveViewer key = keyValuePair.Key;
  350. GameObject value = keyValuePair.Value;
  351. if (key == viewer)
  352. {
  353. value.SetActive(true);
  354. this.m_currentActiveViewer = key;
  355. }
  356. else
  357. {
  358. value.SetActive(false);
  359. }
  360. }
  361. }
  362. public string GetMaidIdByButtonName(string buttonName)
  363. {
  364. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  365. if (maidStatusAndTaskUnitByButtonName != null)
  366. {
  367. return maidStatusAndTaskUnitByButtonName.maidStatus.id;
  368. }
  369. return null;
  370. }
  371. public Maid GetMaidByButtonName(string buttonName)
  372. {
  373. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  374. if (maidStatusAndTaskUnitByButtonName != null && maidStatusAndTaskUnitByButtonName.maidStatus != null && maidStatusAndTaskUnitByButtonName.maidStatus.maid != null)
  375. {
  376. return maidStatusAndTaskUnitByButtonName.maidStatus.maid;
  377. }
  378. return null;
  379. }
  380. public ScheduleCtrl.MaidStatusAndTaskUnit GetMaidStatusAndTaskUnitByButtonName(string buttonName)
  381. {
  382. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  383. ScheduleCtrl.MaidStatusAndTaskUnit result = null;
  384. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out result))
  385. {
  386. return result;
  387. }
  388. return null;
  389. }
  390. public static ScheduleCtrl.Slot GetSlotByButtonName(string buttonName)
  391. {
  392. ScheduleCtrl.Slot slot = new ScheduleCtrl.Slot();
  393. if (string.IsNullOrEmpty(buttonName))
  394. {
  395. return slot;
  396. }
  397. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.MaidStatus.ToString()))
  398. {
  399. int num = buttonName.IndexOf(ScheduleCtrl.SlotColumn.MaidStatus.ToString());
  400. slot.slotNo = buttonName.Substring(0, num - 1);
  401. slot.slotColumn = ScheduleCtrl.SlotColumn.MaidStatus;
  402. }
  403. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.DaytimeTask.ToString()))
  404. {
  405. int num2 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.DaytimeTask.ToString());
  406. slot.slotNo = buttonName.Substring(0, num2 - 1);
  407. slot.slotColumn = ScheduleCtrl.SlotColumn.DaytimeTask;
  408. }
  409. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.NightTask.ToString()))
  410. {
  411. int num3 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.NightTask.ToString());
  412. slot.slotNo = buttonName.Substring(0, num3 - 1);
  413. slot.slotColumn = ScheduleCtrl.SlotColumn.NightTask;
  414. }
  415. return slot;
  416. }
  417. public static int GetSlotNoByButtonName(string buttonName)
  418. {
  419. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  420. return ScheduleCtrl.ToIntSlotNo(slotByButtonName.slotNo);
  421. }
  422. public void SetSelectedRowActive(string buttonName)
  423. {
  424. if (string.IsNullOrEmpty(buttonName))
  425. {
  426. return;
  427. }
  428. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  429. ScheduleCtrl.Slot slotByButtonName2 = ScheduleCtrl.GetSlotByButtonName(this.m_scheduleMgr.CurrentActiveButton);
  430. this.m_activeSlotNo = slotByButtonName.slotNo;
  431. if (slotByButtonName.slotNo == slotByButtonName2.slotNo)
  432. {
  433. ScheduleCtrl.MaidStatusAndTaskUnit unit = null;
  434. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit))
  435. {
  436. this.SetSelectCursorActive(unit, slotByButtonName.slotColumn, true);
  437. this.SetSelectCursorActive(unit, slotByButtonName2.slotColumn, false);
  438. }
  439. }
  440. else
  441. {
  442. ScheduleCtrl.MaidStatusAndTaskUnit unit2 = null;
  443. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit2))
  444. {
  445. this.SetSelectCursorActive(unit2, slotByButtonName.slotColumn, true);
  446. this.SetSlotRowActiveColor(unit2, true);
  447. }
  448. ScheduleCtrl.MaidStatusAndTaskUnit unit3 = null;
  449. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName2.slotNo, out unit3))
  450. {
  451. this.SetSelectCursorActive(unit3, slotByButtonName2.slotColumn, false);
  452. this.SetSlotRowActiveColor(unit3, false);
  453. }
  454. }
  455. }
  456. private void SetSelectCursorActive(ScheduleCtrl.MaidStatusAndTaskUnit unit, ScheduleCtrl.SlotColumn slotColumn, bool active)
  457. {
  458. if (slotColumn != ScheduleCtrl.SlotColumn.MaidStatus)
  459. {
  460. if (slotColumn != ScheduleCtrl.SlotColumn.DaytimeTask)
  461. {
  462. if (slotColumn == ScheduleCtrl.SlotColumn.NightTask)
  463. {
  464. unit.goSelectCursorNightTask.SetActive(active);
  465. }
  466. }
  467. else
  468. {
  469. unit.goSelectCursorDaytimeTask.SetActive(active);
  470. }
  471. }
  472. else
  473. {
  474. unit.goSelectCursorMaidStatus.SetActive(active);
  475. }
  476. }
  477. private void SetSlotRowActiveColor(ScheduleCtrl.MaidStatusAndTaskUnit unit, bool active)
  478. {
  479. if (active)
  480. {
  481. unit.uiBtnMaidStatus.defaultColor = this.activeColor;
  482. unit.uiBtnDaytimeTask.defaultColor = this.activeColor;
  483. unit.uiBtnNightTask.defaultColor = this.activeColor;
  484. }
  485. else
  486. {
  487. unit.uiBtnMaidStatus.defaultColor = this.inActiveColor;
  488. unit.uiBtnDaytimeTask.defaultColor = this.inActiveColor;
  489. unit.uiBtnNightTask.defaultColor = this.inActiveColor;
  490. }
  491. }
  492. public static int SetActiveExceptForNothing(List<ScheduleCtrl.VariableItem> list, string condition)
  493. {
  494. int num = 0;
  495. foreach (ScheduleCtrl.VariableItem variableItem in list)
  496. {
  497. if (variableItem.value.text == condition)
  498. {
  499. variableItem.item.SetActive(false);
  500. }
  501. else
  502. {
  503. variableItem.item.SetActive(true);
  504. num++;
  505. }
  506. }
  507. return num;
  508. }
  509. public bool ExistSelectedMaid()
  510. {
  511. if (this.m_dicMaidStatusAndTask != null || this.m_dicMaidStatusAndTask.Count > 0)
  512. {
  513. IEnumerable<ScheduleCtrl.MaidStatusAndTaskUnit> source = from value in this.m_dicMaidStatusAndTask.Values
  514. where !value.isEmpty
  515. select value;
  516. if (source.Count<ScheduleCtrl.MaidStatusAndTaskUnit>() > 0)
  517. {
  518. return true;
  519. }
  520. }
  521. GameMain.Instance.SysDlg.Show("スケジュールにキャラクターが\n設定されておりません。", SystemDialog.TYPE.OK, null, null);
  522. return false;
  523. }
  524. public void SetMaidIdByButtonName(string buttonName)
  525. {
  526. this.m_maidId = this.GetMaidIdByButtonName(buttonName);
  527. this.selectedMaid = this.GetMaidByButtonName(buttonName);
  528. }
  529. public void DeleteMaidStatus(ScheduleScene scheduleApi, string buttonName)
  530. {
  531. this.m_scheduleApi = scheduleApi;
  532. string maidName = this.GetMaidName(buttonName);
  533. this.m_deleteSlotNo = ScheduleCtrl.GetSlotByButtonName(buttonName).slotNo;
  534. GameMain.Instance.SysDlg.Show(string.Format("名前:{0}\nスケジュールから削除して\n宜しいですか。", maidName), SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.DeleteMaidAndReDraw), null);
  535. }
  536. private void DeleteMaidAndReDraw()
  537. {
  538. string text = null;
  539. if (this.m_dicMaidStatusAndTask.ContainsKey(this.m_deleteSlotNo))
  540. {
  541. text = this.m_scheduleMgr.CurrentActiveButton;
  542. int slotId = ScheduleCtrl.ToIntSlotNo(this.m_deleteSlotNo);
  543. this.m_scheduleApi.SetSlot_Safe(slotId, null, true, true);
  544. if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.MaidStatusList].activeSelf)
  545. {
  546. this.m_charSelMgr.MoveGridArea(this.GetMaidBySlotNo(this.m_deleteSlotNo));
  547. }
  548. this.m_scheduleMgr.UpdateMaidStatus();
  549. }
  550. GameMain.Instance.SysDlg.Close();
  551. if (!string.IsNullOrEmpty(text))
  552. {
  553. if (text.Contains(this.m_deleteSlotNo))
  554. {
  555. this.SetViewerActive(ScheduleCtrl.ExclusiveViewer.None);
  556. }
  557. else
  558. {
  559. this.SetSelectedRowActive(text);
  560. this.m_scheduleMgr.CurrentActiveButton = text;
  561. this.SetViewerActive(this.m_currentActiveViewer);
  562. if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.Task].activeSelf)
  563. {
  564. this.m_scheduleMgr.UpdateTask("-1");
  565. }
  566. }
  567. }
  568. this.m_deleteSlotNo = null;
  569. this.m_scheduleApi = null;
  570. }
  571. public bool CanDeleteData(string buttonName)
  572. {
  573. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  574. return !maidStatusAndTaskUnitByButtonName.isEmpty && (!maidStatusAndTaskUnitByButtonName.maidStatus.isReader || this.GetSettingMaidCount() != 1);
  575. }
  576. private int GetSettingMaidCount()
  577. {
  578. int num = 0;
  579. foreach (ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit in this.m_dicMaidStatusAndTask.Values)
  580. {
  581. if (!maidStatusAndTaskUnit.isEmpty)
  582. {
  583. num++;
  584. }
  585. }
  586. return num;
  587. }
  588. private string GetMaidName(string buttonName)
  589. {
  590. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  591. if (!maidStatusAndTaskUnitByButtonName.isEmpty)
  592. {
  593. return maidStatusAndTaskUnitByButtonName.maidStatus.lastName + " " + maidStatusAndTaskUnitByButtonName.maidStatus.firstName;
  594. }
  595. return string.Empty;
  596. }
  597. public Maid GetMaidByMaidId(string maidId)
  598. {
  599. Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTask = this.GetDicMaidStatusAndTask();
  600. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in dicMaidStatusAndTask)
  601. {
  602. ScheduleCtrl.MaidStatusAndTaskUnit value = keyValuePair.Value;
  603. if (!value.isEmpty && value.maidStatus.id == maidId)
  604. {
  605. return value.maidStatus.maid;
  606. }
  607. }
  608. return null;
  609. }
  610. public Maid GetMaidBySlotNo(string slotNo)
  611. {
  612. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  613. if (this.m_dicMaidStatusAndTask.TryGetValue(slotNo, out maidStatusAndTaskUnit))
  614. {
  615. return maidStatusAndTaskUnit.maidStatus.maid;
  616. }
  617. return null;
  618. }
  619. public Maid GetMaidByActiveSlot()
  620. {
  621. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  622. if (this.m_dicMaidStatusAndTask.TryGetValue(this.m_activeSlotNo, out maidStatusAndTaskUnit))
  623. {
  624. return maidStatusAndTaskUnit.maidStatus.maid;
  625. }
  626. return null;
  627. }
  628. public static int ToIntSlotNo(string slotNo)
  629. {
  630. if (!string.IsNullOrEmpty(slotNo))
  631. {
  632. return int.Parse(slotNo.Replace("slot_", string.Empty));
  633. }
  634. Debug.LogError(string.Format("不適切なスロットNoが指定されました。指定されたスロットNo={0}", slotNo));
  635. return 9999;
  636. }
  637. private ScheduleMgr m_scheduleMgr;
  638. private CharacterSelectManager m_charSelMgr;
  639. private ScheduleScene m_scheduleApi;
  640. private ScheduleCtrl.ExclusiveViewer m_currentActiveViewer;
  641. private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> m_dicMaidStatusAndTask;
  642. private GameObject m_goPanel;
  643. private static Texture2D m_readerIcon;
  644. private Color activeColor;
  645. private Color inActiveColor;
  646. private Color disableColor;
  647. private string m_activeSlotNo;
  648. private string m_maidId;
  649. private bool m_bInit;
  650. [SerializeField]
  651. private Maid selectedMaid;
  652. private const string UNIT_PARENT_PATH = "SelectedMaidViewer/Contents/SelectedMaidUnitParent";
  653. private const string UNIT_PREFAB_PATH = "SceneDaily/Schedule/Prefab/MaidStatusUnit";
  654. private const string SYSTEM_UI_ROOT_PATH = "__GameMain__/SystemUI Root";
  655. private const string MAID_STATUS_BUTTON_NAME_SUFFIX = "_maidStatus";
  656. private const string DAYTIME_TASK_BUTTON_NAME_SUFFIX = "_daytime";
  657. private const string NIGHT_TASK_BUTTON_NAME_SUFFIX = "_night";
  658. private const string DIALOG_MESSAGE_TO_DELETE = "名前:{0}\nスケジュールから削除して\n宜しいですか。";
  659. private const string DIALOG_MESSAGE_NOT_SELECTED_MAID = "スケジュールにキャラクターが\n設定されておりません。";
  660. private string m_deleteSlotNo;
  661. private const int ERROR_CODE_FOR_SLOTNO = 9999;
  662. public enum SlotColumn
  663. {
  664. MaidStatus,
  665. DaytimeTask,
  666. NightTask
  667. }
  668. public enum ExclusiveViewer
  669. {
  670. None,
  671. MaidStatusList,
  672. Task,
  673. Room
  674. }
  675. public class MaidStatusAndTaskUnit
  676. {
  677. public int slotNo;
  678. public bool isEmpty;
  679. public MaidStatusListCtrl.MaidStatusButton maidStatus;
  680. public string daytimeTaskId;
  681. public string nightTaskId;
  682. public bool daytimeCommu;
  683. public bool nightCommu;
  684. public string daytimeTaskName;
  685. public string nightTaskName;
  686. public Texture2D taskIcon;
  687. public Texture2D nightTaskIcon;
  688. public UITexture uiDaytimeTaskIcon;
  689. public UITexture uiNightTaskIcon;
  690. public UIButton uiBtnMaidStatus;
  691. public UIButton uiBtnDaytimeTask;
  692. public UIButton uiBtnNightTask;
  693. public UIToggle uiTglCommuDaytime;
  694. public UIToggle uiTglCommuNight;
  695. public BoxCollider colliderMaidStatus;
  696. public GameObject goSelectCursorMaidStatus;
  697. public GameObject goSelectCursorDaytimeTask;
  698. public GameObject goSelectCursorNightTask;
  699. }
  700. public class Slot
  701. {
  702. public Slot()
  703. {
  704. this.slotNo = string.Empty;
  705. }
  706. public string slotNo;
  707. public ScheduleCtrl.SlotColumn slotColumn;
  708. }
  709. public class VariableItem
  710. {
  711. public VariableItem(GameObject item, UILabel label)
  712. {
  713. this.item = item;
  714. this.value = label;
  715. }
  716. public GameObject item;
  717. public UILabel value;
  718. }
  719. }