OnHoverTaskIcon.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using Schedule;
  3. using UnityEngine;
  4. public class OnHoverTaskIcon : MonoBehaviour
  5. {
  6. public void Init(string taskName, Maid maid, ScheduleMgr.ScheduleTime time)
  7. {
  8. this.taskName = taskName;
  9. this.maid = maid;
  10. if (string.IsNullOrEmpty(taskName))
  11. {
  12. return;
  13. }
  14. this.m_goNamePlate = UTY.GetChildObject(base.gameObject, "NamePlate", false);
  15. this.spritePlate = this.m_goNamePlate.GetComponent<UISprite>();
  16. this.labelName = UTY.GetChildObject(this.m_goNamePlate, "Name", false).GetComponent<UILabel>();
  17. this.labelName.width = 0;
  18. this.SetText(taskName);
  19. this.m_goNamePlate.SetActive(false);
  20. this.WariningFacilty = UTY.GetChildObject(base.gameObject, "WarningFacilty", false).GetComponent<UISprite>();
  21. this.WariningFacilty.gameObject.SetActive(false);
  22. this.time = time;
  23. int key = 0;
  24. if (maid != null)
  25. {
  26. if (time == ScheduleMgr.ScheduleTime.DayTime)
  27. {
  28. key = maid.status.noonWorkId;
  29. }
  30. else if (time == ScheduleMgr.ScheduleTime.Night)
  31. {
  32. key = maid.status.nightWorkId;
  33. }
  34. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[key];
  35. if (scheduleBase.type == ScheduleTaskCtrl.TaskType.Work)
  36. {
  37. this.workData = (ScheduleCSVData.Work)scheduleBase;
  38. this.facility = GameMain.Instance.FacilityMgr.GetMaidAssignedFacility(maid, time);
  39. }
  40. }
  41. }
  42. private void Update()
  43. {
  44. if (this.workData != null && this.workData.id != ScheduleCSVData.faclilityPowerUpWorkId)
  45. {
  46. this.WariningFacilty.gameObject.SetActive(!this.facility.IsOperation(this.time));
  47. }
  48. }
  49. public void SetText(string message)
  50. {
  51. UISprite component = this.m_goNamePlate.GetComponent<UISprite>();
  52. this.labelName.text = message;
  53. this.labelName.MakePixelPerfect();
  54. string[] array = message.Split(new char[]
  55. {
  56. '\n'
  57. });
  58. int num = 0;
  59. foreach (string text in array)
  60. {
  61. if (num < text.Length)
  62. {
  63. num = text.Length;
  64. }
  65. }
  66. component.width = this.labelName.width + 15;
  67. component.height = array.Length * 33;
  68. }
  69. private void OnHover(bool isOver)
  70. {
  71. if (isOver)
  72. {
  73. if (this.m_goNamePlate != null)
  74. {
  75. this.m_goNamePlate.SetActive(true);
  76. }
  77. if (this.workData != null && this.workData.id != ScheduleCSVData.faclilityPowerUpWorkId)
  78. {
  79. this.CheckFacilityState();
  80. }
  81. }
  82. else
  83. {
  84. if (this.m_goNamePlate != null)
  85. {
  86. this.m_goNamePlate.SetActive(false);
  87. }
  88. if (this.WariningFacilty != null)
  89. {
  90. this.WariningFacilty.gameObject.SetActive(false);
  91. }
  92. }
  93. }
  94. private void CheckFacilityState()
  95. {
  96. if (!this.facility.IsOperation(this.time))
  97. {
  98. int num;
  99. if (this.time == ScheduleMgr.ScheduleTime.DayTime)
  100. {
  101. num = this.facility.minMaidCount - this.facility.nowDayTimeMaidCount;
  102. }
  103. else
  104. {
  105. num = this.facility.minMaidCount - this.facility.nowNightMaidCount;
  106. }
  107. this.SetText(string.Concat(new object[]
  108. {
  109. this.taskName,
  110. "\nあと[FF0000]",
  111. num,
  112. "人[-]必要です"
  113. }));
  114. }
  115. else
  116. {
  117. this.SetText(this.taskName);
  118. }
  119. }
  120. private GameObject m_goNamePlate;
  121. private UISprite spritePlate;
  122. private UILabel labelName;
  123. private const int SIDE_OFFSET = 15;
  124. private const int VERT_OFFSET = 33;
  125. private string taskName;
  126. private ScheduleCSVData.Work workData;
  127. public UISprite WariningFacilty;
  128. private ScheduleMgr.ScheduleTime time;
  129. private Facility facility;
  130. private Maid maid;
  131. }