TrophyAchieveEffect.cs 4.5 KB

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