TrophyAchieveEffect.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using I2.Loc;
  5. using UnityEngine;
  6. public class TrophyAchieveEffect : MonoBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.main_panel_ = base.gameObject.GetComponent<UIPanel>();
  11. this.title_label_ = UTY.GetChildObject(base.gameObject, "TitleLabel", false).GetComponent<UILabel>();
  12. this.item_label_ = UTY.GetChildObject(base.gameObject, "LineupItemLabel", false).GetComponent<UILabel>();
  13. this.item_fix_label_obj_ = UTY.GetChildObject(base.gameObject, "ItemFixText", false);
  14. this.trophy_image_ = UTY.GetChildObject(base.gameObject, "TrophyImage/Image", false).GetComponent<UISprite>();
  15. this.main_panel_.alpha = 0f;
  16. this.init_local_pos_ = base.transform.localPosition;
  17. }
  18. public void EffectStart(Trophy.Data trophy_data)
  19. {
  20. if (trophy_data == null)
  21. {
  22. return;
  23. }
  24. this.trophy_data_list_.Add(trophy_data);
  25. }
  26. public void EffectStackClear()
  27. {
  28. this.Clear();
  29. this.trophy_data_list_.Clear();
  30. }
  31. public void Clear()
  32. {
  33. if (this.state_ == TrophyAchieveEffect.State.InMove || this.state_ == TrophyAchieveEffect.State.OutMove)
  34. {
  35. iTween.Stop(base.gameObject);
  36. }
  37. this.state_ = TrophyAchieveEffect.State.Null;
  38. this.main_panel_.alpha = 0f;
  39. base.transform.localPosition = this.init_local_pos_;
  40. }
  41. public void Update()
  42. {
  43. if (0 < this.trophy_data_list_.Count && this.state_ == TrophyAchieveEffect.State.Null && GameMain.Instance.MainCamera.IsFadeStateNon())
  44. {
  45. Trophy.Data trophy_data = this.trophy_data_list_[0];
  46. this.trophy_data_list_.RemoveAt(0);
  47. this.Clear();
  48. this.WriteUITrophyData(trophy_data);
  49. this.state_ = TrophyAchieveEffect.State.InMove;
  50. GameMain.Instance.SoundMgr.PlaySystem("SE015.ogg");
  51. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  52. {
  53. "easetype",
  54. iTween.EaseType.easeOutCubic,
  55. "from",
  56. 0,
  57. "to",
  58. 1,
  59. "time",
  60. this.MoveSpeedTime,
  61. "onupdate",
  62. "UpdateFadeIn",
  63. "oncomplete",
  64. "OnEndFadeIn"
  65. }));
  66. return;
  67. }
  68. if (this.state_ == TrophyAchieveEffect.State.Wait && this.fade_out_tick_count_ <= GameMain.tick_count)
  69. {
  70. this.state_ = TrophyAchieveEffect.State.OutMove;
  71. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  72. {
  73. "easetype",
  74. iTween.EaseType.easeOutCubic,
  75. "from",
  76. 1,
  77. "to",
  78. 0,
  79. "time",
  80. this.MoveSpeedTime,
  81. "onupdate",
  82. "UpdateFadeOut",
  83. "oncomplete",
  84. "OnEndFadeOut"
  85. }));
  86. }
  87. }
  88. private void UpdateFadeIn(float value)
  89. {
  90. if (this.state_ != TrophyAchieveEffect.State.InMove)
  91. {
  92. return;
  93. }
  94. this.main_panel_.alpha = value;
  95. base.transform.localPosition = new Vector3(this.init_local_pos_.x + (float)this.MoveXPos * value, this.init_local_pos_.y, this.init_local_pos_.z);
  96. }
  97. private void OnEndFadeIn()
  98. {
  99. if (this.state_ != TrophyAchieveEffect.State.InMove)
  100. {
  101. return;
  102. }
  103. base.StartCoroutine(this.CoLoadWaitMove());
  104. }
  105. private IEnumerator CoLoadWaitMove()
  106. {
  107. while (GameMain.Instance.MainCamera.IsFadeProc())
  108. {
  109. yield return null;
  110. }
  111. if (this.state_ == TrophyAchieveEffect.State.InMove)
  112. {
  113. this.fade_out_tick_count_ = GameMain.tick_count + this.WaitTime;
  114. this.state_ = TrophyAchieveEffect.State.Wait;
  115. }
  116. yield break;
  117. }
  118. private void UpdateFadeOut(float value)
  119. {
  120. if (this.state_ != TrophyAchieveEffect.State.OutMove)
  121. {
  122. return;
  123. }
  124. this.main_panel_.alpha = value;
  125. }
  126. private void OnEndFadeOut()
  127. {
  128. if (this.state_ != TrophyAchieveEffect.State.OutMove)
  129. {
  130. return;
  131. }
  132. this.state_ = TrophyAchieveEffect.State.Null;
  133. this.Clear();
  134. }
  135. private void WriteUITrophyData(Trophy.Data trophy_data)
  136. {
  137. this.trophy_image_.spriteName = trophy_data.trophySpriteName;
  138. this.title_label_.text = "『" + trophy_data.name + "』";
  139. if (Product.SPP)
  140. {
  141. Localize component = this.title_label_.GetComponent<Localize>();
  142. if (component != null)
  143. {
  144. component.TermPrefix = "『";
  145. component.TermSuffix = "』";
  146. component.SetTerm(trophy_data.nameTerm);
  147. }
  148. }
  149. if (!string.IsNullOrEmpty(trophy_data.effectDrawItemName) && GameMain.Instance.CharacterMgr.status.isAvailableShop)
  150. {
  151. this.item_label_.text = "『" + trophy_data.effectDrawItemName + "』";
  152. this.item_fix_label_obj_.SetActive(true);
  153. }
  154. else
  155. {
  156. this.item_label_.text = string.Empty;
  157. this.item_fix_label_obj_.SetActive(false);
  158. }
  159. }
  160. public float MoveSpeedTime;
  161. public int MoveXPos = 1000;
  162. public int WaitTime = 2500;
  163. private TrophyAchieveEffect.State state_;
  164. private UISprite trophy_image_;
  165. private UIPanel main_panel_;
  166. private UILabel title_label_;
  167. private UILabel item_label_;
  168. private GameObject item_fix_label_obj_;
  169. private Vector3 init_local_pos_;
  170. private int fade_out_tick_count_;
  171. private List<Trophy.Data> trophy_data_list_ = new List<Trophy.Data>();
  172. private enum State
  173. {
  174. Null,
  175. InMove,
  176. Wait,
  177. OutMove
  178. }
  179. }