DanceBattle_Mgr.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. bool flag;
  207. if (!VsDanceDataMgr.Instance.CurrentSetting.isSpecifiedVictoryState)
  208. {
  209. flag = (this.IsWin() && RhythmAction_Mgr.Instance.IsTakeEnd);
  210. }
  211. else
  212. {
  213. flag = (VsDanceDataMgr.Instance.CurrentSetting.specifyVictoryState == VsDanceDataMgr.ForcedVictory.ForceWin);
  214. }
  215. if (flag)
  216. {
  217. Result_Display.SetResultData("BattleResult", "WIN", Result_Display.ResultType.Image);
  218. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
  219. }
  220. else
  221. {
  222. Result_Display.SetResultData("BattleResult", "LOSE", Result_Display.ResultType.Image);
  223. GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
  224. }
  225. RhythmAction_Mgr.DanceState nowState = RhythmAction_Mgr.NowState;
  226. if (nowState != RhythmAction_Mgr.DanceState.Dance_First)
  227. {
  228. if (nowState == RhythmAction_Mgr.DanceState.Dance_Second)
  229. {
  230. Result_Display.SetResultData("BattleCount", "2nd", Result_Display.ResultType.Image);
  231. }
  232. }
  233. else
  234. {
  235. Result_Display.SetResultData("BattleCount", "1st", Result_Display.ResultType.Image);
  236. }
  237. }
  238. public float GetScoreRate(DanceBattle_Mgr.CharaType chara_type, bool is_percentage = false)
  239. {
  240. 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));
  241. if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) + Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy) == 0L)
  242. {
  243. num = 0.5f;
  244. }
  245. if (is_percentage)
  246. {
  247. num *= 100f;
  248. }
  249. return num;
  250. }
  251. public bool IsWin()
  252. {
  253. return base.IsActive && Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) >= Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy);
  254. }
  255. public bool IsEven()
  256. {
  257. return base.IsActive && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) >= this.m_MinAntagonism && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) <= this.m_MaxAntagonism;
  258. }
  259. public static DanceBattle_Mgr.CharaType GetOpponentType(DanceBattle_Mgr.CharaType chara_type)
  260. {
  261. if (chara_type == DanceBattle_Mgr.CharaType.Player)
  262. {
  263. return DanceBattle_Mgr.CharaType.Enemy;
  264. }
  265. return DanceBattle_Mgr.CharaType.Player;
  266. }
  267. public static bool IsAllBattleWin()
  268. {
  269. if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS)
  270. {
  271. return false;
  272. }
  273. Status status = GameMain.Instance.CharacterMgr.status;
  274. return status.GetFlag("ダンス勝敗") == 1 && status.GetFlag("バトル回数") == 2;
  275. }
  276. [SerializeField]
  277. private float m_MinAntagonism = 40f;
  278. [SerializeField]
  279. private float m_MaxAntagonism = 60f;
  280. [SerializeField]
  281. [Header("アピールを行うかの抽選を行う時間")]
  282. private float m_AppealCheckTime = 5f;
  283. [SerializeField]
  284. [Header("逆転カットイン可能になる時間")]
  285. private float m_CanReversalTime = 15f;
  286. [SerializeField]
  287. [Header("プレイヤーのVSゲージの親")]
  288. private Transform m_PlayerVSGauge;
  289. private List<UISprite> m_GaugeList = new List<UISprite>();
  290. private float m_GaugeFillAmount;
  291. [SerializeField]
  292. private GameObject m_GaugeEffect;
  293. [SerializeField]
  294. [Header("ライン発生間隔")]
  295. private float m_LineRate = 0.3f;
  296. [SerializeField]
  297. private float m_LineMaxSize = 1.25f;
  298. [SerializeField]
  299. private Transform m_PlayerLineGroup;
  300. [SerializeField]
  301. private Transform m_EnemyLineGroup;
  302. [Header("ゲージ上に粒子がかかるようなエフェクト")]
  303. [SerializeField]
  304. private UI_ParticleImageFit m_PlayerGlitterEffect;
  305. [SerializeField]
  306. private UI_ParticleImageFit m_EnemyGlitterEffect;
  307. private UISprite[] m_PlayerLineArray;
  308. private UISprite[] m_EnemyLineArray;
  309. private UI_ImageFitPos m_EffectUIFit;
  310. private DanceBattle_Mgr.CharaType m_SuperiorityChara = DanceBattle_Mgr.CharaType.None;
  311. private float m_GaugeSetSpace;
  312. private bool m_readEnd;
  313. public enum CharaType
  314. {
  315. Player,
  316. Enemy,
  317. None
  318. }
  319. }