Voltage_Mgr.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class Voltage_Mgr : PartsMgrBase
  6. {
  7. public int VoltageStage
  8. {
  9. get
  10. {
  11. return this.m_VoltageFacter / 200 + 1;
  12. }
  13. private set
  14. {
  15. this.m_SaveVoltage = Mathf.Clamp((value - 1) * 200 + 100, 1, 1000);
  16. }
  17. }
  18. public static Voltage_Mgr Instance
  19. {
  20. get
  21. {
  22. return Voltage_Mgr.m_Instance;
  23. }
  24. }
  25. protected override void Start()
  26. {
  27. Voltage_Mgr.m_Instance = this;
  28. base.Start();
  29. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Free)
  30. {
  31. this.VoltageStage = DanceSetting.Settings.Voltage;
  32. }
  33. else
  34. {
  35. this.VoltageStage = 3;
  36. }
  37. this.m_VoltageFacter = this.m_SaveVoltage;
  38. foreach (ParticleSystem particleSystem in this.m_VoltageUpEffect)
  39. {
  40. particleSystem.gameObject.SetActive(false);
  41. }
  42. foreach (ParticleSystem particleSystem2 in this.m_VoltageDownEffect)
  43. {
  44. particleSystem2.gameObject.SetActive(false);
  45. }
  46. if (!base.IsActive)
  47. {
  48. base.gameObject.SetActive(false);
  49. return;
  50. }
  51. this.m_GaugeValue = this.m_VoltageFacter;
  52. this.m_GaugeMaxMark.SetActive(this.m_VoltageFacter == 1000);
  53. for (int k = 0; k < this.m_GaugeGroup.childCount; k++)
  54. {
  55. Transform child = this.m_GaugeGroup.GetChild(k);
  56. UISprite component = child.GetComponent<UISprite>();
  57. this.m_GaugeList.Add(component);
  58. component.fillAmount = (float)(this.m_VoltageFacter - k * 200) / 200f;
  59. }
  60. IEnumerator enumerator = this.m_FlashGauge.GetEnumerator();
  61. try
  62. {
  63. while (enumerator.MoveNext())
  64. {
  65. object obj = enumerator.Current;
  66. Transform transform = (Transform)obj;
  67. this.m_FlashGaugeList.Add(transform.GetComponent<UISprite>());
  68. }
  69. }
  70. finally
  71. {
  72. IDisposable disposable;
  73. if ((disposable = (enumerator as IDisposable)) != null)
  74. {
  75. disposable.Dispose();
  76. }
  77. }
  78. RhythmAction_Mgr.Instance.AddParticleSystem(this.m_VoltageUpEffect);
  79. RhythmAction_Mgr.Instance.AddParticleSystem(this.m_VoltageDownEffect);
  80. }
  81. private IEnumerator GaugeAnimation()
  82. {
  83. float timer = 0f;
  84. int first_voltage = this.m_GaugeValue;
  85. int voltage_diff = this.m_SaveVoltage - this.m_GaugeValue;
  86. for (;;)
  87. {
  88. timer += Time.deltaTime;
  89. this.m_GaugeValue = (int)((float)first_voltage + (float)voltage_diff * Mathf.Sin(timer / 0.75f * 90f * 0.017453292f));
  90. for (int i = 0; i < this.m_GaugeList.Count; i++)
  91. {
  92. this.m_GaugeList[i].fillAmount = (float)(this.m_GaugeValue - i * 200) / 200f;
  93. }
  94. if (timer >= 0.75f)
  95. {
  96. break;
  97. }
  98. yield return null;
  99. }
  100. this.m_GaugeValue = this.m_VoltageFacter;
  101. this.m_GaugeMaxMark.SetActive(this.m_VoltageFacter == 1000);
  102. yield break;
  103. yield break;
  104. }
  105. private IEnumerator GaugeFlash()
  106. {
  107. float timer = 0f;
  108. for (;;)
  109. {
  110. if (this.m_VoltageFacter < 200)
  111. {
  112. timer = 0f;
  113. this.m_FlashGauge.gameObject.SetActive(false);
  114. }
  115. else
  116. {
  117. if (!RhythmAction_Mgr.Instance.IsPause)
  118. {
  119. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  120. }
  121. this.m_FlashGauge.gameObject.SetActive(true);
  122. Color white = Color.white;
  123. white.a = Mathf.Sin(timer / this.m_FlashTime * 90f * 0.017453292f);
  124. for (int i = 0; i < this.m_FlashGaugeList.Count; i++)
  125. {
  126. if (200 * (i + 1) <= this.m_GaugeValue)
  127. {
  128. this.m_FlashGaugeList[i].gameObject.SetActive(true);
  129. this.m_FlashGaugeList[i].color = white;
  130. }
  131. else
  132. {
  133. this.m_FlashGaugeList[i].gameObject.SetActive(false);
  134. }
  135. }
  136. if (this.m_GaugeValue == 1000)
  137. {
  138. this.m_FlashGaugeMax.gameObject.SetActive(true);
  139. this.m_FlashGaugeMax.color = white;
  140. }
  141. else
  142. {
  143. this.m_FlashGaugeMax.gameObject.SetActive(false);
  144. }
  145. }
  146. yield return null;
  147. }
  148. yield break;
  149. }
  150. public void DecideVoltageValue()
  151. {
  152. int num = this.m_VoltageFacter / 200 + 1;
  153. this.m_VoltageFacter = this.m_SaveVoltage;
  154. if (num <= 3 && this.VoltageStage >= 4)
  155. {
  156. foreach (ParticleSystem particleSystem in this.m_VoltageUpEffect)
  157. {
  158. particleSystem.gameObject.SetActive(true);
  159. particleSystem.Play();
  160. }
  161. GameMain.Instance.SoundMgr.PlaySe(this.m_VoltageUpSe, false);
  162. }
  163. else if (num >= 4 && this.VoltageStage <= 3)
  164. {
  165. foreach (ParticleSystem particleSystem2 in this.m_VoltageDownEffect)
  166. {
  167. particleSystem2.gameObject.SetActive(true);
  168. particleSystem2.Play();
  169. }
  170. GameMain.Instance.SoundMgr.PlaySe(this.m_VoltageDownSe, false);
  171. }
  172. base.StartCoroutine(this.GaugeAnimation());
  173. }
  174. public void DownVoltage(Dance_Note.Evaluation evalue)
  175. {
  176. if (this.m_SaveVoltage == 1)
  177. {
  178. return;
  179. }
  180. foreach (Voltage_Mgr.DownData downData in this.m_VoltageDown_Data)
  181. {
  182. if (downData.Evalue == evalue)
  183. {
  184. this.m_SaveVoltage -= downData.DownValue;
  185. break;
  186. }
  187. }
  188. if (this.m_SaveVoltage < 1)
  189. {
  190. this.m_SaveVoltage = 1;
  191. }
  192. }
  193. public void AddVoltage()
  194. {
  195. if (this.m_SaveVoltage == 1000)
  196. {
  197. return;
  198. }
  199. this.m_SaveVoltage += this.m_AddValue;
  200. if (this.m_SaveVoltage > 1000)
  201. {
  202. this.m_SaveVoltage = 1000;
  203. }
  204. }
  205. public override void StartAction()
  206. {
  207. base.StartCoroutine(this.GaugeFlash());
  208. }
  209. private const float m_AnimeTime = 0.75f;
  210. public const int VoltageStageDefo = 3;
  211. public const int VoltageStageMin = 1;
  212. private const int m_MinFacter = 1;
  213. private const int m_MaxFacter = 1000;
  214. private const int m_VoltageUp = 200;
  215. private int m_VoltageFacter;
  216. private int m_GaugeValue;
  217. private int m_SaveVoltage;
  218. [SerializeField]
  219. private Transform m_GaugeGroup;
  220. [SerializeField]
  221. private GameObject m_GaugeMaxMark;
  222. [SerializeField]
  223. private float m_FlashTime;
  224. [SerializeField]
  225. private Transform m_FlashGauge;
  226. [SerializeField]
  227. private UISprite m_FlashGaugeMax;
  228. private List<UISprite> m_FlashGaugeList = new List<UISprite>();
  229. private List<UISprite> m_GaugeList = new List<UISprite>();
  230. [SerializeField]
  231. [Header("アピール時のボルテージ増加量")]
  232. private int m_AddValue = 50;
  233. [SerializeField]
  234. [Header("各評価ごとのボルテージの減少値")]
  235. private Voltage_Mgr.DownData[] m_VoltageDown_Data = new Voltage_Mgr.DownData[]
  236. {
  237. new Voltage_Mgr.DownData(Dance_Note.Evaluation.MISS, 30),
  238. new Voltage_Mgr.DownData(Dance_Note.Evaluation.BAD, 20),
  239. new Voltage_Mgr.DownData(Dance_Note.Evaluation.GOOD, 10)
  240. };
  241. [SerializeField]
  242. [Header("ボルテージがUpしたときの各エフェクト")]
  243. private ParticleSystem[] m_VoltageUpEffect;
  244. [SerializeField]
  245. private string m_VoltageUpSe = "SE008.ogg";
  246. [SerializeField]
  247. [Header("ボルテージがDownしたときの各エフェクト")]
  248. private ParticleSystem[] m_VoltageDownEffect;
  249. [SerializeField]
  250. private string m_VoltageDownSe = "SE003.ogg";
  251. private static Voltage_Mgr m_Instance;
  252. [Serializable]
  253. private class DownData
  254. {
  255. public DownData(Dance_Note.Evaluation evalue, int value)
  256. {
  257. this.Evalue = evalue;
  258. this.DownValue = value;
  259. }
  260. public Dance_Note.Evaluation Evalue;
  261. public int DownValue;
  262. }
  263. }