Dance_Note.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. public class Dance_Note : NoteBase
  7. {
  8. public bool IsAppealNow
  9. {
  10. get
  11. {
  12. return this.m_IsAppealNow;
  13. }
  14. }
  15. public float NotJudgeTime
  16. {
  17. get
  18. {
  19. return this.m_BaseTiming + this.m_AddTiming * (float)DanceSetting.Settings.NoteOccurTiming;
  20. }
  21. }
  22. protected override void Start()
  23. {
  24. base.Start();
  25. this.m_IsAppealNow = Note_Mgr.Instance.CanNoteAppeal(this.m_MyType);
  26. Note_Mgr.Instance.AddNote(this, this.m_MyType);
  27. foreach (ParticleSystem particleSystem in this.m_SpecialEffect)
  28. {
  29. particleSystem.gameObject.SetActive(false);
  30. }
  31. this.m_IsMySpecial = Note_Mgr.Instance.IsNoteSpecial(this.m_MyType);
  32. if (this.m_IsMySpecial)
  33. {
  34. if (this.m_MyType == DanceBattle_Mgr.CharaType.Player)
  35. {
  36. foreach (ParticleSystem particleSystem2 in this.m_SpecialEffect)
  37. {
  38. particleSystem2.gameObject.SetActive(true);
  39. RhythmAction_Mgr.Instance.AddParticleSystem(particleSystem2);
  40. }
  41. }
  42. Note_Mgr.Instance.SetSpecialFlag(this.m_MyType, false);
  43. }
  44. if (this.m_MyType == DanceBattle_Mgr.CharaType.Enemy)
  45. {
  46. for (int k = 0; k < this.m_NoteUIList.Count<Dance_Note.NoteUIInfo>(); k++)
  47. {
  48. this.m_NoteUIList[k].NoteSprite.enabled = false;
  49. }
  50. this.m_RingSprite.enabled = false;
  51. this.CheckNote();
  52. return;
  53. }
  54. this.m_RingWidth = (float)this.m_RingSprite.width;
  55. this.m_RingHeight = (float)this.m_RingSprite.height;
  56. float num = this.m_RingWidth - this.m_RingFitNote.x;
  57. float num2 = this.m_RingHeight - this.m_RingFitNote.y;
  58. this.m_JudgeStartTime = this.GetBeforeJudge(Dance_Note.Evaluation.BAD) + this.NotJudgeTime;
  59. this.m_JudgeEndtTime = this.GetAfterJudge(Dance_Note.Evaluation.BAD);
  60. this.m_nTime = this.m_JudgeStartTime;
  61. this.m_WidthSpeed = num / this.m_JudgeStartTime;
  62. this.m_HeightSpeed = num2 / this.m_JudgeStartTime;
  63. if (this.m_IsAppealNow)
  64. {
  65. this.m_RingSprite.color = this.m_Appeal_RingColor;
  66. }
  67. else
  68. {
  69. this.m_RingSprite.color = this.m_Normal_RingColor;
  70. }
  71. base.StartCoroutine(this.NoteScaling());
  72. }
  73. private IEnumerator NoteScaling()
  74. {
  75. float timer = 0f;
  76. for (;;)
  77. {
  78. if (!RhythmAction_Mgr.Instance.IsPause)
  79. {
  80. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  81. float d = Mathf.Sin(Mathf.Clamp01(timer / this.m_ScalingTime) * 90f * 0.0174532924f);
  82. base.transform.localScale = Vector3.one * d;
  83. this.m_RingSprite.transform.localScale = Vector3.one / d;
  84. if (timer > this.m_ScalingTime)
  85. {
  86. break;
  87. }
  88. }
  89. yield return null;
  90. }
  91. yield break;
  92. yield break;
  93. }
  94. protected override void Update()
  95. {
  96. base.Update();
  97. if (!RhythmAction_Mgr.Instance.IsPause)
  98. {
  99. for (int i = 0; i < this.m_NoteUIList.Count<Dance_Note.NoteUIInfo>(); i++)
  100. {
  101. if (!this.m_NoteUIList[i].IsRotate)
  102. {
  103. this.m_NoteUIList[i].NoteSprite.fillAmount = Mathf.Clamp01(1f - this.m_nTime / this.m_JudgeStartTime) / 2f;
  104. }
  105. else
  106. {
  107. float d = this.m_RotateSpeed * (float)(1 - i % 2 * 2);
  108. this.m_NoteUIList[i].NoteSprite.transform.eulerAngles += Vector3.forward * d * RhythmAction_Mgr.Instance.DanceDeltaTime;
  109. }
  110. }
  111. if (!this.m_IsAppealNow && !Note_Mgr.Instance.CanNoteAppeal(this.m_MyType))
  112. {
  113. if (this.m_nTime < -this.m_JudgeEndtTime)
  114. {
  115. this.NoteEnd(Dance_Note.Evaluation.MISS);
  116. }
  117. }
  118. else
  119. {
  120. if (this.m_nTime <= 0f)
  121. {
  122. this.NoteEnd(Dance_Note.Evaluation.PERFECT);
  123. }
  124. if (this.m_RingSprite.color != this.m_Appeal_RingColor)
  125. {
  126. this.m_RingSprite.color = this.m_Appeal_RingColor;
  127. this.m_IsAppealNow = true;
  128. Note_Mgr.Instance.AddAppealNoteCount(this.m_MyType);
  129. }
  130. }
  131. this.m_RingWidth -= this.m_WidthSpeed * RhythmAction_Mgr.Instance.DanceDeltaTime;
  132. this.m_RingHeight -= this.m_HeightSpeed * RhythmAction_Mgr.Instance.DanceDeltaTime;
  133. this.m_RingSprite.width = Mathf.Max((int)this.m_RingWidth, 0);
  134. this.m_RingSprite.height = Mathf.Max((int)this.m_RingHeight, 0);
  135. this.m_nTime -= RhythmAction_Mgr.Instance.DanceDeltaTime;
  136. if (this.m_nTime <= 0f && Dance_Note.IsAutoPlay)
  137. {
  138. this.NoteEnd(Dance_Note.Evaluation.PERFECT);
  139. }
  140. }
  141. }
  142. public float GetBeforeJudge(Dance_Note.Evaluation evalue)
  143. {
  144. return this.m_EvalueJudge.SingleOrDefault((Dance_Note.EvalueJadge e) => e.Evalue == evalue).BeforeJudge;
  145. }
  146. public float GetAfterJudge(Dance_Note.Evaluation evalue)
  147. {
  148. return this.m_EvalueJudge.SingleOrDefault((Dance_Note.EvalueJadge e) => e.Evalue == evalue).AfterJudge;
  149. }
  150. private void NoteEnd(Dance_Note.Evaluation evalue)
  151. {
  152. Score_Mgr.Instance.AddScore(evalue, this.m_MyType, this.m_IsMySpecial);
  153. if (Appeal_Mgr.Instance.IsActive && (evalue == Dance_Note.Evaluation.GREAT || evalue == Dance_Note.Evaluation.PERFECT) && !this.m_IsAppealNow)
  154. {
  155. Appeal_Mgr.Instance.AddAppealValue(this.m_MyType, this.m_AddAppeal);
  156. }
  157. if (this.m_MyType == DanceBattle_Mgr.CharaType.Player)
  158. {
  159. if (DanceSetting.Settings.IsSEPlay && evalue != Dance_Note.Evaluation.MISS)
  160. {
  161. Note_Mgr.Instance.NoteSEPlay(null);
  162. }
  163. if (Voltage_Mgr.Instance.IsActive)
  164. {
  165. Voltage_Mgr.Instance.DownVoltage(evalue);
  166. }
  167. RhythmAction_Mgr.Instance.RemoveParticleSystem(this.m_SpecialEffect);
  168. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(Note_Mgr.Instance.NoteEffectPrefab);
  169. gameObject.transform.parent = base.transform.parent;
  170. gameObject.transform.localPosition = base.transform.localPosition;
  171. gameObject.transform.localScale = Vector3.one;
  172. gameObject.GetComponent<NoteEffect>().Initialize(evalue, this.m_IsAppealNow, this.m_MyDotX, this.m_MyDotY, this.m_effectType);
  173. }
  174. Note_Mgr.Instance.RemoveNote(this.m_MyType);
  175. UnityEngine.Object.Destroy(base.gameObject);
  176. }
  177. public void SetTargetNote()
  178. {
  179. if (!this.m_IsAppealNow)
  180. {
  181. this.m_RingSprite.color = this.m_TargetMarkColor;
  182. for (int i = 0; i < this.m_NoteUIList.Count<Dance_Note.NoteUIInfo>(); i++)
  183. {
  184. if (this.m_NoteUIList[i].IsRotate)
  185. {
  186. this.m_NoteUIList[i].NoteSprite.color = this.m_TargetNoteColor;
  187. }
  188. }
  189. }
  190. }
  191. public void CheckNote()
  192. {
  193. Dance_Note.Evaluation evalue = Dance_Note.Evaluation.MISS;
  194. if (this.m_MyType == DanceBattle_Mgr.CharaType.Player)
  195. {
  196. if (Dance_Note.IsAutoPlay)
  197. {
  198. return;
  199. }
  200. if (this.m_IsAppealNow)
  201. {
  202. return;
  203. }
  204. if (this.m_nTime > this.GetBeforeJudge(Dance_Note.Evaluation.BAD))
  205. {
  206. return;
  207. }
  208. bool flag = true;
  209. foreach (Dance_Note.EvalueJadge evalueJadge in this.m_EvalueJudge)
  210. {
  211. if (!flag)
  212. {
  213. bool flag2 = false;
  214. if (this.m_nTime >= 0f)
  215. {
  216. if (evalueJadge.BeforeJudge < this.m_nTime)
  217. {
  218. flag2 = true;
  219. }
  220. }
  221. else if (evalueJadge.AfterJudge < Mathf.Abs(this.m_nTime))
  222. {
  223. flag2 = true;
  224. }
  225. if (flag2)
  226. {
  227. break;
  228. }
  229. evalue = evalueJadge.Evalue;
  230. }
  231. flag = false;
  232. }
  233. }
  234. else if (this.m_MyType == DanceBattle_Mgr.CharaType.Enemy)
  235. {
  236. if (this.m_IsAppealNow)
  237. {
  238. evalue = Dance_Note.Evaluation.PERFECT;
  239. }
  240. else if (UnityEngine.Random.Range(0, 100) >= DanceBattle_Mgr.EnemyData.PushRate)
  241. {
  242. evalue = Dance_Note.Evaluation.MISS;
  243. }
  244. else
  245. {
  246. int num = UnityEngine.Random.Range(0, 100);
  247. int num2 = 0;
  248. bool flag3 = false;
  249. foreach (KeyValuePair<Dance_Note.Evaluation, int> keyValuePair in DanceBattle_Mgr.EnemyData.EvalueRate)
  250. {
  251. int num3 = num2 + keyValuePair.Value;
  252. if (num3 > num && num >= num2)
  253. {
  254. flag3 = true;
  255. evalue = keyValuePair.Key;
  256. break;
  257. }
  258. num2 += keyValuePair.Value;
  259. }
  260. if (!flag3)
  261. {
  262. evalue = Dance_Note.Evaluation.BAD;
  263. }
  264. }
  265. }
  266. this.NoteEnd(evalue);
  267. }
  268. public void Init(Note_Mgr.NoteData data, DanceBattle_Mgr.CharaType setType, int note_count)
  269. {
  270. this.m_MyDotX = data.DotX;
  271. this.m_MyDotY = data.DotY;
  272. this.m_MyType = setType;
  273. this.m_effectType = data.effectType;
  274. if (data.RingSize > 0f)
  275. {
  276. this.m_RingSprite.width = Mathf.FloorToInt((float)this.m_RingSprite.width * data.RingSize);
  277. this.m_RingSprite.height = Mathf.FloorToInt((float)this.m_RingSprite.height * data.RingSize);
  278. }
  279. UIBasicSprite[] componentsInChildren = base.GetComponentsInChildren<UIBasicSprite>();
  280. foreach (UIBasicSprite uibasicSprite in componentsInChildren)
  281. {
  282. uibasicSprite.depth -= (note_count - 1) * componentsInChildren.Count<UIBasicSprite>();
  283. }
  284. }
  285. public static bool IsAutoPlay;
  286. [SerializeField]
  287. [Header("輪がノートと完全に重なるサイズ")]
  288. private Vector2 m_RingFitNote;
  289. [SerializeField]
  290. [Header("判定中の輪の色")]
  291. private Color m_TargetMarkColor = Color.white;
  292. [SerializeField]
  293. private UI2DSprite m_RingSprite;
  294. [SerializeField]
  295. [Header("通常時の輪の色")]
  296. private Color m_Normal_RingColor = Color.white;
  297. [SerializeField]
  298. [Header("アピール時の輪の色")]
  299. private Color m_Appeal_RingColor = Color.white;
  300. [SerializeField]
  301. [Header("判定中のノートの色")]
  302. private Color m_TargetNoteColor = Color.white;
  303. [SerializeField]
  304. [Header("SE名")]
  305. private string m_Sound_Name = "PUSH_SE.ogg";
  306. private float m_RingWidth;
  307. private float m_RingHeight;
  308. private float m_nTime;
  309. private float m_JudgeStartTime;
  310. private float m_JudgeEndtTime;
  311. private float m_WidthSpeed;
  312. private float m_HeightSpeed;
  313. private bool m_IsAppealNow;
  314. [SerializeField]
  315. private float m_ScalingTime = 0.25f;
  316. [SerializeField]
  317. [Header("回転速度")]
  318. private float m_RotateSpeed;
  319. [SerializeField]
  320. private Dance_Note.NoteUIInfo[] m_NoteUIList;
  321. [SerializeField]
  322. [Header("各評定の設定")]
  323. private Dance_Note.EvalueJadge[] m_EvalueJudge = new Dance_Note.EvalueJadge[]
  324. {
  325. new Dance_Note.EvalueJadge(Dance_Note.Evaluation.MISS, 0),
  326. new Dance_Note.EvalueJadge(Dance_Note.Evaluation.BAD, 0),
  327. new Dance_Note.EvalueJadge(Dance_Note.Evaluation.GOOD, 0),
  328. new Dance_Note.EvalueJadge(Dance_Note.Evaluation.GREAT, 0),
  329. new Dance_Note.EvalueJadge(Dance_Note.Evaluation.PERFECT, 0)
  330. };
  331. [SerializeField]
  332. [Header("アピール増加量")]
  333. private int m_AddAppeal = 2;
  334. [SerializeField]
  335. [Header("基底タイミング時間")]
  336. private float m_BaseTiming = 0.5f;
  337. [SerializeField]
  338. private float m_AddTiming = 0.05f;
  339. [SerializeField]
  340. [Header("コンボ一定数毎に出すエフェクト")]
  341. private ParticleSystem[] m_SpecialEffect;
  342. private DanceBattle_Mgr.CharaType m_MyType;
  343. private bool m_IsMySpecial;
  344. private Note_Mgr.EffecctType m_effectType;
  345. public enum Evaluation
  346. {
  347. MISS,
  348. BAD,
  349. GOOD,
  350. GREAT,
  351. PERFECT
  352. }
  353. [Serializable]
  354. private class EvalueJadge
  355. {
  356. public EvalueJadge(Dance_Note.Evaluation evalue, int time)
  357. {
  358. this.Evalue = evalue;
  359. this.BeforeJudge = (float)time;
  360. this.AfterJudge = (float)time;
  361. }
  362. [Header("評価")]
  363. public Dance_Note.Evaluation Evalue;
  364. [Header("判定時間(0秒までの判定時間)")]
  365. public float BeforeJudge;
  366. [Header("判定時間(0秒以降の判定時間)")]
  367. public float AfterJudge;
  368. }
  369. [Serializable]
  370. private class NoteUIInfo
  371. {
  372. public UISprite NoteSprite;
  373. public bool IsRotate;
  374. }
  375. }