OnHoverTaskIcon.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using System;
  2. using I2.Loc;
  3. using Schedule;
  4. using UnityEngine;
  5. public class OnHoverTaskIcon : MonoBehaviour
  6. {
  7. public void Init(string taskName, Maid maid, ScheduleMgr.ScheduleTime time)
  8. {
  9. this.taskName = taskName;
  10. this.maid = maid;
  11. if (string.IsNullOrEmpty(taskName))
  12. {
  13. return;
  14. }
  15. this.m_goNamePlate = UTY.GetChildObject(base.gameObject, "NamePlate", false);
  16. this.spritePlate = this.m_goNamePlate.GetComponent<UISprite>();
  17. this.labelName = UTY.GetChildObject(this.m_goNamePlate, "Name", false).GetComponent<UILabel>();
  18. this.labelName.width = 0;
  19. this.SetText(taskName, -1);
  20. this.m_goNamePlate.SetActive(false);
  21. this.WariningFacilty = UTY.GetChildObject(base.gameObject, "WarningFacilty", false).GetComponent<UISprite>();
  22. this.WariningFacilty.gameObject.SetActive(false);
  23. this.time = time;
  24. int key = 0;
  25. if (maid != null)
  26. {
  27. if (time == ScheduleMgr.ScheduleTime.DayTime)
  28. {
  29. key = maid.status.noonWorkId;
  30. }
  31. else if (time == ScheduleMgr.ScheduleTime.Night)
  32. {
  33. key = maid.status.nightWorkId;
  34. }
  35. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[key];
  36. if (scheduleBase.type == ScheduleTaskCtrl.TaskType.Work)
  37. {
  38. this.workData = (ScheduleCSVData.Work)scheduleBase;
  39. this.facility = GameMain.Instance.FacilityMgr.GetMaidAssignedFacility(maid, time);
  40. }
  41. }
  42. }
  43. private void Update()
  44. {
  45. if (this.workData != null && this.workData.id != ScheduleCSVData.faclilityPowerUpWorkId)
  46. {
  47. this.WariningFacilty.gameObject.SetActive(!this.facility.IsOperation(this.time));
  48. }
  49. }
  50. public void SetText(string message, int needNum = -1)
  51. {
  52. UISprite component = this.m_goNamePlate.GetComponent<UISprite>();
  53. if (Product.supportMultiLanguage)
  54. {
  55. string text = message;
  56. if (message.IndexOf('\n') != -1)
  57. {
  58. text = message.Split(new char[]
  59. {
  60. '\n'
  61. })[0];
  62. }
  63. string text2 = string.Empty;
  64. text2 = LocalizationManager.GetTranslation("SceneDaily/スケジュール/項目/" + text, true, 0, true, false, null, null);
  65. if (string.IsNullOrEmpty(text2))
  66. {
  67. text2 = LocalizationManager.GetTranslation("SceneFacilityManagement/施設名/" + text, true, 0, true, false, null, null);
  68. }
  69. if (string.IsNullOrEmpty(text2))
  70. {
  71. text2 = text;
  72. }
  73. string text3 = string.Empty;
  74. if (needNum != -1)
  75. {
  76. text3 = LocalizationManager.GetTranslation("SceneDaily/あと{0}人必要です", true, 0, true, false, null, null);
  77. }
  78. string text4 = text2;
  79. if (!string.IsNullOrEmpty(text3))
  80. {
  81. text4 = text4 + "\n" + string.Format(text3, needNum);
  82. }
  83. this.labelName.text = text4;
  84. this.labelName.MakePixelPerfect();
  85. }
  86. else
  87. {
  88. this.labelName.text = message;
  89. this.labelName.MakePixelPerfect();
  90. }
  91. string[] array = message.Split(new char[]
  92. {
  93. '\n'
  94. });
  95. int num = 0;
  96. foreach (string text5 in array)
  97. {
  98. if (num < text5.Length)
  99. {
  100. num = text5.Length;
  101. }
  102. }
  103. component.width = this.labelName.width + 15;
  104. component.height = array.Length * 33;
  105. }
  106. private void OnHover(bool isOver)
  107. {
  108. if (isOver)
  109. {
  110. if (this.m_goNamePlate != null)
  111. {
  112. if (Product.supportMultiLanguage)
  113. {
  114. this.SetText(this.taskName, -1);
  115. }
  116. this.m_goNamePlate.SetActive(true);
  117. }
  118. if (this.workData != null && this.workData.id != ScheduleCSVData.faclilityPowerUpWorkId)
  119. {
  120. this.CheckFacilityState();
  121. }
  122. }
  123. else
  124. {
  125. if (this.m_goNamePlate != null)
  126. {
  127. this.m_goNamePlate.SetActive(false);
  128. }
  129. if (this.WariningFacilty != null)
  130. {
  131. this.WariningFacilty.gameObject.SetActive(false);
  132. }
  133. }
  134. }
  135. private void CheckFacilityState()
  136. {
  137. if (!this.facility.IsOperation(this.time))
  138. {
  139. int num;
  140. if (this.time == ScheduleMgr.ScheduleTime.DayTime)
  141. {
  142. num = this.facility.minMaidCount - this.facility.nowDayTimeMaidCount;
  143. }
  144. else
  145. {
  146. num = this.facility.minMaidCount - this.facility.nowNightMaidCount;
  147. }
  148. this.SetText(string.Concat(new object[]
  149. {
  150. this.taskName,
  151. "\nあと[FF0000]",
  152. num,
  153. "人[-]必要です"
  154. }), num);
  155. }
  156. else
  157. {
  158. this.SetText(this.taskName, -1);
  159. }
  160. }
  161. private GameObject m_goNamePlate;
  162. private UISprite spritePlate;
  163. private UILabel labelName;
  164. private const int SIDE_OFFSET = 15;
  165. private const int VERT_OFFSET = 33;
  166. private string taskName;
  167. private ScheduleCSVData.Work workData;
  168. public UISprite WariningFacilty;
  169. private ScheduleMgr.ScheduleTime time;
  170. private Facility facility;
  171. private Maid maid;
  172. }