NoteEffect.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. public class NoteEffect : NoteBase
  7. {
  8. protected override void Update()
  9. {
  10. base.Update();
  11. }
  12. private IEnumerator EffectDelete()
  13. {
  14. float timer = 0f;
  15. for (;;)
  16. {
  17. if (!RhythmAction_Mgr.Instance.IsPause)
  18. {
  19. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  20. this.m_MySprite.width = (int)((float)this.m_FirstWidth * Mathf.Sin(90f * Mathf.Clamp01(timer / this.m_EffectTime) * 0.017453292f));
  21. this.m_MySprite.height = (int)((float)this.m_FirstHeight * Mathf.Sin(90f * Mathf.Clamp01(timer / this.m_EffectTime) * 0.017453292f));
  22. if (timer >= this.m_EffectTime + this.m_WaitTime)
  23. {
  24. if (this.m_AllEffectList.All((ParticleSystem effect) => !effect.isPlaying))
  25. {
  26. break;
  27. }
  28. }
  29. }
  30. yield return null;
  31. }
  32. foreach (ParticleSystem particle in this.m_AllEffectList)
  33. {
  34. RhythmAction_Mgr.Instance.RemoveParticleSystem(particle);
  35. }
  36. UnityEngine.Object.Destroy(base.gameObject);
  37. yield break;
  38. yield break;
  39. }
  40. public void Initialize(Dance_Note.Evaluation evalue, bool IsAppeal, int dotX, int dotY, Note_Mgr.EffecctType effect_type)
  41. {
  42. this.m_MyDotX = dotX;
  43. this.m_MyDotY = dotY;
  44. this.m_FirstWidth = this.m_MySprite.width;
  45. this.m_FirstHeight = this.m_MySprite.height;
  46. this.m_MySprite.width = 0;
  47. this.m_MySprite.height = 0;
  48. NoteEffect.EffectSetting use_setting = this.m_AllSettings.SingleOrDefault((NoteEffect.EffectSetting e) => e.Evalue == evalue);
  49. Action<GameObject, List<GameObject>> action = delegate(GameObject parent, List<GameObject> not_light)
  50. {
  51. if (!parent)
  52. {
  53. return;
  54. }
  55. parent.SetActive(true);
  56. IEnumerator enumerator = parent.transform.GetEnumerator();
  57. try
  58. {
  59. while (enumerator.MoveNext())
  60. {
  61. object obj = enumerator.Current;
  62. Transform transform = (Transform)obj;
  63. if ((DanceSetting.Settings.IsNoteEffectLight && !not_light.Contains(transform.gameObject)) || effect_type == Note_Mgr.EffecctType.Nothing || (effect_type == Note_Mgr.EffecctType.Few && !use_setting.NotFewEffect.Contains(transform.gameObject)))
  64. {
  65. transform.gameObject.SetActive(false);
  66. }
  67. else
  68. {
  69. ParticleSystem component = transform.GetComponent<ParticleSystem>();
  70. if (component)
  71. {
  72. RhythmAction_Mgr.Instance.AddParticleSystem(component);
  73. this.m_AllEffectList.Add(component);
  74. }
  75. }
  76. }
  77. }
  78. finally
  79. {
  80. IDisposable disposable;
  81. if ((disposable = (enumerator as IDisposable)) != null)
  82. {
  83. disposable.Dispose();
  84. }
  85. }
  86. };
  87. if (IsAppeal)
  88. {
  89. action(this.m_AppealEffect, this.m_NotLightAppeal);
  90. }
  91. else
  92. {
  93. action(use_setting.EffectObj, use_setting.NotLight);
  94. }
  95. this.m_MySprite.spriteName = use_setting.TexName;
  96. base.Start();
  97. base.StartCoroutine(this.EffectDelete());
  98. }
  99. private const float m_NotAnimeSize = 0.25f;
  100. [SerializeField]
  101. private float m_EffectTime = 0.5f;
  102. [SerializeField]
  103. private float m_WaitTime = 0.15f;
  104. [SerializeField]
  105. private UISprite m_MySprite;
  106. [SerializeField]
  107. private NoteEffect.EffectSetting[] m_AllSettings;
  108. [SerializeField]
  109. [Header("アピール時表示するオブジェクト")]
  110. private GameObject m_AppealEffect;
  111. [SerializeField]
  112. private List<GameObject> m_NotLightAppeal = new List<GameObject>();
  113. private int m_FirstWidth;
  114. private int m_FirstHeight;
  115. private List<ParticleSystem> m_AllEffectList = new List<ParticleSystem>();
  116. [Serializable]
  117. private class EffectSetting
  118. {
  119. [Header("評価")]
  120. public Dance_Note.Evaluation Evalue;
  121. [Header("表示オブジェクト")]
  122. public GameObject EffectObj;
  123. [Header("軽量モードで残すもの")]
  124. public List<GameObject> NotLight = new List<GameObject>();
  125. [Header("小エフェクトのとき残すもの")]
  126. public List<GameObject> NotFewEffect = new List<GameObject>();
  127. [Header("表示画像名")]
  128. public string TexName;
  129. }
  130. }