YotogiParamScroll.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using I2.Loc;
  5. using UnityEngine;
  6. using wf;
  7. public class YotogiParamScroll : MonoBehaviour
  8. {
  9. private void Awake()
  10. {
  11. this.panel_ = UTY.GetChildObject(base.gameObject, "Mask", false).GetComponent<UIPanel>();
  12. this.parent_obj_ = UTY.GetChildObject(base.gameObject, "Parent", false);
  13. Transform transform = this.parent_obj_.transform;
  14. this.label_array = new YotogiParamScroll.LabelAndLocalize[transform.childCount];
  15. for (int i = 0; i < this.label_array.Length; i++)
  16. {
  17. this.label_array[i] = new YotogiParamScroll.LabelAndLocalize(transform.GetChild(i).GetComponent<UILabel>(), transform.GetChild(i).GetComponent<Localize>());
  18. }
  19. this.base_pos = transform.localPosition;
  20. this.hide_pos = this.base_pos;
  21. this.hide_pos.x = this.hide_pos.x - this.panel_.baseClipRegion.z;
  22. this.end_pos = this.base_pos;
  23. this.end_pos.y = this.end_pos.y + this.panel_.baseClipRegion.w;
  24. transform.localPosition = this.hide_pos;
  25. }
  26. public void Init()
  27. {
  28. for (int i = 0; i < this.label_array.Length; i++)
  29. {
  30. this.label_array[i].label.alpha = 0f;
  31. }
  32. if (this.state_ == YotogiParamScroll.State.FadeIn || this.state_ == YotogiParamScroll.State.FadeOut)
  33. {
  34. iTween.Stop(this.parent_obj_);
  35. }
  36. if (this.state_ == YotogiParamScroll.State.FadeOut)
  37. {
  38. this.parent_obj_.transform.SetParent(base.transform, false);
  39. for (int j = 0; j < this.label_array.Length; j++)
  40. {
  41. this.label_array[j].label.ParentHasChanged();
  42. }
  43. }
  44. this.parent_obj_.transform.localPosition = this.hide_pos;
  45. }
  46. public void CallFadeIn(List<KeyValuePair<string, int>> draw_param)
  47. {
  48. draw_param.RemoveAll((KeyValuePair<string, int> key_val) => key_val.Value == 0);
  49. int num = (this.label_array.Length >= draw_param.Count) ? draw_param.Count : this.label_array.Length;
  50. for (int i = 0; i < this.label_array.Length; i++)
  51. {
  52. this.label_array[i].label.alpha = 0f;
  53. }
  54. for (int j = 0; j < num; j++)
  55. {
  56. this.label_array[j].label.alpha = 1f;
  57. KeyValuePair<string, int> keyValuePair = draw_param[j];
  58. YotogiParamScroll.SetLabelText(this.label_array[j], keyValuePair.Key, keyValuePair.Value);
  59. }
  60. if (this.state_ == YotogiParamScroll.State.FadeIn || this.state_ == YotogiParamScroll.State.FadeOut)
  61. {
  62. iTween.Stop(this.parent_obj_);
  63. }
  64. if (this.state_ == YotogiParamScroll.State.FadeOut)
  65. {
  66. this.parent_obj_.transform.SetParent(base.transform, false);
  67. for (int k = 0; k < this.label_array.Length; k++)
  68. {
  69. this.label_array[k].label.ParentHasChanged();
  70. }
  71. }
  72. this.parent_obj_.transform.localPosition = this.hide_pos;
  73. this.state_ = YotogiParamScroll.State.CallIn;
  74. }
  75. private void Update()
  76. {
  77. if (this.state_ == YotogiParamScroll.State.Wait && this.fade_out_tick_count <= GameMain.tick_count)
  78. {
  79. this.parent_obj_.transform.SetParent(this.panel_.transform, false);
  80. for (int i = 0; i < this.label_array.Length; i++)
  81. {
  82. this.label_array[i].label.ParentHasChanged();
  83. }
  84. Hashtable hashtable = TweenHash.EaseOutSine(TweenHash.Type.Position, this.end_pos, this.MoveSpeedTime);
  85. hashtable.Add("oncomplete", "OnEndFadeOut");
  86. hashtable.Add("oncompletetarget", base.gameObject);
  87. iTween.MoveTo(this.parent_obj_, hashtable);
  88. this.state_ = YotogiParamScroll.State.FadeOut;
  89. }
  90. }
  91. private void LateUpdate()
  92. {
  93. if (this.state_ == YotogiParamScroll.State.CallIn && this.parent_obj_.GetComponent<iTween>() == null)
  94. {
  95. Hashtable hashtable = TweenHash.EaseOutSine(TweenHash.Type.Position, this.base_pos, this.MoveSpeedTime);
  96. hashtable.Add("oncomplete", "OnEndFadeIn");
  97. hashtable.Add("oncompletetarget", base.gameObject);
  98. iTween.MoveTo(this.parent_obj_, hashtable);
  99. this.state_ = YotogiParamScroll.State.FadeIn;
  100. }
  101. }
  102. private void OnEndFadeIn()
  103. {
  104. iTween.Stop(this.parent_obj_);
  105. this.fade_out_tick_count = GameMain.tick_count + this.WaitTime;
  106. this.state_ = YotogiParamScroll.State.Wait;
  107. }
  108. private void OnEndFadeOut()
  109. {
  110. iTween.Stop(this.parent_obj_);
  111. this.parent_obj_.transform.SetParent(base.transform, false);
  112. for (int i = 0; i < this.label_array.Length; i++)
  113. {
  114. this.label_array[i].label.ParentHasChanged();
  115. }
  116. this.parent_obj_.transform.localPosition = this.hide_pos;
  117. this.state_ = YotogiParamScroll.State.Null;
  118. }
  119. private static void SetLabelText(YotogiParamScroll.LabelAndLocalize labelAndLocalize, string text, int num)
  120. {
  121. labelAndLocalize.label.text = text;
  122. if (labelAndLocalize.localize != null)
  123. {
  124. labelAndLocalize.localize.SetTerm("MaidStatus/" + text);
  125. }
  126. UILabel label = labelAndLocalize.label;
  127. label.text = label.text + " " + num.ToString();
  128. }
  129. public int WaitTime = 2500;
  130. public float MoveSpeedTime = 0.7f;
  131. private UIPanel panel_;
  132. private GameObject parent_obj_;
  133. private YotogiParamScroll.LabelAndLocalize[] label_array;
  134. private Vector3 base_pos;
  135. private Vector3 hide_pos;
  136. private Vector3 end_pos;
  137. private int fade_out_tick_count;
  138. private YotogiParamScroll.State state_;
  139. private enum State
  140. {
  141. Null,
  142. CallIn,
  143. FadeIn,
  144. Wait,
  145. FadeOut
  146. }
  147. private struct LabelAndLocalize
  148. {
  149. public LabelAndLocalize(UILabel label, Localize localize)
  150. {
  151. this.label = label;
  152. this.localize = localize;
  153. }
  154. public UILabel label;
  155. public Localize localize;
  156. }
  157. }