ConfrontCutIn.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class ConfrontCutIn : MonoBehaviour
  6. {
  7. private float m_FadeAlpha
  8. {
  9. get
  10. {
  11. return this.m_FadeSprite.color.a;
  12. }
  13. set
  14. {
  15. Color color = this.m_FadeSprite.color;
  16. color.a = value;
  17. this.m_FadeSprite.color = color;
  18. }
  19. }
  20. private float m_MydeltaTime
  21. {
  22. get
  23. {
  24. return Time.deltaTime * (float)this.m_TimeSpeed;
  25. }
  26. }
  27. private void Init(string end_label)
  28. {
  29. this.m_CutinBG.enabled = GameMain.Instance.VRMode;
  30. GameMain.Instance.SoundMgr.StopBGM(0f);
  31. GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
  32. UICamera.InputEnable = false;
  33. GameMain.Instance.BgMgr.DeleteBg();
  34. this.m_EndJumpLabel = end_label;
  35. GameMain.Instance.CharacterMgr.VisibleAll(false);
  36. this.m_VSText.gameObject.SetActive(false);
  37. foreach (ParticleSystem particleSystem in this.m_CutInEffect)
  38. {
  39. particleSystem.gameObject.SetActive(false);
  40. }
  41. this.m_FadeAlpha = 0f;
  42. this.m_PlayerSprite.sprite2D = ShootCutInTex.GetCutInTex(DanceBattle_Mgr.CharaType.Player, ShootCutInTex.CutInName.対峙演出);
  43. this.m_EnemySprite.sprite2D = ShootCutInTex.GetCutInTex(DanceBattle_Mgr.CharaType.Enemy, ShootCutInTex.CutInName.対峙演出);
  44. base.StartCoroutine(this.SpriteCutIn());
  45. }
  46. private void CheckJinglePlay(ConfrontCutIn.CutinEvent cutin_event, bool first)
  47. {
  48. if (cutin_event == this.m_JingleTiming && first == this.m_IsBeginPlay)
  49. {
  50. if (this.m_DelayTime > 0f)
  51. {
  52. base.Invoke("PlayJingle", this.m_DelayTime);
  53. }
  54. else
  55. {
  56. this.PlayJingle();
  57. }
  58. }
  59. }
  60. private void PlayJingle()
  61. {
  62. GameMain.Instance.SoundMgr.PlaySe(this.m_JingleSe, false);
  63. }
  64. private void Update()
  65. {
  66. this.m_EnemySprite.transform.localPosition = Vector3.right * (float)this.m_EnemySprite.width / 2f;
  67. this.m_TimeSpeed = ((!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl)) ? 1 : 2);
  68. }
  69. private IEnumerator SpriteCutIn()
  70. {
  71. float timer = 0f;
  72. bool enemy_cut = false;
  73. Vector3 player_first = Vector3.zero;
  74. Vector3 enemy_first = Vector3.zero;
  75. if (GameMain.Instance.VRMode)
  76. {
  77. player_first.x = (float)(-(float)this.m_UIRect_Width / 2);
  78. enemy_first.x = (float)(this.m_UIRect_Width / 2);
  79. }
  80. else
  81. {
  82. player_first.y = (enemy_first.y = (float)(Screen.height / 2));
  83. enemy_first.x = (float)(Screen.width * 2);
  84. enemy_first = UI_ScreenFitBase.PointToScreenPos(enemy_first);
  85. player_first.x = (float)(-(float)Screen.width);
  86. player_first = UI_ScreenFitBase.PointToScreenPos(player_first);
  87. }
  88. while (GameMain.Instance.MainCamera.IsFadeOut())
  89. {
  90. yield return null;
  91. }
  92. yield return new WaitForSeconds(this.m_CutInStart / (float)this.m_TimeSpeed);
  93. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.PlayerCut, true);
  94. for (;;)
  95. {
  96. timer += this.m_MydeltaTime;
  97. if (!enemy_cut)
  98. {
  99. this.m_PlayerSprite.transform.parent.localPosition = Vector3.Lerp(player_first, Vector3.zero, this.TimeRate01(timer, this.m_CutInTime));
  100. }
  101. else
  102. {
  103. this.m_EnemySprite.transform.parent.localPosition = Vector3.Lerp(enemy_first, Vector3.zero, this.TimeRate01(timer, this.m_CutInTime));
  104. }
  105. this.m_CutinBG.transform.position = this.m_PlayerSprite.transform.position;
  106. if (timer > this.m_CutInTime)
  107. {
  108. if (!enemy_cut)
  109. {
  110. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.PlayerCut, false);
  111. }
  112. else
  113. {
  114. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.EnemyCut, false);
  115. }
  116. yield return new WaitForSeconds(this.m_CutInWait / (float)this.m_TimeSpeed);
  117. if (enemy_cut)
  118. {
  119. break;
  120. }
  121. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.EnemyCut, true);
  122. enemy_cut = true;
  123. timer = 0f;
  124. }
  125. yield return null;
  126. }
  127. base.StartCoroutine(this.TextScaling());
  128. yield break;
  129. yield break;
  130. }
  131. private IEnumerator TextScaling()
  132. {
  133. this.m_VSText.gameObject.SetActive(true);
  134. float timer = 0f;
  135. Vector3 first = Vector3.zero;
  136. if (GameMain.Instance.VRMode)
  137. {
  138. first.y = (float)(this.m_UIRect_Width / 2);
  139. }
  140. else
  141. {
  142. first.x = (float)(Screen.width / 2);
  143. first.y = (float)(Screen.width / 2);
  144. first = UI_ScreenFitBase.PointToScreenPos(first);
  145. first.y *= -1f;
  146. }
  147. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.TextZoom, true);
  148. for (;;)
  149. {
  150. timer += this.m_MydeltaTime;
  151. this.m_VSText.transform.localPosition = Vector3.Lerp(first, Vector3.zero, Mathf.Clamp01(timer / this.m_TextScaling));
  152. UIWidget vstext = this.m_VSText;
  153. int num = (int)Mathf.Lerp((float)this.m_TextMax, (float)this.m_TextMin, Mathf.Clamp01(timer / this.m_TextScaling));
  154. this.m_VSText.height = num;
  155. vstext.width = num;
  156. if (timer > this.m_TextScaling)
  157. {
  158. break;
  159. }
  160. yield return null;
  161. }
  162. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.TextZoom, false);
  163. base.StartCoroutine(this.TextVibrate());
  164. yield break;
  165. yield break;
  166. }
  167. private IEnumerator TextVibrate()
  168. {
  169. float timer = 0f;
  170. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.TextVibrate, true);
  171. for (;;)
  172. {
  173. timer += this.m_MydeltaTime;
  174. Vector3 vibe_vec = Vector3.zero;
  175. vibe_vec.x = (float)UnityEngine.Random.Range(-1, 1);
  176. vibe_vec.y = (float)UnityEngine.Random.Range(-1, 1);
  177. vibe_vec = vibe_vec.normalized * UnityEngine.Random.Range(0f, 1f) * this.m_VibrateRange;
  178. this.m_VSText.transform.localPosition = vibe_vec;
  179. if (timer > this.m_VibrateTime)
  180. {
  181. break;
  182. }
  183. yield return null;
  184. }
  185. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.TextVibrate, false);
  186. this.m_VSText.transform.localPosition = Vector3.zero;
  187. base.StartCoroutine(this.FadeEffect());
  188. yield break;
  189. yield break;
  190. }
  191. private IEnumerator FadeEffect()
  192. {
  193. float timer = 0f;
  194. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.ScreenFlash, true);
  195. for (;;)
  196. {
  197. timer += this.m_MydeltaTime;
  198. this.m_FadeAlpha = Mathf.Sin(Mathf.Clamp01(timer / this.m_FadeTime) * 180f * 0.0174532924f);
  199. if (timer > this.m_FadeTime)
  200. {
  201. break;
  202. }
  203. if (timer > this.m_FadeTime / 2f)
  204. {
  205. foreach (ParticleSystem particleSystem in this.m_CutInEffect)
  206. {
  207. particleSystem.gameObject.SetActive(true);
  208. if (!particleSystem.main.loop && !particleSystem.isPlaying)
  209. {
  210. particleSystem.Play();
  211. }
  212. }
  213. this.m_VSText.gameObject.SetActive(false);
  214. }
  215. yield return null;
  216. }
  217. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.ScreenFlash, false);
  218. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.EffectPlay, true);
  219. yield return new WaitForSeconds(this.m_EndWait / (float)this.m_TimeSpeed);
  220. NDebug.Assert(!string.IsNullOrEmpty(this.m_EndJumpLabel), "ConfrontCutIn.cs:対峙演出終了後に飛ぶラベルが設定されてません");
  221. this.CheckJinglePlay(ConfrontCutIn.CutinEvent.EffectPlay, false);
  222. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.CutInEnd), true, default(Color));
  223. yield break;
  224. yield break;
  225. }
  226. private void CutInEnd()
  227. {
  228. UnityEngine.Object.Destroy(base.gameObject);
  229. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_EndJumpLabel);
  230. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  231. }
  232. private float TimeRate01(float timer, float time_max)
  233. {
  234. return Mathf.Sin(Mathf.Clamp01(timer / time_max) * 90f * 0.0174532924f);
  235. }
  236. public static void CutInStart(string end_label)
  237. {
  238. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/ConfrontCutIn"));
  239. gameObject.GetComponentInChildren<ConfrontCutIn>().Init(end_label);
  240. }
  241. private const string m_ConfrontObjPath = "SceneDance/Rhythm_Action/Prefab/ConfrontCutIn";
  242. private const int m_Magnification = 2;
  243. [SerializeField]
  244. [Header("ジングル再生するタイミング")]
  245. private ConfrontCutIn.CutinEvent m_JingleTiming;
  246. [SerializeField]
  247. [Header("イベントの開始時にならすかどうか")]
  248. private bool m_IsBeginPlay;
  249. [SerializeField]
  250. [Header("ジングルのSE名")]
  251. private string m_JingleSe;
  252. [SerializeField]
  253. [Header("ジングル再生時のDelay")]
  254. private float m_DelayTime;
  255. [SerializeField]
  256. [Header("")]
  257. private int m_UIRect_Width = 1920;
  258. [SerializeField]
  259. private UI2DSprite m_VSText;
  260. [SerializeField]
  261. [Header("プレイヤー画像")]
  262. private UI2DSprite m_PlayerSprite;
  263. [SerializeField]
  264. [Header("敵画像")]
  265. private UI2DSprite m_EnemySprite;
  266. [SerializeField]
  267. [Header("カットインエフェクト")]
  268. private List<ParticleSystem> m_CutInEffect = new List<ParticleSystem>();
  269. [SerializeField]
  270. [Header("フェード用画像")]
  271. private UISprite m_FadeSprite;
  272. [SerializeField]
  273. [Header("カットイン画像背景")]
  274. private UI2DSprite m_CutinBG;
  275. [SerializeField]
  276. [Header("全てのアニメーションが開始されるまでの待機時間")]
  277. private float m_CutInStart = 1f;
  278. [SerializeField]
  279. [Header("カットイン時間")]
  280. private float m_CutInTime = 0.5f;
  281. [SerializeField]
  282. [Header("カットイン後次の演出に行くまでの待機時間")]
  283. private float m_CutInWait = 0.5f;
  284. [SerializeField]
  285. [Header("テキストの拡縮時間")]
  286. private float m_TextScaling = 0.5f;
  287. [SerializeField]
  288. [Header("テキスト最大サイズ")]
  289. private int m_TextMax = 1024;
  290. [SerializeField]
  291. [Header("テキスト最小サイズ")]
  292. private int m_TextMin = 100;
  293. [SerializeField]
  294. [Header("テキスト振動量")]
  295. private float m_VibrateRange = 2.25f;
  296. [SerializeField]
  297. [Header("テキスト振動時間")]
  298. private float m_VibrateTime = 1f;
  299. [SerializeField]
  300. [Header("フェード時間")]
  301. private float m_FadeTime = 0.75f;
  302. [SerializeField]
  303. [Header("フェード終了後次の画面に行くまでの待機時間")]
  304. private float m_EndWait = 1f;
  305. private string m_EndJumpLabel = string.Empty;
  306. private int m_TimeSpeed = 1;
  307. private enum CutinEvent
  308. {
  309. PlayerCut,
  310. EnemyCut,
  311. TextZoom,
  312. TextVibrate,
  313. ScreenFlash,
  314. EffectPlay
  315. }
  316. }