using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Appeal_Mgr : PartsMgrBase
{
	public int AppealComboCount
	{
		get
		{
			return this.m_AppealComboCount;
		}
	}

	private float m_CutInTotal
	{
		get
		{
			return this.m_CutInTime + this.m_FadeStartTime + this.m_FadeOutTime;
		}
	}

	public static Appeal_Mgr Instance
	{
		get
		{
			return Appeal_Mgr.m_Instance;
		}
	}

	protected override void Start()
	{
		Appeal_Mgr.m_Instance = this;
		base.Start();
		this.m_ScreenEffect.SetActive(false);
		this.m_AppealCutInPanel.SetActive(false);
		this.m_RevarsalCutInPanel.SetActive(false);
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS_Skip)
		{
			ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Player);
			ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Enemy);
			if (RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_First)
			{
				this.m_VsSkip1st = true;
				ShootCutInTex.SetEnemyCutInTex(true);
			}
		}
		if (!base.IsActive)
		{
			base.gameObject.SetActive(false);
			return;
		}
		this.m_EffectBase.enabled = (GameMain.Instance.VRMode && DanceSetting.Settings.CutInGrade != Appeal_Mgr.CutInGrade.None);
		RhythmAction_Mgr.Instance.Search_AllEffect(this.m_ScreenEffect.transform, false);
		this.m_CharaAppealList.Add(DanceBattle_Mgr.CharaType.Player, new CharaAppealData());
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			this.m_CharaAppealList.Add(DanceBattle_Mgr.CharaType.Enemy, new CharaAppealData());
		}
	}

	private void OnDestroy()
	{
		if (this.m_VsSkip1st)
		{
			this.m_NotTexClear = (RhythmAction_Mgr.Instance.IsTakeEnd || RhythmAction_Mgr.Instance.IsDanceSkip);
		}
		if (!this.m_NotTexClear)
		{
			ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Player);
			ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Enemy);
		}
	}

	private void AppealDataInit(DanceBattle_Mgr.CharaType chara_type)
	{
		if (!this.m_CharaAppealList.ContainsKey(chara_type))
		{
			this.m_CharaAppealList.Add(chara_type, new CharaAppealData());
		}
		CharaAppealData appeal_data = this.m_CharaAppealList[chara_type];
		foreach (Appeal_Mgr.AppealEfectData appealEfectData in this.m_EffectList)
		{
			if (appealEfectData.Charatype == chara_type)
			{
				appeal_data.CutInType = appealEfectData.CutInType;
				appeal_data.AppealGaugeEffect = appealEfectData.GaugeEffect;
				appeal_data.ReversalCutIn = appealEfectData.ReversalCutInTex;
				appeal_data.GaugeGroup = appealEfectData.GaugeGroup;
				appeal_data.AppealFlashGauge = appealEfectData.AppealFlashGauge;
				appeal_data.CoolTimeGauge = appealEfectData.CoolTimeGauge;
				appeal_data.AppelCoolFlash = appealEfectData.AppelCoolFlash;
				appeal_data.AudioSE = appealEfectData.CutinAudio;
				appeal_data.ReversalObj = appealEfectData.ReversalObj;
				appeal_data.TimerGauge = appealEfectData.TimerGauge;
				appeal_data.SweatEffect = appealEfectData.SweatEffect;
				appeal_data.AuraEffect = appealEfectData.AuraEffect;
			}
		}
		appeal_data.AudioSE.clip = Resources.Load<AudioClip>("SceneDance/Rhythm_Action/Sound/" + this.m_CutInSE);
		appeal_data.AudioSE.volume = this.m_CutinSeVol;
		RhythmAction_Mgr.Instance.AddAudioMgr(appeal_data.AudioSE);
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			appeal_data.ReversalCutIn.sprite2D = ShootCutInTex.GetCutInTex(chara_type, ShootCutInTex.CutInName.逆転);
		}
		GameObject original;
		GameObject original2;
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			original = Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/AppealCutIn/" + DanceMain.SelectDanceData.AppealCutinName);
			original2 = Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/ReversalCutIn/" + DanceMain.SelectDanceData.ReversalCutinName);
		}
		else
		{
			original = DanceBattle_Mgr.EnemyData.AppealCutInEffect;
			original2 = DanceBattle_Mgr.EnemyData.ReversalCutInEffect;
		}
		appeal_data.AppealCutInEffect = UnityEngine.Object.Instantiate<GameObject>(original);
		appeal_data.ReversalCutInEffect = UnityEngine.Object.Instantiate<GameObject>(original2);
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			appeal_data.AppealCutInpanel = this.m_BackPanel;
			appeal_data.AppealCutIn = this.m_BackCutInSprite;
		}
		else
		{
			appeal_data.AppealCutInpanel = this.m_FrontPanel;
			appeal_data.AppealCutIn = this.m_FrontCutInSprite;
		}
		this.Setting_AllParticle(appeal_data.AppealCutInEffect.transform, appeal_data);
		appeal_data.AppealCutInpanel.SetActive(false);
		IEnumerator enumerator2 = appeal_data.ReversalCutInEffect.transform.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				object obj = enumerator2.Current;
				Transform transform = (Transform)obj;
				RhythmAction_Mgr.Instance.AddParticleSystem(transform.GetComponent<ParticleSystem>());
				UI_ParticleImageFit component = transform.GetComponent<UI_ParticleImageFit>();
				if (component)
				{
					component.FitImage = appeal_data.ReversalCutIn;
				}
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator2 as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		appeal_data.ReversalCutInEffect.transform.SetParent(appeal_data.ReversalCutIn.transform, false);
		appeal_data.ReversalObj.SetActive(false);
		for (int i = 0; i < appeal_data.GaugeGroup.childCount; i++)
		{
			UISprite component2 = appeal_data.GaugeGroup.GetChild(i).GetComponent<UISprite>();
			if (component2)
			{
				this.m_GaugeHeight = (float)component2.height;
				if ((i + 1) * 200 <= appeal_data.AppealMax)
				{
					appeal_data.AllGaugeList.Add(component2);
					component2.fillAmount = 0f;
				}
				else
				{
					component2.color = this.m_NotChargeColor;
					component2.fillAmount = (float)(appeal_data.AppealMax % ((i + 1) * 200)) / 200f;
				}
			}
		}
		RhythmAction_Mgr.Instance.AddParticleSystem(appeal_data.AppealGaugeEffect.GetComponent<ParticleSystem>());
		appeal_data.AppealGaugeEffect.SetActive(false);
		appeal_data.TimerGauge.gameObject.SetActive(false);
		RhythmAction_Mgr.Instance.AddParticleSystem(appeal_data.AuraEffect.GetComponent<ParticleSystem>());
		RhythmAction_Mgr.Instance.AddParticleSystem(appeal_data.SweatEffect.GetComponent<ParticleSystem>());
		appeal_data.AuraEffect.SetActive(false);
		appeal_data.SweatEffect.SetActive(false);
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			string str = "csv_rhythm_action/cutin_voice";
			this.SetCutInVoice(str + ".nei");
			if (string.IsNullOrEmpty(this.GetPlayerData().strJobVoice))
			{
				for (int j = 0; j < GameUty.PathList.Count; j++)
				{
					this.SetCutInVoice(str + "_" + GameUty.PathList[j] + ".nei");
					if (!string.IsNullOrEmpty(this.GetPlayerData().strJobVoice))
					{
						break;
					}
				}
			}
		}
		else
		{
			appeal_data.strPersonalVoice1 = DanceBattle_Mgr.EnemyData.PersonalVoice1;
			appeal_data.strPersonalVoice2 = DanceBattle_Mgr.EnemyData.PersonalVoice2;
			appeal_data.strJobVoice = DanceBattle_Mgr.EnemyData.JobVoice;
			appeal_data.strReversalVoice = DanceBattle_Mgr.EnemyData.ReversalVoice;
		}
		Func<string, AudioSourceMgr> func = delegate(string name)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(GameObject.Find("AudioSe(Clone)"));
			AudioSourceMgr component3 = gameObject.GetComponent<AudioSourceMgr>();
			component3.name = name;
			component3.Init(AudioSourceMgr.Type.Se, false, GameMain.Instance.SoundMgr, appeal_data.AudioSE.transform.parent);
			component3.audiosource.spatialBlend = 0f;
			RhythmAction_Mgr.Instance.AddAudioMgr(component3.audiosource);
			return component3;
		};
		appeal_data.AudioVoice = func("CutinVoice");
		appeal_data.ReversalVoice = func("ReversalVoice");
	}

	private void SetCutInVoice(string csv_name)
	{
		if (!GameUty.FileSystem.IsExistentFile(csv_name))
		{
			return;
		}
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen(csv_name))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, csv_name + "\nopen failed.");
				for (int i = 0; i < csvParser.max_cell_y; i++)
				{
					if (!(RhythmAction_Mgr.Instance.UserMaid.status.personal.uniqueName != csvParser.GetCellAsString(0, i)))
					{
						for (int j = 0; j < csvParser.max_cell_x; j++)
						{
							switch (j)
							{
							case 1:
								this.GetPlayerData().strPersonalVoice1 = csvParser.GetCellAsString(j, i);
								break;
							case 2:
								this.GetPlayerData().strPersonalVoice2 = csvParser.GetCellAsString(j, i);
								break;
							case 3:
								this.GetPlayerData().strJobVoice = csvParser.GetCellAsString(j, i);
								break;
							case 4:
								this.GetPlayerData().strReversalVoice = csvParser.GetCellAsString(j, i);
								break;
							}
						}
						break;
					}
				}
			}
		}
	}

	private void Setting_AllParticle(Transform parent, CharaAppealData appeal_data)
	{
		IEnumerator enumerator = parent.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform transform = (Transform)obj;
				bool flag = DanceSetting.Settings.CutInGrade == Appeal_Mgr.CutInGrade.High;
				ParticleSystem component = transform.GetComponent<ParticleSystem>();
				UI_ImageFitPos component2 = transform.GetComponent<UI_ImageFitPos>();
				UI_ParticleImageFit component3 = transform.GetComponent<UI_ParticleImageFit>();
				ParticleSystemRenderer component4 = transform.GetComponent<ParticleSystemRenderer>();
				transform.gameObject.SetActive(flag);
				if (component2)
				{
					component2.FitImage = this.m_EffectBase;
				}
				if (component3)
				{
					component3.FitImage = this.m_EffectBase;
				}
				if (flag)
				{
					if (component)
					{
						appeal_data.AllCutInEffect.Add(component);
						RhythmAction_Mgr.Instance.AddParticleSystem(component);
					}
					if (component4)
					{
						appeal_data.EffectRender.Add(component4);
						appeal_data.m_EffectRenderOrder.Add(component4.sortingOrder);
					}
				}
				this.Setting_AllParticle(transform, appeal_data);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}

	private IEnumerator CutInOperate()
	{
		int appeal_count = 1;
		for (;;)
		{
			this.m_AppealcountLabel.text = string.Format("{0:00}", this.GetPlayerData().AppealValue / 200);
			if (!RhythmAction_Mgr.Instance.IsPause && !GameMain.Instance.MainCamera.IsFadeOut() && !RhythmAction_Mgr.Instance.IsReadyNow && this.m_GaugeChargeEnd)
			{
				if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
				{
					if (RhythmAction_Mgr.Instance.DanceTimer >= RhythmAction_Mgr.Instance.TakeTime / 7f * (float)appeal_count && appeal_count <= 6)
					{
						appeal_count++;
						if (appeal_count % 2 == 0)
						{
							this.AppealCutIn(DanceBattle_Mgr.CharaType.Player);
							Voltage_Mgr.Instance.AddVoltage();
						}
						else
						{
							this.AppealCutIn(DanceBattle_Mgr.CharaType.Enemy);
						}
					}
				}
				else
				{
					bool flag = Input.GetKeyDown(KeyCode.Space);
					if (GameMain.Instance.VRMode && !GameMain.Instance.OvrMgr.OvrCamera.IsNoHandController)
					{
						AVRControllerButtons controller_buttons = GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller_buttons;
						AVRControllerButtons controller_buttons2 = GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller_buttons;
						AVRController controller = GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller;
						AVRController controller2 = GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller;
						flag |= ((controller_buttons.GetPressDown(AVRControllerButtons.BTN.TRIGGER) && controller.HandDanceMode) || (controller_buttons2.GetPressDown(AVRControllerButtons.BTN.TRIGGER) && controller2.HandDanceMode));
					}
					else
					{
						flag |= NInput.GetMouseButtonDown(1);
					}
					if (flag && this.GetAppealData(DanceBattle_Mgr.CharaType.Player).IsCanApplel)
					{
						this.AppealCutIn(DanceBattle_Mgr.CharaType.Player);
						Voltage_Mgr.Instance.AddVoltage();
					}
				}
			}
			yield return null;
		}
		yield break;
	}

	private void SetCutInSprite(DanceBattle_Mgr.CharaType chara_type)
	{
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
		{
			this.SetCutInChallenge(chara_type);
		}
		else
		{
			this.SetCutInVS(chara_type);
		}
	}

	private void SetCutInChallenge(DanceBattle_Mgr.CharaType chara_type)
	{
		CharaAppealData charaAppealData = this.m_CharaAppealList[chara_type];
		charaAppealData.AppealCutIn.sprite2D = ShootCutInTex.GetCutInTex(chara_type, this.m_NowCutIn);
		ShootCutInTex.CutInName nowCutIn = ShootCutInTex.CutInName.ジョブ固有;
		switch (this.m_NowCutIn)
		{
		case ShootCutInTex.CutInName.性格固有1:
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strPersonalVoice1, 0f, false, false);
			nowCutIn = ShootCutInTex.CutInName.性格固有2;
			break;
		case ShootCutInTex.CutInName.性格固有2:
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strPersonalVoice2, 0f, false, false);
			nowCutIn = ShootCutInTex.CutInName.ジョブ固有;
			break;
		case ShootCutInTex.CutInName.ジョブ固有:
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strJobVoice, 0f, false, false);
			nowCutIn = ShootCutInTex.CutInName.性格固有1;
			break;
		}
		this.m_NowCutIn = nowCutIn;
	}

	private void SetCutInVS(DanceBattle_Mgr.CharaType chara_type)
	{
		CharaAppealData charaAppealData = this.m_CharaAppealList[chara_type];
		DanceBattle_Mgr.CharaType opponentType = DanceBattle_Mgr.GetOpponentType(chara_type);
		float num = Mathf.Abs(DanceBattle_Mgr.Instance.GetScoreRate(chara_type, true) - DanceBattle_Mgr.Instance.GetScoreRate(opponentType, true));
		Sprite cutInTex;
		if (num <= 20f)
		{
			cutInTex = ShootCutInTex.GetCutInTex(chara_type, ShootCutInTex.CutInName.ジョブ固有);
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strJobVoice, 0f, false, false);
		}
		else if (Score_Mgr.Instance.GetScore(chara_type) < Score_Mgr.Instance.GetScore(opponentType))
		{
			cutInTex = ShootCutInTex.GetCutInTex(chara_type, ShootCutInTex.CutInName.性格固有1);
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strPersonalVoice1, 0f, false, false);
		}
		else
		{
			cutInTex = ShootCutInTex.GetCutInTex(chara_type, ShootCutInTex.CutInName.性格固有2);
			charaAppealData.AudioVoice.LoadPlay(charaAppealData.strPersonalVoice2, 0f, false, false);
		}
		charaAppealData.AppealCutIn.sprite2D = cutInTex;
	}

	private IEnumerator CutIn(DanceBattle_Mgr.CharaType chara_type)
	{
		float timer = 0f;
		CharaAppealData appeal_data = this.m_CharaAppealList[chara_type];
		DanceBattle_Mgr.CharaType oppnent_type = DanceBattle_Mgr.GetOpponentType(chara_type);
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			this.m_ScreenEffect.SetActive(DanceSetting.Settings.CutInGrade == Appeal_Mgr.CutInGrade.High);
		}
		appeal_data.TimerGauge.fillAmount = 1f;
		appeal_data.TimerGauge.gameObject.SetActive(true);
		appeal_data.AudioSE.Play();
		bool exist_cutin = this.m_AppealCutInPanel.activeSelf;
		if (!this.m_AppealCutInPanel.activeSelf)
		{
			this.m_AppealCutInPanel.SetActive(true);
		}
		if (this.m_CharaAppealList.ContainsKey(DanceBattle_Mgr.CharaType.Enemy))
		{
			if (this.GetAppealData(oppnent_type).IsCutInNow)
			{
				appeal_data.AppealCutIn = this.m_FrontCutInSprite;
				appeal_data.AppealCutInpanel = this.m_FrontPanel;
				appeal_data.CutInEffectOrder = 1;
			}
			else
			{
				appeal_data.AppealCutIn = this.m_BackCutInSprite;
				appeal_data.AppealCutInpanel = this.m_BackPanel;
				appeal_data.CutInEffectOrder = 0;
			}
		}
		appeal_data.AppealCutIn.color = Color.white;
		this.SetCutInSprite(chara_type);
		Vector3 cutin_local = Vector3.zero;
		Appeal_Mgr.CutInMove cutInType = appeal_data.CutInType;
		if (cutInType != Appeal_Mgr.CutInMove.CutIn_Left)
		{
			if (cutInType == Appeal_Mgr.CutInMove.CutIn_Right)
			{
				if (GameMain.Instance.VRMode)
				{
					cutin_local.x = (float)Note_Mgr.Instance.UIRootWidth;
				}
				else
				{
					cutin_local.x = (float)Screen.width * 1.5f;
					cutin_local = UI_ScreenFitBase.PointToScreenPos(cutin_local);
				}
				appeal_data.AppealCutInEffect.transform.localEulerAngles = Vector3.zero;
			}
		}
		else
		{
			if (GameMain.Instance.VRMode)
			{
				cutin_local.x = (float)(-(float)Note_Mgr.Instance.UIRootWidth);
			}
			else
			{
				cutin_local.x = (float)Screen.width * -0.5f;
				cutin_local = UI_ScreenFitBase.PointToScreenPos(cutin_local);
			}
			appeal_data.AppealCutInEffect.transform.localEulerAngles = Vector3.up * 180f;
		}
		cutin_local.y = 0f;
		appeal_data.AppealCutInEffect.SetActive(true);
		appeal_data.AppealCutInpanel.gameObject.SetActive(DanceSetting.Settings.CutInGrade != Appeal_Mgr.CutInGrade.None);
		appeal_data.AppealCutInpanel.transform.localPosition = cutin_local;
		Vector3 first_pos = appeal_data.AppealCutInpanel.transform.localPosition;
		foreach (ParticleSystem particleSystem in appeal_data.AllCutInEffect)
		{
			particleSystem.Play();
		}
		appeal_data.AppealGauge = appeal_data.AppealValue;
		float first_gauge = (float)appeal_data.AppealGauge;
		appeal_data.AppealValue -= 200;
		if (appeal_data.AppealValue < 0)
		{
			appeal_data.AppealValue = 0;
		}
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			RhythmAction_Mgr.Instance.UserMaid.status.baseAppealPoint -= 200;
		}
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause)
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				float num = Mathf.Sin(Mathf.Clamp01(timer / this.m_CutInTime) * 90f * 0.0174532924f);
				appeal_data.AppealCutInpanel.transform.localPosition = Vector3.Lerp(first_pos, Vector3.zero, num);
				this.m_EffectBase.transform.localPosition = appeal_data.AppealCutInpanel.transform.localPosition;
				appeal_data.AppealGauge = Mathf.Max((int)(first_gauge - 200f * num), 0);
				if (timer >= this.m_FadeStartTime)
				{
					appeal_data.AppealCutIn.alpha = 1f - Mathf.Sin(Mathf.Clamp01((timer - this.m_FadeStartTime) / this.m_FadeOutTime) * 90f * 0.0174532924f);
				}
				if (exist_cutin || !this.m_CharaAppealList.ContainsKey(DanceBattle_Mgr.CharaType.Enemy) || (!exist_cutin && !this.GetAppealData(oppnent_type).IsCutInNow))
				{
					this.m_EffectBase.color = appeal_data.AppealCutIn.color;
				}
				if (timer >= this.m_CutInTotal)
				{
					break;
				}
			}
			yield return null;
		}
		appeal_data.AppealGaugeEffect.SetActive(false);
		appeal_data.AppealCutInpanel.gameObject.SetActive(false);
		appeal_data.AppealCutInEffect.SetActive(false);
		appeal_data.IsCutInNow = false;
		appeal_data.AppealCutInpanel.transform.localPosition = first_pos;
		appeal_data.AppealGauge = appeal_data.AppealValue;
		if (this.m_CharaAppealList.ContainsKey(DanceBattle_Mgr.CharaType.Enemy))
		{
			if (!this.GetAppealData(oppnent_type).IsCutInNow)
			{
				this.m_AppealCutInPanel.SetActive(false);
			}
		}
		else
		{
			this.m_AppealCutInPanel.SetActive(false);
		}
		base.StartCoroutine(this.AppealTime(chara_type));
		yield break;
		yield break;
	}

	private IEnumerator AppealTime(DanceBattle_Mgr.CharaType chara_type)
	{
		float timer = 0f;
		CharaAppealData appeal_data = this.m_CharaAppealList[chara_type];
		appeal_data.AppelCoolFlash.alpha = 0f;
		while (RhythmAction_Mgr.Instance.IsPause || appeal_data.AppealCombo < this.m_AppealComboCount)
		{
			yield return null;
		}
		Note_Mgr.Instance.RecetAppealCount(chara_type);
		appeal_data.IsAppealNow = false;
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			this.m_ScreenEffect.SetActive(false);
		}
		this.GetAppealData(chara_type).AuraEffect.SetActive(false);
		appeal_data.TimerGauge.gameObject.SetActive(false);
		DanceBattle_Mgr.CharaType oppenent = DanceBattle_Mgr.GetOpponentType(chara_type);
		if (this.m_CharaAppealList.ContainsKey(oppenent))
		{
			this.GetAppealData(oppenent).SweatEffect.SetActive(false);
			appeal_data.SweatEffect.SetActive(this.GetAppealData(oppenent).IsAppealNow);
		}
		timer = 0f;
		appeal_data.IsAppealCoolNow = true;
		appeal_data.AppealCombo = 0;
		appeal_data.CoolTimeGauge.gameObject.SetActive(true);
		appeal_data.CoolTimeGauge.fillAmount = 1f;
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause)
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				if (timer > 5f + this.m_GaugeFlashTime)
				{
					break;
				}
				if (timer > 5f)
				{
					appeal_data.AppelCoolFlash.gameObject.SetActive(true);
					float num = timer - 5f;
					appeal_data.AppelCoolFlash.alpha = Mathf.Sin(Mathf.Clamp01(num / this.m_GaugeFlashTime) * 180f * 0.0174532924f);
				}
				else
				{
					appeal_data.CoolTimeGauge.fillAmount = 1f - Mathf.Clamp01(timer / 5f);
				}
			}
			yield return null;
		}
		appeal_data.AppelCoolFlash.gameObject.SetActive(false);
		appeal_data.CoolTimeGauge.gameObject.SetActive(false);
		appeal_data.IsAppealCoolNow = false;
		yield break;
		yield break;
	}

	private IEnumerator CutInReversal(DanceBattle_Mgr.CharaType chara_type)
	{
		float timer = 0f;
		CharaAppealData appeal_data = this.m_CharaAppealList[chara_type];
		if (!this.m_RevarsalCutInPanel.activeSelf)
		{
			this.m_RevarsalCutInPanel.SetActive(true);
		}
		Transform mask_parent = appeal_data.ReversalObj.transform;
		appeal_data.IsRevarsalNow = true;
		mask_parent.gameObject.SetActive(true);
		Vector3 cutin_local = Vector3.zero;
		appeal_data.ReversalVoice.LoadPlay(appeal_data.strReversalVoice, 0f, false, false);
		Appeal_Mgr.CutInMove cutInType = appeal_data.CutInType;
		if (cutInType != Appeal_Mgr.CutInMove.CutIn_Left)
		{
			if (cutInType == Appeal_Mgr.CutInMove.CutIn_Right)
			{
				cutin_local.x = (float)(appeal_data.ReversalCutIn.width / 2);
			}
		}
		else
		{
			cutin_local.x = (float)(-(float)appeal_data.ReversalCutIn.width / 2);
		}
		cutin_local.y = -this.m_ReversalCutInMove;
		mask_parent.localPosition = cutin_local;
		Vector3 first_pos = mask_parent.localPosition;
		Vector3 move_pos = Vector3.zero;
		if (appeal_data.CutInType == Appeal_Mgr.CutInMove.CutIn_Left)
		{
			move_pos = first_pos + Vector3.right * (float)appeal_data.ReversalCutIn.width + Vector3.up * this.m_ReversalCutInMove;
		}
		else
		{
			move_pos = first_pos + Vector3.left * (float)appeal_data.ReversalCutIn.width + Vector3.up * this.m_ReversalCutInMove;
		}
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause)
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				Vector3 localScale = mask_parent.localScale;
				if (timer >= 2.75f)
				{
					break;
				}
				if (timer >= 2.5f)
				{
					float num = timer - 2.5f;
					float y = Mathf.Cos(Mathf.Clamp01(num / 0.25f) * 90f * 0.0174532924f);
					localScale.y = y;
					mask_parent.localScale = localScale;
				}
				else if (timer < 0.5f)
				{
					float num2 = Mathf.Sin(Mathf.Clamp01(timer / 0.5f) * 90f * 0.0174532924f);
					mask_parent.localPosition = Vector3.Lerp(first_pos, move_pos, num2);
					localScale.y = num2;
					mask_parent.localScale = localScale;
				}
			}
			yield return null;
		}
		appeal_data.IsRevarsalNow = false;
		mask_parent.gameObject.SetActive(false);
		mask_parent.localPosition = first_pos;
		if (chara_type != DanceBattle_Mgr.CharaType.Player)
		{
			if (chara_type == DanceBattle_Mgr.CharaType.Enemy)
			{
				if (!this.GetAppealData(DanceBattle_Mgr.CharaType.Player).IsRevarsalNow)
				{
					this.m_RevarsalCutInPanel.SetActive(false);
				}
			}
		}
		else if (!this.GetAppealData(DanceBattle_Mgr.CharaType.Enemy).IsRevarsalNow)
		{
			this.m_RevarsalCutInPanel.SetActive(false);
		}
		yield break;
		yield break;
	}

	private IEnumerator AppealGaugeCharge()
	{
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge && this.GetPlayerData().AppealValue == 0)
		{
			this.GetPlayerData().AppealGauge = 0;
			this.m_GaugeChargeEnd = true;
			yield break;
		}
		float timer = 0f;
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause && !GameMain.Instance.MainCamera.IsFadeOut())
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				if (timer > this.m_GaugeChargeTime)
				{
					break;
				}
				foreach (CharaAppealData charaAppealData in this.m_CharaAppealList.Values)
				{
					float num = Mathf.Sin(Mathf.Clamp01(timer / this.m_GaugeChargeTime) * 90f * 0.0174532924f);
					charaAppealData.AppealGauge = (int)((float)charaAppealData.AppealValue * num);
				}
			}
			yield return null;
		}
		base.StartCoroutine(this.GaugeFlash(DanceBattle_Mgr.CharaType.Player));
		if (this.m_CharaAppealList.ContainsKey(DanceBattle_Mgr.CharaType.Enemy))
		{
			base.StartCoroutine(this.GaugeFlash(DanceBattle_Mgr.CharaType.Enemy));
		}
		yield break;
		yield break;
	}

	private IEnumerator GaugeFlash(DanceBattle_Mgr.CharaType chara_type)
	{
		float timer = 0f;
		CharaAppealData appeal_data = this.GetAppealData(chara_type);
		appeal_data.AppealFlashGauge.gameObject.SetActive(true);
		appeal_data.AppealFlashGauge.alpha = 0f;
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause && !GameMain.Instance.MainCamera.IsFadeOut())
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				if (timer > this.m_GaugeFlashTime)
				{
					break;
				}
				appeal_data.AppealFlashGauge.alpha = Mathf.Sin(Mathf.Clamp01(timer / this.m_GaugeFlashTime) * 180f * 0.0174532924f);
			}
			yield return null;
		}
		appeal_data.AppealFlashGauge.gameObject.SetActive(false);
		this.m_GaugeChargeEnd = true;
		yield break;
		yield break;
	}

	private IEnumerator TimerGaugeFlash(DanceBattle_Mgr.CharaType chara_type)
	{
		float timer = 0f;
		for (;;)
		{
			if (!RhythmAction_Mgr.Instance.IsPause)
			{
				timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
				this.GetAppealData(chara_type).TimerGauge.alpha = Mathf.Lerp(1f, this.m_FlashMinAlpha, KasaiUtility.SinRate01(timer, this.m_TimerFlash, false, false));
				if (timer > this.m_TimerFlash)
				{
					break;
				}
			}
			yield return null;
		}
		yield break;
		yield break;
	}

	public void AddAppealValue(DanceBattle_Mgr.CharaType chara_type, int add_value = 1)
	{
		int num = this.GetAppealData(chara_type).AppealValue + add_value;
		if (num % 200 == 0)
		{
			base.StartCoroutine(this.GaugeFlash(chara_type));
			if (chara_type == DanceBattle_Mgr.CharaType.Player)
			{
				GameMain.Instance.SoundMgr.PlaySe(this.m_GaugeChargeSE, false);
			}
		}
		this.GetAppealData(chara_type).AppealValue += add_value;
		if (this.GetAppealData(chara_type).AppealValue > this.GetAppealData(chara_type).AppealMax)
		{
			this.GetAppealData(chara_type).AppealValue = this.GetAppealData(chara_type).AppealMax;
		}
		if (chara_type == DanceBattle_Mgr.CharaType.Player)
		{
			RhythmAction_Mgr.Instance.UserMaid.status.baseAppealPoint += add_value;
		}
		this.GetAppealData(chara_type).AppealGauge = this.GetAppealData(chara_type).AppealValue;
	}

	public override void StartAction()
	{
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			RhythmAction_Mgr.Instance.UserMaid.status.baseDance = 9999;
			RhythmAction_Mgr.Instance.UserMaid.status.baseAppealPoint = 2000;
		}
		this.m_CharaAppealList[DanceBattle_Mgr.CharaType.Player].AppealMax = RhythmAction_Mgr.Instance.UserMaid.status.maxAppealPoint;
		this.AppealDataInit(DanceBattle_Mgr.CharaType.Player);
		this.GetPlayerData().AppealValue = Mathf.Clamp(RhythmAction_Mgr.Instance.UserMaid.status.appealPoint, 0, this.GetPlayerData().AppealMax);
		if (this.m_CharaAppealList.ContainsKey(DanceBattle_Mgr.CharaType.Enemy))
		{
			this.m_CharaAppealList[DanceBattle_Mgr.CharaType.Enemy].AppealMax = DanceBattle_Mgr.EnemyData.ApeealMax;
			this.AppealDataInit(DanceBattle_Mgr.CharaType.Enemy);
			this.m_CharaAppealList[DanceBattle_Mgr.CharaType.Enemy].AppealValue = DanceBattle_Mgr.EnemyData.InitialAppeal;
		}
		else
		{
			this.m_FrontPanel.SetActive(false);
			foreach (Appeal_Mgr.AppealEfectData appealEfectData in this.m_EffectList)
			{
				if (appealEfectData.Charatype == DanceBattle_Mgr.CharaType.Enemy)
				{
					appealEfectData.GaugeGroup.parent.gameObject.SetActive(false);
					appealEfectData.ReversalCutInTex.gameObject.SetActive(false);
					break;
				}
			}
		}
		base.StartCoroutine(this.AppealGaugeCharge());
		base.StartCoroutine(this.CutInOperate());
	}

	public override void EndAction()
	{
		this.m_NotTexClear = true;
		foreach (CharaAppealData charaAppealData in this.m_CharaAppealList.Values)
		{
			UnityEngine.Object.Destroy(charaAppealData.AudioSE.gameObject);
		}
		ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Player);
		ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Enemy);
		if (!RhythmAction_Mgr.Instance.DanceEnd)
		{
			return;
		}
		bool flag = RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS && RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_First;
		if (flag && DanceBattle_Mgr.Instance.IsWin())
		{
			ShootCutInTex.SetEnemyCutInTex(true);
		}
	}

	public void AppealCutIn(DanceBattle_Mgr.CharaType chara_type)
	{
		this.GetAppealData(chara_type).IsAppealNow = true;
		this.GetAppealData(chara_type).IsCutInNow = true;
		this.GetAppealData(chara_type).AuraEffect.SetActive(true);
		this.GetAppealData(chara_type).SweatEffect.SetActive(false);
		DanceBattle_Mgr.CharaType opponentType = DanceBattle_Mgr.GetOpponentType(chara_type);
		if (this.m_CharaAppealList.ContainsKey(opponentType) && !this.GetAppealData(opponentType).IsAppealNow)
		{
			this.GetAppealData(opponentType).SweatEffect.SetActive(true);
		}
		base.StartCoroutine(this.CutIn(chara_type));
	}

	public void ReversalCutIn(DanceBattle_Mgr.CharaType chara_type)
	{
		if (this.GetAppealData(chara_type).IsRevarsalNow)
		{
			return;
		}
		base.StartCoroutine(this.CutInReversal(chara_type));
	}

	public CharaAppealData GetAppealData(DanceBattle_Mgr.CharaType chara_type)
	{
		return this.m_CharaAppealList[chara_type];
	}

	public CharaAppealData GetPlayerData()
	{
		return this.GetAppealData(DanceBattle_Mgr.CharaType.Player);
	}

	public void AddAppealCombo(DanceBattle_Mgr.CharaType chara_type)
	{
		if (!this.m_CharaAppealList.ContainsKey(chara_type))
		{
			return;
		}
		this.GetAppealData(chara_type).AppealCombo++;
		this.GetAppealData(chara_type).TimerGauge.fillAmount = 1f - Mathf.Clamp01((float)this.GetAppealData(chara_type).AppealCombo / (float)this.m_AppealComboCount);
		base.StartCoroutine(this.TimerGaugeFlash(chara_type));
	}

	public static string GradeTostring(Appeal_Mgr.CutInGrade grade)
	{
		string result = grade.ToString();
		if (grade != Appeal_Mgr.CutInGrade.High)
		{
			if (grade == Appeal_Mgr.CutInGrade.Low)
			{
				result = "Cut In Only";
			}
		}
		else
		{
			result = "Cut In + Effect";
		}
		return result;
	}

	public static Appeal_Mgr.CutInGrade ParseGrade(string text_data)
	{
		Appeal_Mgr.CutInGrade result = Appeal_Mgr.CutInGrade.None;
		try
		{
			result = (Appeal_Mgr.CutInGrade)Enum.Parse(typeof(Appeal_Mgr.CutInGrade), text_data);
		}
		catch
		{
			if (text_data != null)
			{
				if (text_data == "Cut In + Effect")
				{
					result = Appeal_Mgr.CutInGrade.High;
					goto IL_70;
				}
				if (text_data == "Cut In Only")
				{
					result = Appeal_Mgr.CutInGrade.Low;
					goto IL_70;
				}
			}
			Debug.LogErrorFormat("文字データ「{0}」はAppeal_Mgr.CutInGradeに変換できません", new object[]
			{
				text_data
			});
			IL_70:;
		}
		return result;
	}

	private const string m_GaugeObj_Path = "SceneDance/Rhythm_Action/Prefab/AppealGauge";

	private const float m_AppealCoolTime = 5f;

	private const float m_ReversalTime = 0.5f;

	private const float m_ReversalCutInWait = 2f;

	private const float m_ReversalFade = 0.25f;

	private const int m_GaugeNum = 10;

	public const int AppealMax = 2000;

	public const int OneGaugeValue = 200;

	private const int m_BenchAppeal = 6;

	public const string SpecialLowString = "Cut In Only";

	public const string SpecialHighString = "Cut In + Effect";

	[SerializeField]
	[Header("アピール効果を得られるコンボ数")]
	private int m_AppealComboCount = 30;

	[SerializeField]
	[Header("カットイン時間")]
	private float m_CutInTime = 0.25f;

	[SerializeField]
	[Header("カットイン画像滞在時間")]
	private float m_FadeStartTime = 1.75f;

	[SerializeField]
	[Header("カットイン画像フェードアウト時間")]
	private float m_FadeOutTime = 0.25f;

	[SerializeField]
	[Header("アピール用SE")]
	private string m_CutInSE = "SEAppeal";

	[SerializeField]
	private string m_GaugeChargeSE = "SE038.ogg";

	[SerializeField]
	private float m_ReversalCutInMove = 256f;

	[SerializeField]
	[Header("アピールゲージ配置間隔")]
	private Vector2 m_SetSpace = new Vector2(40f, 50f);

	[SerializeField]
	[Header("チャージできないときの色")]
	private Color m_NotChargeColor;

	[SerializeField]
	[Header("画面全体エフェクト")]
	private GameObject m_ScreenEffect;

	private float m_GaugeHeight;

	private Dictionary<DanceBattle_Mgr.CharaType, CharaAppealData> m_CharaAppealList = new Dictionary<DanceBattle_Mgr.CharaType, CharaAppealData>();

	[SerializeField]
	[Header("プレイヤー・敵ごとのエフェクトリスト")]
	private List<Appeal_Mgr.AppealEfectData> m_EffectList = new List<Appeal_Mgr.AppealEfectData>
	{
		new Appeal_Mgr.AppealEfectData(DanceBattle_Mgr.CharaType.Player),
		new Appeal_Mgr.AppealEfectData(DanceBattle_Mgr.CharaType.Enemy)
	};

	[SerializeField]
	[Header("カットインエフェクト位置の基準になる画像")]
	private UI2DSprite m_EffectBase;

	[SerializeField]
	[Header("後アピールカットインパネル")]
	private GameObject m_BackPanel;

	[SerializeField]
	private UI2DSprite m_BackCutInSprite;

	[SerializeField]
	[Header("前アピールカットインパネル")]
	private GameObject m_FrontPanel;

	[SerializeField]
	private UI2DSprite m_FrontCutInSprite;

	[SerializeField]
	[Header("アピールカットイン親")]
	private GameObject m_AppealCutInPanel;

	[SerializeField]
	[Header("逆転カットインパネル親")]
	private GameObject m_RevarsalCutInPanel;

	[SerializeField]
	private float m_GaugeChargeTime = 0.25f;

	[SerializeField]
	private float m_GaugeFlashTime = 0.25f;

	[SerializeField]
	[Header("アピール可能数を表示するUI")]
	private UILabel m_AppealcountLabel;

	[SerializeField]
	[Header("タイマーゲージの点滅間隔")]
	private float m_TimerFlash = 0.5f;

	[SerializeField]
	[Range(0f, 1f)]
	private float m_FlashMinAlpha = 0.5f;

	[SerializeField]
	[Header("カットインSEのボリューム")]
	[Range(0f, 1f)]
	private float m_CutinSeVol = 0.5f;

	private ShootCutInTex.CutInName m_NowCutIn = ShootCutInTex.CutInName.ジョブ固有;

	private bool m_GaugeChargeEnd;

	private bool m_NotTexClear;

	private bool m_VsSkip1st;

	private static Appeal_Mgr m_Instance;

	public enum CutInGrade
	{
		High,
		Low,
		None
	}

	public enum CutInMove
	{
		CutIn_Right,
		CutIn_Left
	}

	[Serializable]
	private class AppealEfectData
	{
		public AppealEfectData(DanceBattle_Mgr.CharaType chara_type)
		{
			this.Charatype = chara_type;
		}

		public DanceBattle_Mgr.CharaType Charatype;

		public Appeal_Mgr.CutInMove CutInType;

		public UI2DSprite ReversalCutInTex;

		public Transform GaugeGroup;

		public GameObject GaugeEffect;

		public UIBasicSprite AppealFlashGauge;

		public UIBasicSprite CoolTimeGauge;

		public UIBasicSprite AppelCoolFlash;

		public AudioSource CutinAudio;

		public GameObject ReversalObj;

		public UIBasicSprite TimerGauge;

		public GameObject SweatEffect;

		public GameObject AuraEffect;
	}
}
