OnHoverTaskIcon.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. this.m_goNamePlate.SetActive(true);
  74. if (this.workData != null && this.workData.id != ScheduleCSVData.faclilityPowerUpWorkId)
  75. {
  76. this.CheckFacilityState();
  77. }
  78. }
  79. else
  80. {
  81. this.m_goNamePlate.SetActive(false);
  82. this.WariningFacilty.gameObject.SetActive(false);
  83. }
  84. }
  85. private void CheckFacilityState()
  86. {
  87. if (!this.facility.IsOperation(this.time))
  88. {
  89. int num;
  90. if (this.time == ScheduleMgr.ScheduleTime.DayTime)
  91. {
  92. num = this.facility.minMaidCount - this.facility.nowDayTimeMaidCount;
  93. }
  94. else
  95. {
  96. num = this.facility.minMaidCount - this.facility.nowNightMaidCount;
  97. }
  98. this.SetText(string.Concat(new object[]
  99. {
  100. this.taskName,
  101. "\nあと[FF0000]",
  102. num,
  103. "人[-]必要です"
  104. }));
  105. }
  106. else
  107. {
  108. this.SetText(this.taskName);
  109. }
  110. }
  111. private GameObject m_goNamePlate;
  112. private UISprite spritePlate;
  113. private UILabel labelName;
  114. private const int SIDE_OFFSET = 15;
  115. private const int VERT_OFFSET = 33;
  116. private string taskName;
  117. private ScheduleCSVData.Work workData;
  118. public UISprite WariningFacilty;
  119. private ScheduleMgr.ScheduleTime time;
  120. private Facility facility;
  121. private Maid maid;
  122. }