DanceBattle_Mgr.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using PlayerStatus;
  6. using UnityEngine;
  7. public class DanceBattle_Mgr : PartsMgrBase
  8. {
  9. private float m_OneVSGaugeValue
  10. {
  11. get
  12. {
  13. return 1f / (float)this.m_GaugeList.Count;
  14. }
  15. }
  16. private float m_GaugeValue
  17. {
  18. get
  19. {
  20. return this.m_GaugeFillAmount;
  21. }
  22. set
  23. {
  24. this.m_GaugeFillAmount = Mathf.Clamp01(value);
  25. for (int i = 0; i < this.m_GaugeList.Count; i++)
  26. {
  27. this.m_GaugeList[i].fillAmount = (this.m_GaugeFillAmount - (float)i * this.m_OneVSGaugeValue) / this.m_OneVSGaugeValue;
  28. if (this.m_GaugeList[i].fillAmount > 0f && this.m_GaugeList[i].fillAmount <= 1f)
  29. {
  30. this.m_EffectUIFit.FitImage = this.m_GaugeList[i];
  31. }
  32. else if (this.m_GaugeFillAmount <= 0f)
  33. {
  34. this.m_EffectUIFit.FitImage = this.m_GaugeList[0];
  35. }
  36. }
  37. }
  38. }
  39. public static DanceEnemyParam EnemyData
  40. {
  41. get
  42. {
  43. return VsDanceDataMgr.Instance.GetCurrentEnemy(RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_Second);
  44. }
  45. }
  46. public static DanceBattle_Mgr Instance { get; private set; }
  47. protected override void Start()
  48. {
  49. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
  50. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS_Skip)
  51. {
  52. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
  53. }
  54. base.Start();
  55. DanceBattle_Mgr.Instance = this;
  56. if (!base.IsActive)
  57. {
  58. base.gameObject.SetActive(false);
  59. return;
  60. }
  61. this.m_PlayerLineArray = this.m_PlayerLineGroup.GetComponentsInChildren<UISprite>();
  62. this.m_EnemyLineArray = this.m_EnemyLineGroup.GetComponentsInChildren<UISprite>();
  63. this.m_EffectUIFit = this.m_GaugeEffect.GetComponent<UI_ImageFitPos>();
  64. ParticleSystem[] componentsInChildren = this.m_GaugeEffect.GetComponentsInChildren<ParticleSystem>();
  65. foreach (ParticleSystem particle in componentsInChildren)
  66. {
  67. RhythmAction_Mgr.Instance.AddParticleSystem(particle);
  68. }
  69. IEnumerator enumerator = this.m_PlayerVSGauge.GetEnumerator();
  70. try
  71. {
  72. while (enumerator.MoveNext())
  73. {
  74. object obj = enumerator.Current;
  75. Transform transform = (Transform)obj;
  76. UISprite component = transform.GetComponent<UISprite>();
  77. if (component)
  78. {
  79. this.m_GaugeList.Add(component);
  80. component.fillAmount = 0f;
  81. }
  82. }
  83. }
  84. finally
  85. {
  86. IDisposable disposable;
  87. if ((disposable = (enumerator as IDisposable)) != null)
  88. {
  89. disposable.Dispose();
  90. }
  91. }
  92. this.m_GaugeSetSpace = Mathf.Abs((this.m_GaugeList[0].transform.position - this.m_GaugeList[1].transform.position).x);
  93. this.m_GaugeValue = 0.5f;
  94. }
  95. private IEnumerator CheckBattleSituation()
  96. {
  97. float appeal_timer = 0f;
  98. for (;;)
  99. {
  100. if (!RhythmAction_Mgr.Instance.IsPause)
  101. {
  102. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) != 0L || Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy) != 0L)
  103. {
  104. this.m_GaugeValue = this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, false);
  105. }
  106. if (RhythmAction_Mgr.Instance.DanceTimer > this.m_CanReversalTime)
  107. {
  108. switch (this.m_SuperiorityChara)
  109. {
  110. case DanceBattle_Mgr.CharaType.Player:
  111. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) < Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
  112. {
  113. this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Enemy;
  114. Appeal_Mgr.Instance.ReversalCutIn(this.m_SuperiorityChara);
  115. }
  116. break;
  117. case DanceBattle_Mgr.CharaType.Enemy:
  118. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) > Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
  119. {
  120. this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Player;
  121. Appeal_Mgr.Instance.ReversalCutIn(this.m_SuperiorityChara);
  122. }
  123. break;
  124. case DanceBattle_Mgr.CharaType.None:
  125. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) < Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
  126. {
  127. this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Enemy;
  128. }
  129. else
  130. {
  131. this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Player;
  132. }
  133. break;
  134. }
  135. if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.BenchMark && Appeal_Mgr.Instance.GetAppealData(DanceBattle_Mgr.CharaType.Enemy).IsCanApplel && !Note_Mgr.Instance.IsNoteEnd(DanceBattle_Mgr.CharaType.Enemy))
  136. {
  137. appeal_timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  138. if (appeal_timer >= this.m_AppealCheckTime)
  139. {
  140. if (UnityEngine.Random.Range(0, 100) < DanceBattle_Mgr.EnemyData.ApeealRate)
  141. {
  142. Appeal_Mgr.Instance.AppealCutIn(DanceBattle_Mgr.CharaType.Enemy);
  143. }
  144. appeal_timer = 0f;
  145. }
  146. }
  147. }
  148. }
  149. yield return null;
  150. }
  151. yield break;
  152. }
  153. private IEnumerator GaugeLineAnime()
  154. {
  155. float timer = 0f;
  156. Vector3 gauge_first = this.m_GaugeList.First<UISprite>().transform.position;
  157. Vector3 gauge_last = this.m_GaugeList.Last<UISprite>().transform.position;
  158. Vector3 start_pos = Vector3.zero;
  159. Vector3 end_pos = Vector3.zero;
  160. Action<UISprite[], Color> line_setting = delegate(UISprite[] line_array, Color line_col)
  161. {
  162. float num = (float)line_array.Count<UISprite>() * this.m_LineRate;
  163. for (int i = 0; i < line_array.Count<UISprite>(); i++)
  164. {
  165. float num2 = Mathf.Max(timer - this.m_LineRate * (float)i, 0f);
  166. float num3 = num2 - (float)Mathf.FloorToInt(num2 / num) * num;
  167. float num4 = Mathf.Clamp01(num3 / num);
  168. if (num4 > 0f && !line_array[i].gameObject.activeSelf)
  169. {
  170. line_array[i].gameObject.SetActive(true);
  171. }
  172. Color color = line_col;
  173. color.a = 1f - num4;
  174. line_array[i].color = color;
  175. line_array[i].transform.position = Vector3.Lerp(start_pos, end_pos, num4);
  176. line_array[i].transform.localScale = Vector3.one * this.m_LineMaxSize * (1f - num4);
  177. }
  178. };
  179. for (;;)
  180. {
  181. if (!RhythmAction_Mgr.Instance.IsPause)
  182. {
  183. this.m_PlayerGlitterEffect.SizeRateX = this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, false);
  184. this.m_EnemyGlitterEffect.SizeRateX = this.GetScoreRate(DanceBattle_Mgr.CharaType.Enemy, false);
  185. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  186. start_pos = this.m_PlayerLineGroup.position;
  187. float d = Mathf.Min(this.m_GaugeSetSpace * (float)(this.m_PlayerLineArray.Count<UISprite>() - 1), start_pos.x - gauge_first.x);
  188. end_pos = start_pos + Vector3.left * d;
  189. line_setting(this.m_PlayerLineArray, Color.green);
  190. start_pos = this.m_EnemyLineGroup.position;
  191. d = Mathf.Min(this.m_GaugeSetSpace * (float)(this.m_EnemyLineArray.Count<UISprite>() - 1), gauge_last.x - start_pos.x);
  192. end_pos = start_pos + Vector3.right * d;
  193. line_setting(this.m_EnemyLineArray, Color.magenta);
  194. }
  195. yield return null;
  196. }
  197. yield break;
  198. }
  199. public override void StartAction()
  200. {
  201. base.StartCoroutine(this.CheckBattleSituation());
  202. base.StartCoroutine(this.GaugeLineAnime());
  203. }
  204. public override void EndAction()
  205. {
  206. RhythmAction_Mgr.DanceState nowState = RhythmAction_Mgr.NowState;
  207. if (nowState != RhythmAction_Mgr.DanceState.Dance_First)
  208. {
  209. if (nowState == RhythmAction_Mgr.DanceState.Dance_Second)
  210. {
  211. Result_Display.SetResultData("BattleCount", "2nd", Result_Display.ResultType.Image);
  212. if (this.IsWin() && RhythmAction_Mgr.Instance.IsTakeEnd)
  213. {
  214. Result_Display.SetResultData("BattleResult", "WIN", Result_Display.ResultType.Image);
  215. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
  216. }
  217. else
  218. {
  219. Result_Display.SetResultData("BattleResult", "LOSE", Result_Display.ResultType.Image);
  220. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
  221. }
  222. }
  223. }
  224. else
  225. {
  226. Result_Display.SetResultData("BattleCount", "1st", Result_Display.ResultType.Image);
  227. if (this.IsWin() && RhythmAction_Mgr.Instance.IsTakeEnd)
  228. {
  229. Result_Display.SetResultData("BattleResult", "WIN", Result_Display.ResultType.Image);
  230. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
  231. }
  232. else
  233. {
  234. Result_Display.SetResultData("BattleResult", "LOSE", Result_Display.ResultType.Image);
  235. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
  236. }
  237. }
  238. }
  239. public float GetScoreRate(DanceBattle_Mgr.CharaType chara_type, bool is_percentage = false)
  240. {
  241. float num = (float)Score_Mgr.Instance.GetScore(chara_type) / (float)(Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) + Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy));
  242. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) + Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy) == 0L)
  243. {
  244. num = 0.5f;
  245. }
  246. if (is_percentage)
  247. {
  248. num *= 100f;
  249. }
  250. return num;
  251. }
  252. public bool IsWin()
  253. {
  254. return base.IsActive && Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) >= Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy);
  255. }
  256. public bool IsEven()
  257. {
  258. return base.IsActive && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) >= this.m_MinAntagonism && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) <= this.m_MaxAntagonism;
  259. }
  260. public static DanceBattle_Mgr.CharaType GetOpponentType(DanceBattle_Mgr.CharaType chara_type)
  261. {
  262. if (chara_type == DanceBattle_Mgr.CharaType.Player)
  263. {
  264. return DanceBattle_Mgr.CharaType.Enemy;
  265. }
  266. return DanceBattle_Mgr.CharaType.Player;
  267. }
  268. public static bool IsAllBattleWin()
  269. {
  270. if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS)
  271. {
  272. return false;
  273. }
  274. Status status = GameMain.Instance.CharacterMgr.status;
  275. return status.GetFlag("ダンス勝敗") == 1 && status.GetFlag("バトル回数") == 2;
  276. }
  277. [SerializeField]
  278. private float m_MinAntagonism = 40f;
  279. [SerializeField]
  280. private float m_MaxAntagonism = 60f;
  281. [SerializeField]
  282. [Header("アピールを行うかの抽選を行う時間")]
  283. private float m_AppealCheckTime = 5f;
  284. [SerializeField]
  285. [Header("逆転カットイン可能になる時間")]
  286. private float m_CanReversalTime = 15f;
  287. [SerializeField]
  288. [Header("プレイヤーのVSゲージの親")]
  289. private Transform m_PlayerVSGauge;
  290. private List<UISprite> m_GaugeList = new List<UISprite>();
  291. private float m_GaugeFillAmount;
  292. [SerializeField]
  293. private GameObject m_GaugeEffect;
  294. [SerializeField]
  295. [Header("ライン発生間隔")]
  296. private float m_LineRate = 0.3f;
  297. [SerializeField]
  298. private float m_LineMaxSize = 1.25f;
  299. [SerializeField]
  300. private Transform m_PlayerLineGroup;
  301. [SerializeField]
  302. private Transform m_EnemyLineGroup;
  303. [Header("ゲージ上に粒子がかかるようなエフェクト")]
  304. [SerializeField]
  305. private UI_ParticleImageFit m_PlayerGlitterEffect;
  306. [SerializeField]
  307. private UI_ParticleImageFit m_EnemyGlitterEffect;
  308. private UISprite[] m_PlayerLineArray;
  309. private UISprite[] m_EnemyLineArray;
  310. private UI_ImageFitPos m_EffectUIFit;
  311. private DanceBattle_Mgr.CharaType m_SuperiorityChara = DanceBattle_Mgr.CharaType.None;
  312. private float m_GaugeSetSpace;
  313. private bool m_readEnd;
  314. public enum CharaType
  315. {
  316. Player,
  317. Enemy,
  318. None
  319. }
  320. }