ScheduleFacillityPanelCtrl.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System;
  2. using System.Collections.Generic;
  3. using Schedule;
  4. using UnityEngine;
  5. public class ScheduleFacillityPanelCtrl : MonoBehaviour
  6. {
  7. public ScheduleTaskViewer TaskViewr
  8. {
  9. set
  10. {
  11. this.viewer = value;
  12. }
  13. }
  14. public ScheduleCSVData.Work WorkData
  15. {
  16. set
  17. {
  18. this.current_workData = value;
  19. }
  20. }
  21. public Maid SelectMaid
  22. {
  23. set
  24. {
  25. this.current_maid = value;
  26. }
  27. }
  28. public ScheduleMgr.ScheduleTime ScheduleTime
  29. {
  30. set
  31. {
  32. this.current_time = value;
  33. }
  34. }
  35. public WorkTaskUnit TaskUnit
  36. {
  37. set
  38. {
  39. this.taskUnit = value;
  40. }
  41. }
  42. private void Awake()
  43. {
  44. this.faciltyManagement = base.gameObject.GetComponent<SceneFacilityManagement>();
  45. this.faciltyManagement.enableSetUpCameraAndBG = false;
  46. this.parentFacility = UTY.GetChildObject(base.gameObject, "Window Facility Details/Parent Facility Button", false);
  47. }
  48. private void Update()
  49. {
  50. if (!this.init)
  51. {
  52. this.Init();
  53. }
  54. }
  55. public void Active(bool active)
  56. {
  57. base.gameObject.SetActive(active);
  58. if (active)
  59. {
  60. GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
  61. this.UpdateFacilityInfo();
  62. this.UpdateFacilityInfoInteractable();
  63. this.faciltyManagement.ToggleEvent_VisibleFacilityInfo(true);
  64. }
  65. }
  66. private void Init()
  67. {
  68. this.init = true;
  69. uGUIListViewer component = GameObject.Find("Window Facility Details").GetComponent<uGUIListViewer>();
  70. GameObject[] itemArray = component.ItemArray;
  71. if (itemArray.Length > 0)
  72. {
  73. this.infoUiList = new List<FacilityInfoUI>();
  74. for (int i = 0; i < itemArray.Length; i++)
  75. {
  76. FacilityInfoUI component2 = itemArray[i].GetComponent<FacilityInfoUI>();
  77. GameObject childObject = UTY.GetChildObject(component2.gameObject, "InputField Facility Name/Button Change Name", false);
  78. childObject.SetActive(false);
  79. this.infoUiList.Add(component2);
  80. }
  81. }
  82. this.faciltyManagement.ToggleEvent_VisibleFacilityInfo(true);
  83. this.UpdateFacilityInfo();
  84. this.UpdateFacilityInfoInteractable();
  85. }
  86. public void AddMaid(FacilityInfoUI infoUI)
  87. {
  88. if (infoUI == null)
  89. {
  90. return;
  91. }
  92. if (infoUI.facility == null)
  93. {
  94. return;
  95. }
  96. if (infoUI.facility.NowMaidCount(this.current_time) >= infoUI.facility.maxMaidCount)
  97. {
  98. GameMain.Instance.SysDlg.Show("この施設にはこれ以上メイドを配置出来ません。", SystemDialog.TYPE.OK, null, null);
  99. return;
  100. }
  101. bool flag = infoUI.facility.AllocationMaid(this.current_maid, this.current_time);
  102. if (flag)
  103. {
  104. this.viewer.OnClickTaskUnit(this.taskUnit);
  105. this.UpdateFacilityInfo();
  106. }
  107. }
  108. private void UpdateFacilityInfoInteractable()
  109. {
  110. if (this.infoUiList == null)
  111. {
  112. return;
  113. }
  114. foreach (FacilityInfoUI facilityInfoUI in this.infoUiList)
  115. {
  116. bool isInteractable = false;
  117. if (facilityInfoUI.facility != null && this.current_workData.facility != null)
  118. {
  119. isInteractable = (facilityInfoUI.facility.defaultData.ID == this.current_workData.facility.ID);
  120. }
  121. foreach (KeyValuePair<int, Facility> keyValuePair in GameMain.Instance.FacilityMgr.GetNextDayFacilityArray())
  122. {
  123. Facility value = keyValuePair.Value;
  124. if (value != null && facilityInfoUI.facility != null && value == facilityInfoUI.facility)
  125. {
  126. isInteractable = false;
  127. break;
  128. }
  129. }
  130. facilityInfoUI.IsInteractable = isInteractable;
  131. }
  132. }
  133. private void UpdateFacilityInfo()
  134. {
  135. if (this.infoUiList == null)
  136. {
  137. return;
  138. }
  139. foreach (FacilityInfoUI facilityInfoUI in this.infoUiList)
  140. {
  141. bool maidIconShowFlag = false;
  142. if (facilityInfoUI.facility != null)
  143. {
  144. Maid[] allocationMaidArray = facilityInfoUI.facility.GetAllocationMaidArray(this.current_time);
  145. foreach (Maid y in allocationMaidArray)
  146. {
  147. if (this.current_maid == y)
  148. {
  149. facilityInfoUI.SetMaidIcon(this.current_maid, this.current_time);
  150. maidIconShowFlag = true;
  151. break;
  152. }
  153. }
  154. }
  155. facilityInfoUI.SetMaidIconShowFlag(maidIconShowFlag);
  156. facilityInfoUI.UpdateFacilityInfo(this.current_time, true);
  157. }
  158. this.UpdateFacilityInfoPanel();
  159. }
  160. private void UpdateFacilityInfoPanel()
  161. {
  162. Facility maidAssignedFacility = GameMain.Instance.FacilityMgr.GetMaidAssignedFacility(this.current_maid, this.current_time);
  163. if (maidAssignedFacility != null)
  164. {
  165. this.m_UIFacilityInfoConstruction.SetFacilityInfo(maidAssignedFacility, true);
  166. this.m_UIFacilityInfoConstruction.UpdateFacilityInfo(this.current_time, true);
  167. this.m_UIFacilityInfoConstruction.gameObject.SetActive(true);
  168. }
  169. else
  170. {
  171. this.m_UIFacilityInfoConstruction.gameObject.SetActive(false);
  172. }
  173. }
  174. private SceneFacilityManagement faciltyManagement;
  175. private GameObject parentFacility;
  176. private List<FacilityInfoUI> infoUiList;
  177. private WorkTaskUnit taskUnit;
  178. private ScheduleTaskViewer viewer;
  179. private ScheduleMgr.ScheduleTime current_time;
  180. private Maid current_maid;
  181. private ScheduleCSVData.Work current_workData;
  182. [SerializeField]
  183. private FacilityInfoUI m_UIFacilityInfoConstruction;
  184. private bool init;
  185. }