ScheduleCtrl.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Schedule;
  5. using UnityEngine;
  6. using wf;
  7. public class ScheduleCtrl : BaseCreateViewerCtrl
  8. {
  9. public Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> GetDicMaidStatusAndTask()
  10. {
  11. return this.m_dicMaidStatusAndTask;
  12. }
  13. public Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject> DicExclusiveViewer { get; set; }
  14. public Color GetActiveColor()
  15. {
  16. return this.activeColor;
  17. }
  18. public Color GetInActiveColor()
  19. {
  20. return this.inActiveColor;
  21. }
  22. public Color GetDisableColor()
  23. {
  24. return this.disableColor;
  25. }
  26. public string GetMaidId()
  27. {
  28. return this.m_maidId;
  29. }
  30. public string GetActiveSlotNo()
  31. {
  32. return this.m_activeSlotNo;
  33. }
  34. public void SetActiveSlotNo(string slotNo)
  35. {
  36. this.m_activeSlotNo = slotNo;
  37. }
  38. public GameObject GetUnitParent
  39. {
  40. get
  41. {
  42. return this.m_goUnitParent;
  43. }
  44. }
  45. public Maid SelectedMaid
  46. {
  47. get
  48. {
  49. return this.selectedMaid;
  50. }
  51. }
  52. public void Init(ScheduleMgr scheduleMgr, GameObject goPanel)
  53. {
  54. this.m_scheduleMgr = scheduleMgr;
  55. this.m_goPanel = goPanel;
  56. }
  57. private void InitViewer()
  58. {
  59. GameObject childObject = UTY.GetChildObject(this.m_goPanel, "ScheduleTaskViewer", false);
  60. GameObject childObject2 = UTY.GetChildObject(this.m_goPanel, "CharacterSelectPanel", false);
  61. UIButton component = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Ok", false).GetComponent<UIButton>();
  62. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_scheduleMgr.CheckSelectedDataBeforeClosePanel));
  63. this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
  64. this.inActiveColor = component.defaultColor;
  65. this.disableColor = new Color(0.7f, 0.7f, 0.7f, 1f);
  66. this.m_unitPrefabPath = "SceneDaily/Schedule/Prefab/MaidStatusUnit";
  67. this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Contents/SelectedMaidUnitParent", false);
  68. this.DicExclusiveViewer = new Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject>();
  69. this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.MaidStatusList, childObject2);
  70. this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.Task, childObject);
  71. GameObject x = GameObject.Find("__GameMain__/SystemUI Root");
  72. NDebug.Assert(x != null, string.Format("{0}が見つかりませんでした。", "UI Root"));
  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. Utility.SetLocalizeTerm(component5, unit.maidStatus.contractTypeNameTerm, false);
  309. }
  310. if (!Product.isPublic && !Product.isJapan)
  311. {
  312. Vector3 localPosition = component5.transform.localPosition;
  313. component5.transform.localPosition = new Vector3(182f, localPosition.y, localPosition.z);
  314. }
  315. if (Product.isPublic)
  316. {
  317. UTY.GetChildObject(childObject, "ContractType", false).SetActive(false);
  318. UTY.GetChildObject(childObject, "public", false).SetActive(true);
  319. UILabel component6 = UTY.GetChildObject(childObject, "public/TextTypeName_public", false).GetComponent<UILabel>();
  320. component6.text = unit.maidStatus.personalName;
  321. Utility.SetLocalizeTerm(component6, unit.maidStatus.personalNameTerm, false);
  322. }
  323. UITexture component7 = UTY.GetChildObject(maidStatus, "Figure/Icon", false).GetComponent<UITexture>();
  324. if (unit != null)
  325. {
  326. component7.mainTexture = unit.maidStatus.maidIcon;
  327. unit.maidStatus.uiMaidIcon = component7;
  328. }
  329. else
  330. {
  331. component7.mainTexture = null;
  332. }
  333. GameObject childObject2 = UTY.GetChildObject(maidStatus, "Status/Reader", false);
  334. if (unit != null)
  335. {
  336. childObject2.SetActive(unit.maidStatus.isReader);
  337. }
  338. else
  339. {
  340. childObject2.SetActive(false);
  341. }
  342. }
  343. public static string ConvertValueWhenDefault(int input, string output)
  344. {
  345. if (input == 0)
  346. {
  347. return output;
  348. }
  349. return input.ToString();
  350. }
  351. public static void SetEmptyMaidStatus(GameObject maidStatusUnit)
  352. {
  353. GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
  354. UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
  355. UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
  356. UTY.GetChildObject(childObject, "Status", false).SetActive(false);
  357. GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "DaytimeTask", false);
  358. childObject2.SetActive(false);
  359. GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "NightTask", false);
  360. childObject3.SetActive(false);
  361. }
  362. public static void SetEmptyMaidStatusResult(GameObject maidStatusUnit)
  363. {
  364. GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
  365. childObject.SetActive(false);
  366. UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
  367. UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
  368. UTY.GetChildObject(childObject, "Status", false).SetActive(false);
  369. GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "Task", false);
  370. childObject2.SetActive(false);
  371. GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "CommuNoon", false);
  372. childObject3.SetActive(false);
  373. }
  374. public void SetViewerActive(ScheduleCtrl.ExclusiveViewer viewer)
  375. {
  376. foreach (KeyValuePair<ScheduleCtrl.ExclusiveViewer, GameObject> keyValuePair in this.DicExclusiveViewer)
  377. {
  378. ScheduleCtrl.ExclusiveViewer key = keyValuePair.Key;
  379. GameObject value = keyValuePair.Value;
  380. if (key == viewer)
  381. {
  382. value.SetActive(true);
  383. this.m_currentActiveViewer = key;
  384. }
  385. else
  386. {
  387. value.SetActive(false);
  388. }
  389. }
  390. }
  391. public string GetMaidIdByButtonName(string buttonName)
  392. {
  393. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  394. if (maidStatusAndTaskUnitByButtonName != null)
  395. {
  396. return maidStatusAndTaskUnitByButtonName.maidStatus.id;
  397. }
  398. return null;
  399. }
  400. public Maid GetMaidByButtonName(string buttonName)
  401. {
  402. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  403. if (maidStatusAndTaskUnitByButtonName != null && maidStatusAndTaskUnitByButtonName.maidStatus != null && maidStatusAndTaskUnitByButtonName.maidStatus.maid != null)
  404. {
  405. return maidStatusAndTaskUnitByButtonName.maidStatus.maid;
  406. }
  407. return null;
  408. }
  409. public ScheduleCtrl.MaidStatusAndTaskUnit GetMaidStatusAndTaskUnitByButtonName(string buttonName)
  410. {
  411. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  412. ScheduleCtrl.MaidStatusAndTaskUnit result = null;
  413. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out result))
  414. {
  415. return result;
  416. }
  417. return null;
  418. }
  419. public static ScheduleCtrl.Slot GetSlotByButtonName(string buttonName)
  420. {
  421. ScheduleCtrl.Slot slot = new ScheduleCtrl.Slot();
  422. if (string.IsNullOrEmpty(buttonName))
  423. {
  424. return slot;
  425. }
  426. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.MaidStatus.ToString()))
  427. {
  428. int num = buttonName.IndexOf(ScheduleCtrl.SlotColumn.MaidStatus.ToString());
  429. slot.slotNo = buttonName.Substring(0, num - 1);
  430. slot.slotColumn = ScheduleCtrl.SlotColumn.MaidStatus;
  431. }
  432. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.DaytimeTask.ToString()))
  433. {
  434. int num2 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.DaytimeTask.ToString());
  435. slot.slotNo = buttonName.Substring(0, num2 - 1);
  436. slot.slotColumn = ScheduleCtrl.SlotColumn.DaytimeTask;
  437. }
  438. if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.NightTask.ToString()))
  439. {
  440. int num3 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.NightTask.ToString());
  441. slot.slotNo = buttonName.Substring(0, num3 - 1);
  442. slot.slotColumn = ScheduleCtrl.SlotColumn.NightTask;
  443. }
  444. return slot;
  445. }
  446. public static int GetSlotNoByButtonName(string buttonName)
  447. {
  448. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  449. return ScheduleCtrl.ToIntSlotNo(slotByButtonName.slotNo);
  450. }
  451. public void SetSelectedRowActive(string buttonName)
  452. {
  453. if (string.IsNullOrEmpty(buttonName))
  454. {
  455. return;
  456. }
  457. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  458. ScheduleCtrl.Slot slotByButtonName2 = ScheduleCtrl.GetSlotByButtonName(this.m_scheduleMgr.CurrentActiveButton);
  459. this.m_activeSlotNo = slotByButtonName.slotNo;
  460. if (slotByButtonName.slotNo == slotByButtonName2.slotNo)
  461. {
  462. ScheduleCtrl.MaidStatusAndTaskUnit unit = null;
  463. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit))
  464. {
  465. this.SetSelectCursorActive(unit, slotByButtonName.slotColumn, true);
  466. this.SetSelectCursorActive(unit, slotByButtonName2.slotColumn, false);
  467. }
  468. }
  469. else
  470. {
  471. ScheduleCtrl.MaidStatusAndTaskUnit unit2 = null;
  472. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit2))
  473. {
  474. this.SetSelectCursorActive(unit2, slotByButtonName.slotColumn, true);
  475. this.SetSlotRowActiveColor(unit2, true);
  476. }
  477. ScheduleCtrl.MaidStatusAndTaskUnit unit3 = null;
  478. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName2.slotNo, out unit3))
  479. {
  480. this.SetSelectCursorActive(unit3, slotByButtonName2.slotColumn, false);
  481. this.SetSlotRowActiveColor(unit3, false);
  482. }
  483. }
  484. }
  485. private void SetSelectCursorActive(ScheduleCtrl.MaidStatusAndTaskUnit unit, ScheduleCtrl.SlotColumn slotColumn, bool active)
  486. {
  487. if (slotColumn != ScheduleCtrl.SlotColumn.MaidStatus)
  488. {
  489. if (slotColumn != ScheduleCtrl.SlotColumn.DaytimeTask)
  490. {
  491. if (slotColumn == ScheduleCtrl.SlotColumn.NightTask)
  492. {
  493. unit.goSelectCursorNightTask.SetActive(active);
  494. }
  495. }
  496. else
  497. {
  498. unit.goSelectCursorDaytimeTask.SetActive(active);
  499. }
  500. }
  501. else
  502. {
  503. unit.goSelectCursorMaidStatus.SetActive(active);
  504. }
  505. }
  506. private void SetSlotRowActiveColor(ScheduleCtrl.MaidStatusAndTaskUnit unit, bool active)
  507. {
  508. if (active)
  509. {
  510. unit.uiBtnMaidStatus.defaultColor = this.activeColor;
  511. unit.uiBtnDaytimeTask.defaultColor = this.activeColor;
  512. unit.uiBtnNightTask.defaultColor = this.activeColor;
  513. }
  514. else
  515. {
  516. unit.uiBtnMaidStatus.defaultColor = this.inActiveColor;
  517. unit.uiBtnDaytimeTask.defaultColor = this.inActiveColor;
  518. unit.uiBtnNightTask.defaultColor = this.inActiveColor;
  519. }
  520. }
  521. public static int SetActiveExceptForNothing(List<ScheduleCtrl.VariableItem> list, string condition)
  522. {
  523. int num = 0;
  524. foreach (ScheduleCtrl.VariableItem variableItem in list)
  525. {
  526. if (variableItem.value.text == condition)
  527. {
  528. variableItem.item.SetActive(false);
  529. }
  530. else
  531. {
  532. variableItem.item.SetActive(true);
  533. num++;
  534. }
  535. }
  536. return num;
  537. }
  538. public bool ExistSelectedMaid()
  539. {
  540. if (this.m_dicMaidStatusAndTask != null || this.m_dicMaidStatusAndTask.Count > 0)
  541. {
  542. IEnumerable<ScheduleCtrl.MaidStatusAndTaskUnit> source = from value in this.m_dicMaidStatusAndTask.Values
  543. where !value.isEmpty
  544. select value;
  545. if (source.Count<ScheduleCtrl.MaidStatusAndTaskUnit>() > 0)
  546. {
  547. return true;
  548. }
  549. }
  550. GameMain.Instance.SysDlg.Show("スケジュールにキャラクターが\n設定されておりません。", SystemDialog.TYPE.OK, null, null);
  551. return false;
  552. }
  553. public void SetMaidIdByButtonName(string buttonName)
  554. {
  555. this.m_maidId = this.GetMaidIdByButtonName(buttonName);
  556. this.selectedMaid = this.GetMaidByButtonName(buttonName);
  557. }
  558. public void DeleteMaidStatus(ScheduleScene scheduleApi, string buttonName)
  559. {
  560. this.m_scheduleApi = scheduleApi;
  561. string maidName = this.GetMaidName(buttonName);
  562. this.m_deleteSlotNo = ScheduleCtrl.GetSlotByButtonName(buttonName).slotNo;
  563. if (Product.supportMultiLanguage)
  564. {
  565. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/スケジュールから削除して宜しいですか。", null, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.DeleteMaidAndReDraw), null);
  566. }
  567. else
  568. {
  569. GameMain.Instance.SysDlg.Show(string.Format("名前:{0}\nスケジュールから削除して\n宜しいですか。", maidName), SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.DeleteMaidAndReDraw), null);
  570. }
  571. }
  572. private void DeleteMaidAndReDraw()
  573. {
  574. string text = null;
  575. if (this.m_dicMaidStatusAndTask.ContainsKey(this.m_deleteSlotNo))
  576. {
  577. text = this.m_scheduleMgr.CurrentActiveButton;
  578. int slotId = ScheduleCtrl.ToIntSlotNo(this.m_deleteSlotNo);
  579. this.m_scheduleApi.SetSlot_Safe(slotId, null, true, true);
  580. if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.MaidStatusList].activeSelf)
  581. {
  582. this.m_charSelMgr.MoveGridArea(this.GetMaidBySlotNo(this.m_deleteSlotNo));
  583. }
  584. this.m_scheduleMgr.UpdateMaidStatus();
  585. }
  586. GameMain.Instance.SysDlg.Close();
  587. if (!string.IsNullOrEmpty(text))
  588. {
  589. if (text.Contains(this.m_deleteSlotNo))
  590. {
  591. this.SetViewerActive(ScheduleCtrl.ExclusiveViewer.None);
  592. }
  593. else
  594. {
  595. this.SetSelectedRowActive(text);
  596. this.m_scheduleMgr.CurrentActiveButton = text;
  597. this.SetViewerActive(this.m_currentActiveViewer);
  598. if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.Task].activeSelf)
  599. {
  600. this.m_scheduleMgr.UpdateTask("-1");
  601. }
  602. }
  603. }
  604. this.m_deleteSlotNo = null;
  605. this.m_scheduleApi = null;
  606. }
  607. public bool CanDeleteData(string buttonName)
  608. {
  609. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  610. return !maidStatusAndTaskUnitByButtonName.isEmpty && (!maidStatusAndTaskUnitByButtonName.maidStatus.isReader || this.GetSettingMaidCount() != 1);
  611. }
  612. private int GetSettingMaidCount()
  613. {
  614. int num = 0;
  615. foreach (ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit in this.m_dicMaidStatusAndTask.Values)
  616. {
  617. if (!maidStatusAndTaskUnit.isEmpty)
  618. {
  619. num++;
  620. }
  621. }
  622. return num;
  623. }
  624. private string GetMaidName(string buttonName)
  625. {
  626. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
  627. if (!maidStatusAndTaskUnitByButtonName.isEmpty)
  628. {
  629. return maidStatusAndTaskUnitByButtonName.maidStatus.lastName + " " + maidStatusAndTaskUnitByButtonName.maidStatus.firstName;
  630. }
  631. return string.Empty;
  632. }
  633. public Maid GetMaidByMaidId(string maidId)
  634. {
  635. Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTask = this.GetDicMaidStatusAndTask();
  636. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in dicMaidStatusAndTask)
  637. {
  638. ScheduleCtrl.MaidStatusAndTaskUnit value = keyValuePair.Value;
  639. if (!value.isEmpty && value.maidStatus.id == maidId)
  640. {
  641. return value.maidStatus.maid;
  642. }
  643. }
  644. return null;
  645. }
  646. public Maid GetMaidBySlotNo(string slotNo)
  647. {
  648. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  649. if (this.m_dicMaidStatusAndTask.TryGetValue(slotNo, out maidStatusAndTaskUnit))
  650. {
  651. return maidStatusAndTaskUnit.maidStatus.maid;
  652. }
  653. return null;
  654. }
  655. public Maid GetMaidByActiveSlot()
  656. {
  657. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  658. if (this.m_dicMaidStatusAndTask.TryGetValue(this.m_activeSlotNo, out maidStatusAndTaskUnit))
  659. {
  660. return maidStatusAndTaskUnit.maidStatus.maid;
  661. }
  662. return null;
  663. }
  664. public static int ToIntSlotNo(string slotNo)
  665. {
  666. if (!string.IsNullOrEmpty(slotNo))
  667. {
  668. return int.Parse(slotNo.Replace("slot_", string.Empty));
  669. }
  670. Debug.LogError(string.Format("不適切なスロットNoが指定されました。指定されたスロットNo={0}", slotNo));
  671. return 9999;
  672. }
  673. private ScheduleMgr m_scheduleMgr;
  674. private CharacterSelectManager m_charSelMgr;
  675. private ScheduleScene m_scheduleApi;
  676. private ScheduleCtrl.ExclusiveViewer m_currentActiveViewer;
  677. private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> m_dicMaidStatusAndTask;
  678. private GameObject m_goPanel;
  679. private Color activeColor;
  680. private Color inActiveColor;
  681. private Color disableColor;
  682. private string m_activeSlotNo;
  683. private string m_maidId;
  684. private bool m_bInit;
  685. [SerializeField]
  686. private Maid selectedMaid;
  687. private const string UNIT_PARENT_PATH = "SelectedMaidViewer/Contents/SelectedMaidUnitParent";
  688. private const string UNIT_PREFAB_PATH = "SceneDaily/Schedule/Prefab/MaidStatusUnit";
  689. private const string SYSTEM_UI_ROOT_PATH = "__GameMain__/SystemUI Root";
  690. private const string MAID_STATUS_BUTTON_NAME_SUFFIX = "_maidStatus";
  691. private const string DAYTIME_TASK_BUTTON_NAME_SUFFIX = "_daytime";
  692. private const string NIGHT_TASK_BUTTON_NAME_SUFFIX = "_night";
  693. private const string DIALOG_MESSAGE_TO_DELETE = "名前:{0}\nスケジュールから削除して\n宜しいですか。";
  694. private const string DIALOG_MESSAGE_TO_DELETE_TERM = "Dialog/スケジュールから削除して宜しいですか。";
  695. private const string DIALOG_MESSAGE_NOT_SELECTED_MAID = "スケジュールにキャラクターが\n設定されておりません。";
  696. private string m_deleteSlotNo;
  697. private const int ERROR_CODE_FOR_SLOTNO = 9999;
  698. public enum SlotColumn
  699. {
  700. MaidStatus,
  701. DaytimeTask,
  702. NightTask
  703. }
  704. public enum ExclusiveViewer
  705. {
  706. None,
  707. MaidStatusList,
  708. Task,
  709. Room
  710. }
  711. public class MaidStatusAndTaskUnit
  712. {
  713. public int slotNo;
  714. public bool isEmpty;
  715. public MaidStatusListCtrl.MaidStatusButton maidStatus;
  716. public string daytimeTaskId;
  717. public string nightTaskId;
  718. public bool daytimeCommu;
  719. public bool nightCommu;
  720. public string daytimeTaskName;
  721. public string nightTaskName;
  722. public Texture2D taskIcon;
  723. public Texture2D nightTaskIcon;
  724. public UITexture uiDaytimeTaskIcon;
  725. public UITexture uiNightTaskIcon;
  726. public UIButton uiBtnMaidStatus;
  727. public UIButton uiBtnDaytimeTask;
  728. public UIButton uiBtnNightTask;
  729. public UIToggle uiTglCommuDaytime;
  730. public UIToggle uiTglCommuNight;
  731. public BoxCollider colliderMaidStatus;
  732. public GameObject goSelectCursorMaidStatus;
  733. public GameObject goSelectCursorDaytimeTask;
  734. public GameObject goSelectCursorNightTask;
  735. }
  736. public class Slot
  737. {
  738. public Slot()
  739. {
  740. this.slotNo = string.Empty;
  741. }
  742. public string slotNo;
  743. public ScheduleCtrl.SlotColumn slotColumn;
  744. }
  745. public class VariableItem
  746. {
  747. public VariableItem(GameObject item, UILabel label)
  748. {
  749. this.item = item;
  750. this.value = label;
  751. }
  752. public GameObject item;
  753. public UILabel value;
  754. }
  755. }