FacilityInfoUI.cs 9.9 KB

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