ScheduleCtrl.cs 26 KB

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