ScheduleCtrl.cs 27 KB

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