123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using PlayerStatus;
- using UnityEngine;
- public class DanceBattle_Mgr : PartsMgrBase
- {
- private float m_OneVSGaugeValue
- {
- get
- {
- return 1f / (float)this.m_GaugeList.Count;
- }
- }
- private float m_GaugeValue
- {
- get
- {
- return this.m_GaugeFillAmount;
- }
- set
- {
- this.m_GaugeFillAmount = Mathf.Clamp01(value);
- for (int i = 0; i < this.m_GaugeList.Count; i++)
- {
- this.m_GaugeList[i].fillAmount = (this.m_GaugeFillAmount - (float)i * this.m_OneVSGaugeValue) / this.m_OneVSGaugeValue;
- if (this.m_GaugeList[i].fillAmount > 0f && this.m_GaugeList[i].fillAmount <= 1f)
- {
- this.m_EffectUIFit.FitImage = this.m_GaugeList[i];
- }
- else if (this.m_GaugeFillAmount <= 0f)
- {
- this.m_EffectUIFit.FitImage = this.m_GaugeList[0];
- }
- }
- }
- }
- public static DanceEnemyParam EnemyData
- {
- get
- {
- return VsDanceDataMgr.Instance.GetCurrentEnemy(RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_Second);
- }
- }
- public static DanceBattle_Mgr Instance { get; private set; }
- protected override void Start()
- {
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
- if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS_Skip)
- {
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
- }
- base.Start();
- DanceBattle_Mgr.Instance = this;
- if (!base.IsActive)
- {
- base.gameObject.SetActive(false);
- return;
- }
- this.m_PlayerLineArray = this.m_PlayerLineGroup.GetComponentsInChildren<UISprite>();
- this.m_EnemyLineArray = this.m_EnemyLineGroup.GetComponentsInChildren<UISprite>();
- this.m_EffectUIFit = this.m_GaugeEffect.GetComponent<UI_ImageFitPos>();
- ParticleSystem[] componentsInChildren = this.m_GaugeEffect.GetComponentsInChildren<ParticleSystem>();
- foreach (ParticleSystem particle in componentsInChildren)
- {
- RhythmAction_Mgr.Instance.AddParticleSystem(particle);
- }
- IEnumerator enumerator = this.m_PlayerVSGauge.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- UISprite component = transform.GetComponent<UISprite>();
- if (component)
- {
- this.m_GaugeList.Add(component);
- component.fillAmount = 0f;
- }
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- this.m_GaugeSetSpace = Mathf.Abs((this.m_GaugeList[0].transform.position - this.m_GaugeList[1].transform.position).x);
- this.m_GaugeValue = 0.5f;
- }
- private IEnumerator CheckBattleSituation()
- {
- float appeal_timer = 0f;
- for (;;)
- {
- if (!RhythmAction_Mgr.Instance.IsPause)
- {
- if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) != 0L || Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy) != 0L)
- {
- this.m_GaugeValue = this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, false);
- }
- if (RhythmAction_Mgr.Instance.DanceTimer > this.m_CanReversalTime)
- {
- switch (this.m_SuperiorityChara)
- {
- case DanceBattle_Mgr.CharaType.Player:
- if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) < Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
- {
- this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Enemy;
- Appeal_Mgr.Instance.ReversalCutIn(this.m_SuperiorityChara);
- }
- break;
- case DanceBattle_Mgr.CharaType.Enemy:
- if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) > Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
- {
- this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Player;
- Appeal_Mgr.Instance.ReversalCutIn(this.m_SuperiorityChara);
- }
- break;
- case DanceBattle_Mgr.CharaType.None:
- if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) < Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy))
- {
- this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Enemy;
- }
- else
- {
- this.m_SuperiorityChara = DanceBattle_Mgr.CharaType.Player;
- }
- break;
- }
- 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))
- {
- appeal_timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
- if (appeal_timer >= this.m_AppealCheckTime)
- {
- if (UnityEngine.Random.Range(0, 100) < DanceBattle_Mgr.EnemyData.ApeealRate)
- {
- Appeal_Mgr.Instance.AppealCutIn(DanceBattle_Mgr.CharaType.Enemy);
- }
- appeal_timer = 0f;
- }
- }
- }
- }
- yield return null;
- }
- yield break;
- }
- private IEnumerator GaugeLineAnime()
- {
- float timer = 0f;
- Vector3 gauge_first = this.m_GaugeList.First<UISprite>().transform.position;
- Vector3 gauge_last = this.m_GaugeList.Last<UISprite>().transform.position;
- Vector3 start_pos = Vector3.zero;
- Vector3 end_pos = Vector3.zero;
- Action<UISprite[], Color> line_setting = delegate(UISprite[] line_array, Color line_col)
- {
- float num = (float)line_array.Count<UISprite>() * this.m_LineRate;
- for (int i = 0; i < line_array.Count<UISprite>(); i++)
- {
- float num2 = Mathf.Max(timer - this.m_LineRate * (float)i, 0f);
- float num3 = num2 - (float)Mathf.FloorToInt(num2 / num) * num;
- float num4 = Mathf.Clamp01(num3 / num);
- if (num4 > 0f && !line_array[i].gameObject.activeSelf)
- {
- line_array[i].gameObject.SetActive(true);
- }
- Color color = line_col;
- color.a = 1f - num4;
- line_array[i].color = color;
- line_array[i].transform.position = Vector3.Lerp(start_pos, end_pos, num4);
- line_array[i].transform.localScale = Vector3.one * this.m_LineMaxSize * (1f - num4);
- }
- };
- for (;;)
- {
- if (!RhythmAction_Mgr.Instance.IsPause)
- {
- this.m_PlayerGlitterEffect.SizeRateX = this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, false);
- this.m_EnemyGlitterEffect.SizeRateX = this.GetScoreRate(DanceBattle_Mgr.CharaType.Enemy, false);
- timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
- start_pos = this.m_PlayerLineGroup.position;
- float d = Mathf.Min(this.m_GaugeSetSpace * (float)(this.m_PlayerLineArray.Count<UISprite>() - 1), start_pos.x - gauge_first.x);
- end_pos = start_pos + Vector3.left * d;
- line_setting(this.m_PlayerLineArray, Color.green);
- start_pos = this.m_EnemyLineGroup.position;
- d = Mathf.Min(this.m_GaugeSetSpace * (float)(this.m_EnemyLineArray.Count<UISprite>() - 1), gauge_last.x - start_pos.x);
- end_pos = start_pos + Vector3.right * d;
- line_setting(this.m_EnemyLineArray, Color.magenta);
- }
- yield return null;
- }
- yield break;
- }
- public override void StartAction()
- {
- base.StartCoroutine(this.CheckBattleSituation());
- base.StartCoroutine(this.GaugeLineAnime());
- }
- public override void EndAction()
- {
- RhythmAction_Mgr.DanceState nowState = RhythmAction_Mgr.NowState;
- if (nowState != RhythmAction_Mgr.DanceState.Dance_First)
- {
- if (nowState == RhythmAction_Mgr.DanceState.Dance_Second)
- {
- Result_Display.SetResultData("BattleCount", "2nd", Result_Display.ResultType.Image);
- if (this.IsWin() && RhythmAction_Mgr.Instance.IsTakeEnd)
- {
- Result_Display.SetResultData("BattleResult", "WIN", Result_Display.ResultType.Image);
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
- }
- else
- {
- Result_Display.SetResultData("BattleResult", "LOSE", Result_Display.ResultType.Image);
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
- }
- }
- }
- else
- {
- Result_Display.SetResultData("BattleCount", "1st", Result_Display.ResultType.Image);
- if (this.IsWin() && RhythmAction_Mgr.Instance.IsTakeEnd)
- {
- Result_Display.SetResultData("BattleResult", "WIN", Result_Display.ResultType.Image);
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 1);
- }
- else
- {
- Result_Display.SetResultData("BattleResult", "LOSE", Result_Display.ResultType.Image);
- GameMain.Instance.CharacterMgr.status.SetFlag("ダンス勝敗", 0);
- }
- }
- }
- public float GetScoreRate(DanceBattle_Mgr.CharaType chara_type, bool is_percentage = false)
- {
- 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));
- if (Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) + Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy) == 0L)
- {
- num = 0.5f;
- }
- if (is_percentage)
- {
- num *= 100f;
- }
- return num;
- }
- public bool IsWin()
- {
- return base.IsActive && Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Player) >= Score_Mgr.Instance.GetScore(DanceBattle_Mgr.CharaType.Enemy);
- }
- public bool IsEven()
- {
- return base.IsActive && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) >= this.m_MinAntagonism && this.GetScoreRate(DanceBattle_Mgr.CharaType.Player, true) <= this.m_MaxAntagonism;
- }
- public static DanceBattle_Mgr.CharaType GetOpponentType(DanceBattle_Mgr.CharaType chara_type)
- {
- if (chara_type == DanceBattle_Mgr.CharaType.Player)
- {
- return DanceBattle_Mgr.CharaType.Enemy;
- }
- return DanceBattle_Mgr.CharaType.Player;
- }
- public static bool IsAllBattleWin()
- {
- if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS)
- {
- return false;
- }
- Status status = GameMain.Instance.CharacterMgr.status;
- return status.GetFlag("ダンス勝敗") == 1 && status.GetFlag("バトル回数") == 2;
- }
- [SerializeField]
- private float m_MinAntagonism = 40f;
- [SerializeField]
- private float m_MaxAntagonism = 60f;
- [SerializeField]
- [Header("アピールを行うかの抽選を行う時間")]
- private float m_AppealCheckTime = 5f;
- [SerializeField]
- [Header("逆転カットイン可能になる時間")]
- private float m_CanReversalTime = 15f;
- [SerializeField]
- [Header("プレイヤーのVSゲージの親")]
- private Transform m_PlayerVSGauge;
- private List<UISprite> m_GaugeList = new List<UISprite>();
- private float m_GaugeFillAmount;
- [SerializeField]
- private GameObject m_GaugeEffect;
- [SerializeField]
- [Header("ライン発生間隔")]
- private float m_LineRate = 0.3f;
- [SerializeField]
- private float m_LineMaxSize = 1.25f;
- [SerializeField]
- private Transform m_PlayerLineGroup;
- [SerializeField]
- private Transform m_EnemyLineGroup;
- [Header("ゲージ上に粒子がかかるようなエフェクト")]
- [SerializeField]
- private UI_ParticleImageFit m_PlayerGlitterEffect;
- [SerializeField]
- private UI_ParticleImageFit m_EnemyGlitterEffect;
- private UISprite[] m_PlayerLineArray;
- private UISprite[] m_EnemyLineArray;
- private UI_ImageFitPos m_EffectUIFit;
- private DanceBattle_Mgr.CharaType m_SuperiorityChara = DanceBattle_Mgr.CharaType.None;
- private float m_GaugeSetSpace;
- private bool m_readEnd;
- public enum CharaType
- {
- Player,
- Enemy,
- None
- }
- }
|