YotogiParamScroll.cs 5.3 KB

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