DescScheduleBase.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Schedule;
  5. using UnityEngine;
  6. public class DescScheduleBase : MonoBehaviour
  7. {
  8. public virtual void Init(ScheduleTaskCtrl taskCtrl)
  9. {
  10. this.taskCtrl = taskCtrl;
  11. this.m_goMaidParameter = UTY.GetChildObject(base.gameObject, "MaidParameter", false);
  12. this.m_goMaidParameterParent = UTY.GetChildObject(base.gameObject, "MaidParameter/ParameterParent", false);
  13. this.m_listMaidItem = new List<ScheduleCtrl.VariableItem>();
  14. this.m_spBGOfParameterViewer = UTY.GetChildObject(base.gameObject, "MaidParameter/BG", false).GetComponent<UISprite>();
  15. this.m_goTitleOfMaidParameter = UTY.GetChildObject(base.gameObject, "MaidParameter/Title", false);
  16. this.m_heightOfMaidParameterTitle = this.m_goTitleOfMaidParameter.GetComponent<UISprite>().height;
  17. }
  18. public void UpdateViewCommon(ScheduleCSVData.ScheduleBase work_data)
  19. {
  20. if (work_data == null || !int.TryParse(work_data.id.ToString(), out this.intTaskInd))
  21. {
  22. this.Active(false);
  23. return;
  24. }
  25. this.UpdateView(work_data);
  26. }
  27. protected virtual void UpdateView(ScheduleCSVData.ScheduleBase work_data)
  28. {
  29. }
  30. protected virtual void UpdateCurentValue()
  31. {
  32. }
  33. protected virtual void UpdateAddValue(MaidParams maidParam)
  34. {
  35. }
  36. protected void Active(bool active)
  37. {
  38. base.gameObject.SetActive(active);
  39. }
  40. protected string Sign(int input, string format = null)
  41. {
  42. if (input <= 0)
  43. {
  44. return input.ToString();
  45. }
  46. if (format != null)
  47. {
  48. return "+" + input.ToString(format);
  49. }
  50. return "+" + input.ToString();
  51. }
  52. public static void Reposition(GameObject parent)
  53. {
  54. UITable component = parent.GetComponent<UITable>();
  55. if (component)
  56. {
  57. component.Reposition();
  58. return;
  59. }
  60. UIGrid component2 = parent.GetComponent<UIGrid>();
  61. if (component2)
  62. {
  63. component2.Reposition();
  64. return;
  65. }
  66. }
  67. protected void ExamineDisplayItem()
  68. {
  69. int num = ScheduleCtrl.SetActiveExceptForNothing(this.m_listMaidItem, "0");
  70. bool flag = num > 0;
  71. this.m_goTitleOfMaidParameter.SetActive(flag);
  72. if (!flag)
  73. {
  74. this.Active(false);
  75. return;
  76. }
  77. this.Active(true);
  78. DescScheduleBase.Reposition(this.m_goMaidParameterParent);
  79. this.AdjustParameterViewer(num);
  80. }
  81. protected void AdjustParameterViewer(int displayMaidParameterCount)
  82. {
  83. float num = 15f;
  84. float num2 = 25f;
  85. float num3 = 0f;
  86. if (displayMaidParameterCount > 0)
  87. {
  88. num3 += (float)this.m_heightOfMaidParameterTitle + num;
  89. float y = this.m_goMaidParameterParent.GetComponent<UITable>().padding.y;
  90. IEnumerator enumerator = this.m_goMaidParameterParent.transform.GetEnumerator();
  91. try
  92. {
  93. while (enumerator.MoveNext())
  94. {
  95. object obj = enumerator.Current;
  96. Transform transform = (Transform)obj;
  97. if (transform.gameObject.activeSelf)
  98. {
  99. UILabel component = transform.GetComponent<UILabel>();
  100. num3 += (float)component.height + y * 2f;
  101. }
  102. }
  103. }
  104. finally
  105. {
  106. IDisposable disposable;
  107. if ((disposable = (enumerator as IDisposable)) != null)
  108. {
  109. disposable.Dispose();
  110. }
  111. }
  112. num3 += num2;
  113. }
  114. if (num3 > 0f)
  115. {
  116. this.m_spBGOfParameterViewer.height = (int)num3;
  117. }
  118. }
  119. protected int m_heightOfMaidParameterTitle;
  120. protected GameObject m_goTitleOfMaidParameter;
  121. protected UISprite m_spBGOfParameterViewer;
  122. protected const string NOTHING = "0";
  123. protected ScheduleTaskCtrl taskCtrl;
  124. protected List<ScheduleCtrl.VariableItem> m_listMaidItem;
  125. protected GameObject m_goMaidParameter;
  126. protected GameObject m_goMaidParameterParent;
  127. protected int intTaskInd;
  128. public class ParamSet
  129. {
  130. public ParamSet(GameObject parent, string childObjName, bool useCurrentValue = true)
  131. {
  132. this.baseObj = UTY.GetChildObject(parent, childObjName, false);
  133. if (this.baseObj == null)
  134. {
  135. return;
  136. }
  137. GameObject childObject = UTY.GetChildObject(this.baseObj, "Value", false);
  138. if (childObject != null)
  139. {
  140. this.addValue = childObject.GetComponent<UILabel>();
  141. }
  142. if (useCurrentValue)
  143. {
  144. GameObject childObject2 = UTY.GetChildObject(this.baseObj, "CurrentValue", false);
  145. if (childObject2 != null)
  146. {
  147. this.currentValue = childObject2.GetComponent<UILabel>();
  148. }
  149. }
  150. }
  151. public string AddValueText
  152. {
  153. set
  154. {
  155. if (this.addValue != null)
  156. {
  157. this.addValue.text = value;
  158. }
  159. }
  160. }
  161. public string CurrentValueText
  162. {
  163. set
  164. {
  165. if (this.currentValue != null)
  166. {
  167. this.currentValue.text = value;
  168. }
  169. }
  170. }
  171. public ScheduleCtrl.VariableItem GetVariableItem()
  172. {
  173. return new ScheduleCtrl.VariableItem(this.baseObj, this.addValue);
  174. }
  175. private GameObject baseObj;
  176. private UILabel addValue;
  177. private UILabel currentValue;
  178. }
  179. }