FacilityInfoUI.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class FacilityInfoUI : MonoBehaviour
  5. {
  6. public FacilityInfoUI.ViewType viewType
  7. {
  8. get
  9. {
  10. return this.m_ViewType;
  11. }
  12. set
  13. {
  14. this.m_ViewType = value;
  15. this.UpdateViewTypeUI();
  16. }
  17. }
  18. public InputField textFacilityName
  19. {
  20. get
  21. {
  22. return this.m_TextFacilityName;
  23. }
  24. set
  25. {
  26. this.m_TextFacilityName = value;
  27. }
  28. }
  29. public Image imageFacilityThumbnail
  30. {
  31. get
  32. {
  33. return this.m_ImageFacilityThumbnail;
  34. }
  35. }
  36. public Facility facility
  37. {
  38. get
  39. {
  40. return this.m_Facility;
  41. }
  42. }
  43. public void SetFacilityInfo(Facility facility, bool nullCheck = true)
  44. {
  45. ScheduleMgr.ScheduleTime scheduleTime = (!GameMain.Instance.CharacterMgr.status.isDaytime) ? ScheduleMgr.ScheduleTime.Night : ScheduleMgr.ScheduleTime.DayTime;
  46. ScheduleMgr.ScheduleTime nowScheduleTime = this.m_NowScheduleTime;
  47. if (nowScheduleTime != ScheduleMgr.ScheduleTime.DayTime)
  48. {
  49. if (nowScheduleTime == ScheduleMgr.ScheduleTime.Night)
  50. {
  51. scheduleTime = this.m_NowScheduleTime;
  52. }
  53. }
  54. else
  55. {
  56. scheduleTime = this.m_NowScheduleTime;
  57. }
  58. this.SetFacilityInfo(facility, scheduleTime, nullCheck);
  59. }
  60. public void SetFacilityInfo(Facility facility, ScheduleMgr.ScheduleTime scheduleTime, bool nullCheck = true)
  61. {
  62. this.m_Facility = facility;
  63. string text = string.Empty;
  64. string text2 = string.Empty;
  65. string text3 = string.Empty;
  66. string text4 = string.Empty;
  67. string text5 = string.Empty;
  68. string text6 = string.Empty;
  69. string text7 = string.Empty;
  70. Sprite sprite = null;
  71. int itemCount;
  72. int itemCount2;
  73. if (this.m_Facility)
  74. {
  75. text = this.m_Facility.facilityName;
  76. text2 = this.m_Facility.NowMaidCount(scheduleTime).ToString();
  77. text3 = this.m_Facility.minMaidCount.ToString();
  78. text4 = this.m_Facility.maxMaidCount.ToString();
  79. text5 = this.m_Facility.defaultData.cost.ToString();
  80. text6 = this.m_Facility.facilityLevel.ToString();
  81. itemCount = this.m_Facility.defaultData.rank;
  82. itemCount2 = this.m_Facility.GetStaffRank(scheduleTime);
  83. if (this.m_Facility.defaultData.isBusiness)
  84. {
  85. text7 = ((!this.m_Facility.IsOperation(scheduleTime)) ? "未稼働" : "営業可能");
  86. }
  87. else
  88. {
  89. text7 = ((!this.m_Facility.IsOperation(scheduleTime)) ? "未稼働" : "稼働中");
  90. }
  91. sprite = FacilityDataTable.GetFacilityThumbnail(this.m_Facility.param.typeID, true);
  92. }
  93. else
  94. {
  95. text = "空き部屋";
  96. text2 = "---";
  97. text3 = "---";
  98. text4 = "---";
  99. text5 = "---";
  100. text6 = "--";
  101. text7 = "---";
  102. itemCount = 0;
  103. itemCount2 = 0;
  104. }
  105. if (this.m_TextFacilityName)
  106. {
  107. this.m_TextFacilityName.text = text;
  108. }
  109. if (this.m_ImageFacilityThumbnail)
  110. {
  111. this.m_ImageFacilityThumbnail.sprite = sprite;
  112. }
  113. if (this.m_TextNumberOfPeople)
  114. {
  115. this.m_TextNumberOfPeople.text = text2;
  116. }
  117. if (this.m_TextNumberOfMinPeople)
  118. {
  119. this.m_TextNumberOfMinPeople.text = text3;
  120. }
  121. if (this.m_TextNumberOfMaxPeople)
  122. {
  123. this.m_TextNumberOfMaxPeople.text = text4;
  124. }
  125. if (this.m_TextNumberOfCost)
  126. {
  127. this.m_TextNumberOfCost.text = text5;
  128. }
  129. if (this.m_TextLevelOfFacility)
  130. {
  131. this.m_TextLevelOfFacility.text = text6;
  132. }
  133. if (this.m_TextStatusOfFacility)
  134. {
  135. this.m_TextStatusOfFacility.text = text7;
  136. }
  137. if (this.m_uGUIListRankStar)
  138. {
  139. this.m_uGUIListRankStar.Show<Transform>(itemCount, null);
  140. }
  141. if (this.m_uGUIListStaffStar)
  142. {
  143. this.m_uGUIListStaffStar.Show<Transform>(itemCount2, null);
  144. }
  145. }
  146. public void UpdateFacilityInfo(bool nullCheck = true)
  147. {
  148. this.SetFacilityInfo(this.m_Facility, nullCheck);
  149. }
  150. public void UpdateFacilityInfo(ScheduleMgr.ScheduleTime scheduleTime, bool nullCheck = true)
  151. {
  152. this.m_NowScheduleTime = scheduleTime;
  153. this.SetFacilityInfo(this.m_Facility, scheduleTime, nullCheck);
  154. }
  155. public bool IsInteractable
  156. {
  157. get
  158. {
  159. return this.m_IsInteractable;
  160. }
  161. set
  162. {
  163. this.m_IsInteractable = value;
  164. Selectable componentInChildren = base.GetComponentInChildren<Selectable>();
  165. if (componentInChildren != null)
  166. {
  167. componentInChildren.interactable = this.m_IsInteractable;
  168. }
  169. Graphic componentInChildren2 = base.GetComponentInChildren<Graphic>();
  170. if (componentInChildren2 != null)
  171. {
  172. componentInChildren2.raycastTarget = this.m_IsInteractable;
  173. }
  174. GameObject childObject = UTY.GetChildObject(base.gameObject, "Image Inactive mask", true);
  175. if (childObject)
  176. {
  177. childObject.SetActive(!this.m_IsInteractable);
  178. }
  179. }
  180. }
  181. public void SetNameChangeEnable(bool enable)
  182. {
  183. this.m_TextFacilityName.interactable = enable;
  184. }
  185. public void SetMaidIcon(Maid maid, ScheduleMgr.ScheduleTime scheduleTime)
  186. {
  187. if (this.m_MaidIconObject == null)
  188. {
  189. return;
  190. }
  191. if (this.m_Facility == null)
  192. {
  193. return;
  194. }
  195. if (maid == null)
  196. {
  197. this.SetMaidIconShowFlag(false);
  198. return;
  199. }
  200. RawImage componentInChildren = this.m_MaidIconObject.GetComponentInChildren<RawImage>();
  201. if (componentInChildren == null)
  202. {
  203. Debug.LogWarning("メイドの顔アイコン表示オブジェクトが見つかりませんでした。");
  204. return;
  205. }
  206. bool flag = this.IsAllocationMaid(maid, scheduleTime);
  207. Texture texture = null;
  208. if (maid != null && flag)
  209. {
  210. texture = maid.GetThumIcon();
  211. }
  212. componentInChildren.texture = texture;
  213. this.SetMaidIconShowFlag(texture != null);
  214. }
  215. public bool IsAllocationMaid(Maid maid, ScheduleMgr.ScheduleTime scheduleTime)
  216. {
  217. return !(this.m_Facility == null) && !(maid == null) && this.m_Facility.IsAllocationMaid(maid, scheduleTime);
  218. }
  219. public void SetMaidIconShowFlag(bool isShow)
  220. {
  221. if (this.m_MaidIconObject == null)
  222. {
  223. return;
  224. }
  225. if (isShow)
  226. {
  227. if (!this.m_MaidIconObject.activeSelf)
  228. {
  229. this.m_MaidIconObject.SetActive(true);
  230. }
  231. }
  232. else if (this.m_MaidIconObject.activeSelf)
  233. {
  234. this.m_MaidIconObject.SetActive(false);
  235. }
  236. }
  237. private void UpdateViewTypeUI()
  238. {
  239. if (this.m_ViewType == FacilityInfoUI.ViewType.Free)
  240. {
  241. return;
  242. }
  243. bool active = false;
  244. bool active2 = false;
  245. bool active3 = false;
  246. bool active4 = false;
  247. bool active5 = false;
  248. bool active6 = false;
  249. bool active7 = false;
  250. bool active8 = false;
  251. switch (this.m_ViewType)
  252. {
  253. case FacilityInfoUI.ViewType.DefaultMode:
  254. case FacilityInfoUI.ViewType.MiniDefaultMode:
  255. active2 = (active = (active3 = (active4 = (active5 = true))));
  256. break;
  257. case FacilityInfoUI.ViewType.MaidAllocateMode:
  258. active2 = (active = (active3 = (active6 = (active4 = true))));
  259. break;
  260. case FacilityInfoUI.ViewType.ConstructMode:
  261. active6 = (active = (active7 = (active4 = (active8 = true))));
  262. break;
  263. }
  264. if (this.m_uGUIListRankStar)
  265. {
  266. this.m_uGUIListRankStar.gameObject.SetActive(active);
  267. }
  268. if (this.m_uGUIListStaffStar)
  269. {
  270. this.m_uGUIListStaffStar.gameObject.SetActive(active2);
  271. }
  272. if (this.m_TextNumberOfPeople)
  273. {
  274. this.m_TextNumberOfPeople.gameObject.SetActive(active3);
  275. }
  276. if (this.m_TextLevelOfFacility)
  277. {
  278. this.m_TextLevelOfFacility.gameObject.SetActive(active4);
  279. }
  280. if (this.m_TextStatusOfFacility)
  281. {
  282. this.m_TextStatusOfFacility.gameObject.SetActive(active5);
  283. }
  284. if (this.m_TextNumberOfMinPeople)
  285. {
  286. this.m_TextNumberOfMinPeople.gameObject.SetActive(active6);
  287. }
  288. if (this.m_TextNumberOfMaxPeople)
  289. {
  290. this.m_TextNumberOfMaxPeople.gameObject.SetActive(active7);
  291. }
  292. if (this.m_TextNumberOfCost)
  293. {
  294. this.m_TextNumberOfCost.gameObject.SetActive(active8);
  295. }
  296. Image image = null;
  297. GameObject childObject = UTY.GetChildObject(base.gameObject, "Parent Info", true);
  298. if (childObject != null)
  299. {
  300. image = childObject.GetComponent<Image>();
  301. }
  302. if (image == null)
  303. {
  304. image = base.gameObject.GetComponent<Image>();
  305. }
  306. if (image != null)
  307. {
  308. image.sprite = this.GetViewTypePlate(this.m_ViewType);
  309. }
  310. }
  311. private Sprite GetViewTypePlate(FacilityInfoUI.ViewType viewType)
  312. {
  313. Sprite result = null;
  314. switch (viewType)
  315. {
  316. case FacilityInfoUI.ViewType.DefaultMode:
  317. result = Resources.Load<Sprite>("SceneFacilityPowerUp/Sprites/myroom_info_plate");
  318. break;
  319. case FacilityInfoUI.ViewType.MaidAllocateMode:
  320. result = Resources.Load<Sprite>("SceneFacilityManagement/Sprites/shisetsu_infoplate_s2");
  321. break;
  322. case FacilityInfoUI.ViewType.ConstructMode:
  323. result = Resources.Load<Sprite>("SceneFacilityPowerUp/Sprites/myroom_info_plate2");
  324. break;
  325. case FacilityInfoUI.ViewType.MiniDefaultMode:
  326. result = Resources.Load<Sprite>("SceneFacilityManagement/Sprites/shisetsu_infoplate_s");
  327. break;
  328. }
  329. return result;
  330. }
  331. private FacilityInfoUI.ViewType m_ViewType = FacilityInfoUI.ViewType.Free;
  332. [SerializeField]
  333. protected InputField m_TextFacilityName;
  334. [SerializeField]
  335. protected Image m_ImageFacilityThumbnail;
  336. [SerializeField]
  337. protected Text m_TextNumberOfPeople;
  338. [SerializeField]
  339. protected Text m_TextLevelOfFacility;
  340. [SerializeField]
  341. protected Text m_TextStatusOfFacility;
  342. [SerializeField]
  343. protected uGUIListViewer m_uGUIListRankStar;
  344. [SerializeField]
  345. protected uGUIListViewer m_uGUIListStaffStar;
  346. [SerializeField]
  347. protected Text m_TextNumberOfMinPeople;
  348. [SerializeField]
  349. protected Text m_TextNumberOfMaxPeople;
  350. [SerializeField]
  351. protected Text m_TextNumberOfCost;
  352. [SerializeField]
  353. protected GameObject m_MaidIconObject;
  354. private ScheduleMgr.ScheduleTime m_NowScheduleTime = (ScheduleMgr.ScheduleTime)(-1);
  355. protected Facility m_Facility;
  356. private bool m_IsInteractable = true;
  357. public enum ViewType
  358. {
  359. DefaultMode,
  360. MaidAllocateMode,
  361. ConstructMode,
  362. MiniDefaultMode,
  363. Free
  364. }
  365. }