YotogiParamScroll.cs 4.5 KB

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