FacilityInfoUI.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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[] componentsInChildren = this.m_TextFacilityName.GetComponentsInChildren<Localize>();
  111. if (componentsInChildren != null && componentsInChildren.Length > 0)
  112. {
  113. foreach (Localize localize in componentsInChildren)
  114. {
  115. if (localize != null && localize.mLocalizeTargetName == "I2.Loc.LocalizeTarget_UnityUI_Text")
  116. {
  117. if (text == "空き部屋")
  118. {
  119. this.m_TextFacilityName.enabled = false;
  120. localize.SetTerm("SceneFacilityManagement/" + text);
  121. }
  122. else if (this.m_Facility != null && this.m_Facility.defaultName == text)
  123. {
  124. localize.SetTerm(this.m_Facility.defaultData.termName);
  125. }
  126. }
  127. }
  128. }
  129. }
  130. if (this.m_ImageFacilityThumbnail)
  131. {
  132. this.m_ImageFacilityThumbnail.sprite = sprite;
  133. }
  134. if (this.m_TextNumberOfPeople)
  135. {
  136. this.m_TextNumberOfPeople.text = text2;
  137. }
  138. if (this.m_TextNumberOfMinPeople)
  139. {
  140. this.m_TextNumberOfMinPeople.text = text3;
  141. }
  142. if (this.m_TextNumberOfMaxPeople)
  143. {
  144. this.m_TextNumberOfMaxPeople.text = text4;
  145. }
  146. if (this.m_TextNumberOfCost)
  147. {
  148. this.m_TextNumberOfCost.text = text5;
  149. }
  150. if (this.m_TextLevelOfFacility)
  151. {
  152. this.m_TextLevelOfFacility.text = text6;
  153. }
  154. if (this.m_TextStatusOfFacility)
  155. {
  156. this.m_TextStatusOfFacility.text = text7;
  157. Localize component = this.m_TextStatusOfFacility.GetComponent<Localize>();
  158. if (component != null)
  159. {
  160. component.SetTerm("SceneFacilityManagement/" + text7);
  161. }
  162. }
  163. if (this.m_uGUIListRankStar)
  164. {
  165. this.m_uGUIListRankStar.Show<Transform>(itemCount, null);
  166. }
  167. if (this.m_uGUIListStaffStar)
  168. {
  169. this.m_uGUIListStaffStar.Show<Transform>(itemCount2, null);
  170. }
  171. }
  172. public void UpdateFacilityInfo(bool nullCheck = true)
  173. {
  174. this.SetFacilityInfo(this.m_Facility, nullCheck);
  175. }
  176. public void UpdateFacilityInfo(ScheduleMgr.ScheduleTime scheduleTime, bool nullCheck = true)
  177. {
  178. this.m_NowScheduleTime = scheduleTime;
  179. this.SetFacilityInfo(this.m_Facility, scheduleTime, nullCheck);
  180. }
  181. public bool IsInteractable
  182. {
  183. get
  184. {
  185. return this.m_IsInteractable;
  186. }
  187. set
  188. {
  189. this.m_IsInteractable = value;
  190. Selectable componentInChildren = base.GetComponentInChildren<Selectable>();
  191. if (componentInChildren != null)
  192. {
  193. componentInChildren.interactable = this.m_IsInteractable;
  194. }
  195. Graphic componentInChildren2 = base.GetComponentInChildren<Graphic>();
  196. if (componentInChildren2 != null)
  197. {
  198. componentInChildren2.raycastTarget = this.m_IsInteractable;
  199. }
  200. GameObject childObject = UTY.GetChildObject(base.gameObject, "Image Inactive mask", true);
  201. if (childObject)
  202. {
  203. childObject.SetActive(!this.m_IsInteractable);
  204. }
  205. }
  206. }
  207. public void SetNameChangeEnable(bool enable)
  208. {
  209. this.m_TextFacilityName.interactable = enable;
  210. }
  211. public void SetMaidIcon(Maid maid, ScheduleMgr.ScheduleTime scheduleTime)
  212. {
  213. if (this.m_MaidIconObject == null)
  214. {
  215. return;
  216. }
  217. if (this.m_Facility == null)
  218. {
  219. return;
  220. }
  221. if (maid == null)
  222. {
  223. this.SetMaidIconShowFlag(false);
  224. return;
  225. }
  226. RawImage componentInChildren = this.m_MaidIconObject.GetComponentInChildren<RawImage>();
  227. if (componentInChildren == null)
  228. {
  229. Debug.LogWarning("メイドの顔アイコン表示オブジェクトが見つかりませんでした。");
  230. return;
  231. }
  232. bool flag = this.IsAllocationMaid(maid, scheduleTime);
  233. Texture texture = null;
  234. if (maid != null && flag)
  235. {
  236. texture = maid.GetThumIcon();
  237. }
  238. componentInChildren.texture = texture;
  239. this.SetMaidIconShowFlag(texture != null);
  240. }
  241. public bool IsAllocationMaid(Maid maid, ScheduleMgr.ScheduleTime scheduleTime)
  242. {
  243. return !(this.m_Facility == null) && !(maid == null) && this.m_Facility.IsAllocationMaid(maid, scheduleTime);
  244. }
  245. public void SetMaidIconShowFlag(bool isShow)
  246. {
  247. if (this.m_MaidIconObject == null)
  248. {
  249. return;
  250. }
  251. if (isShow)
  252. {
  253. if (!this.m_MaidIconObject.activeSelf)
  254. {
  255. this.m_MaidIconObject.SetActive(true);
  256. }
  257. }
  258. else if (this.m_MaidIconObject.activeSelf)
  259. {
  260. this.m_MaidIconObject.SetActive(false);
  261. }
  262. }
  263. private void UpdateViewTypeUI()
  264. {
  265. if (this.m_ViewType == FacilityInfoUI.ViewType.Free)
  266. {
  267. return;
  268. }
  269. bool active = false;
  270. bool active2 = false;
  271. bool active3 = false;
  272. bool active4 = false;
  273. bool active5 = false;
  274. bool active6 = false;
  275. bool active7 = false;
  276. bool active8 = false;
  277. switch (this.m_ViewType)
  278. {
  279. case FacilityInfoUI.ViewType.DefaultMode:
  280. case FacilityInfoUI.ViewType.MiniDefaultMode:
  281. active2 = (active = (active3 = (active4 = (active5 = true))));
  282. break;
  283. case FacilityInfoUI.ViewType.MaidAllocateMode:
  284. active2 = (active = (active3 = (active6 = (active4 = true))));
  285. break;
  286. case FacilityInfoUI.ViewType.ConstructMode:
  287. active6 = (active = (active7 = (active4 = (active8 = true))));
  288. break;
  289. }
  290. if (this.m_uGUIListRankStar)
  291. {
  292. this.m_uGUIListRankStar.gameObject.SetActive(active);
  293. }
  294. if (this.m_uGUIListStaffStar)
  295. {
  296. this.m_uGUIListStaffStar.gameObject.SetActive(active2);
  297. }
  298. if (this.m_TextNumberOfPeople)
  299. {
  300. this.m_TextNumberOfPeople.gameObject.SetActive(active3);
  301. }
  302. if (this.m_TextLevelOfFacility)
  303. {
  304. this.m_TextLevelOfFacility.gameObject.SetActive(active4);
  305. }
  306. if (this.m_TextStatusOfFacility)
  307. {
  308. this.m_TextStatusOfFacility.gameObject.SetActive(active5);
  309. }
  310. if (this.m_TextNumberOfMinPeople)
  311. {
  312. this.m_TextNumberOfMinPeople.gameObject.SetActive(active6);
  313. }
  314. if (this.m_TextNumberOfMaxPeople)
  315. {
  316. this.m_TextNumberOfMaxPeople.gameObject.SetActive(active7);
  317. }
  318. if (this.m_TextNumberOfCost)
  319. {
  320. this.m_TextNumberOfCost.gameObject.SetActive(active8);
  321. }
  322. Image image = null;
  323. GameObject childObject = UTY.GetChildObject(base.gameObject, "Parent Info", true);
  324. if (childObject != null)
  325. {
  326. image = childObject.GetComponent<Image>();
  327. }
  328. if (image == null)
  329. {
  330. image = base.gameObject.GetComponent<Image>();
  331. }
  332. if (image != null)
  333. {
  334. if (!Product.supportMultiLanguage)
  335. {
  336. image.sprite = this.GetViewTypePlate(this.m_ViewType);
  337. }
  338. else
  339. {
  340. Utility.SetLocalizeTerm(image, this.GetViewTypePlateTerm(this.m_ViewType), false);
  341. }
  342. }
  343. }
  344. private Sprite GetViewTypePlate(FacilityInfoUI.ViewType viewType)
  345. {
  346. Sprite result = null;
  347. switch (viewType)
  348. {
  349. case FacilityInfoUI.ViewType.DefaultMode:
  350. result = Resources.Load<Sprite>("SceneFacilityPowerUp/Sprites/myroom_info_plate");
  351. break;
  352. case FacilityInfoUI.ViewType.MaidAllocateMode:
  353. result = Resources.Load<Sprite>("SceneFacilityManagement/Sprites/shisetsu_infoplate_s2");
  354. break;
  355. case FacilityInfoUI.ViewType.ConstructMode:
  356. result = Resources.Load<Sprite>("SceneFacilityPowerUp/Sprites/myroom_info_plate2");
  357. break;
  358. case FacilityInfoUI.ViewType.MiniDefaultMode:
  359. result = Resources.Load<Sprite>("SceneFacilityManagement/Sprites/shisetsu_infoplate_s");
  360. break;
  361. }
  362. return result;
  363. }
  364. private string GetViewTypePlateTerm(FacilityInfoUI.ViewType viewType)
  365. {
  366. string result = null;
  367. switch (viewType)
  368. {
  369. case FacilityInfoUI.ViewType.DefaultMode:
  370. result = "SceneFacilityManagement/スプライト/情報プレート";
  371. break;
  372. case FacilityInfoUI.ViewType.MaidAllocateMode:
  373. result = "SceneFacilityManagement/スプライト/情報プレートs2";
  374. break;
  375. case FacilityInfoUI.ViewType.ConstructMode:
  376. result = "SceneFacilityManagement/スプライト/情報プレート2";
  377. break;
  378. case FacilityInfoUI.ViewType.MiniDefaultMode:
  379. result = "SceneFacilityManagement/スプライト/情報プレートs";
  380. break;
  381. }
  382. return result;
  383. }
  384. private FacilityInfoUI.ViewType m_ViewType = FacilityInfoUI.ViewType.Free;
  385. [SerializeField]
  386. protected InputField m_TextFacilityName;
  387. [SerializeField]
  388. protected Image m_ImageFacilityThumbnail;
  389. [SerializeField]
  390. protected Text m_TextNumberOfPeople;
  391. [SerializeField]
  392. protected Text m_TextLevelOfFacility;
  393. [SerializeField]
  394. protected Text m_TextStatusOfFacility;
  395. [SerializeField]
  396. protected uGUIListViewer m_uGUIListRankStar;
  397. [SerializeField]
  398. protected uGUIListViewer m_uGUIListStaffStar;
  399. [SerializeField]
  400. protected Text m_TextNumberOfMinPeople;
  401. [SerializeField]
  402. protected Text m_TextNumberOfMaxPeople;
  403. [SerializeField]
  404. protected Text m_TextNumberOfCost;
  405. [SerializeField]
  406. protected GameObject m_MaidIconObject;
  407. private ScheduleMgr.ScheduleTime m_NowScheduleTime = (ScheduleMgr.ScheduleTime)(-1);
  408. protected Facility m_Facility;
  409. private bool m_IsInteractable = true;
  410. public enum ViewType
  411. {
  412. DefaultMode,
  413. MaidAllocateMode,
  414. ConstructMode,
  415. MiniDefaultMode,
  416. Free
  417. }
  418. }