FacilityInfoUI.cs 11 KB

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