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

public class RhythmAction_Mgr : MonoBehaviour
{
	public static RhythmAction_Mgr.DanceType NowDance
	{
		get
		{
			return RhythmAction_Mgr.m_DanceType;
		}
	}

	public static int DanceReward { get; private set; }

	public static RhythmAction_Mgr.DanceState NowState { get; private set; }

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

	public string MusicCSV_Path
	{
		get
		{
			return "csv_rhythm_action/" + this.m_UseMusicName + "/";
		}
	}

	public List<Maid> DanceMaid
	{
		get
		{
			return this.m_DanceMain.DanceMaid;
		}
	}

	public Maid UserMaid
	{
		get
		{
			return this.m_DanceMain.UserMaid;
		}
	}

	public bool IsTakeEnd
	{
		get
		{
			return this.m_DanceMain.m_AnimatorData.takeName == null;
		}
	}

	public float TakeTime
	{
		get
		{
			return this.m_DanceMain.m_AnimatorData.GetTakeTime();
		}
	}

	public bool IsPause
	{
		get
		{
			return this.m_IsPause;
		}
	}

	public AVProVideoPlayer MovieMgr { get; private set; }

	public float DanceDeltaTime { get; private set; }

	public Transform OvrCamTrans
	{
		get
		{
			return this.m_DanceMain.OvrCamTrans;
		}
	}

	public GameObject UIScreen { get; private set; }

	public bool IsReadyNow
	{
		get
		{
			return this.m_ReadyPanel;
		}
	}

	public float DanceTimer { get; private set; }

	public bool DanceEnd
	{
		get
		{
			return this.m_DanceMain.IsDanceEnd;
		}
	}

	public bool ForceDanceEnd
	{
		get
		{
			return this.m_DanceMain.IsForceDanceEnd;
		}
	}

	public List<Maid> FactOrderList
	{
		get
		{
			return this.m_FactOrderList;
		}
	}

	public bool IsDanceSkip
	{
		get
		{
			return this.m_DanceMain.IsDanceSkip;
		}
	}

	public bool IsNewController
	{
		get
		{
			return GameMain.Instance.VRMode && GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller.IsControllerTypeNew && GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller.IsControllerTypeNew;
		}
	}

	public float RemainingTime
	{
		get
		{
			return Mathf.Max(this.TakeTime - this.DanceTimer, 0f);
		}
	}

	public static int MusicReleaseFlag
	{
		get
		{
			return GameMain.Instance.CharacterMgr.status.GetFlag("_楽曲解放");
		}
		set
		{
			GameMain.Instance.CharacterMgr.status.SetFlag("_楽曲解放", value);
		}
	}

	public static bool IsVSDance
	{
		get
		{
			return RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS_Skip;
		}
	}

	private void Awake()
	{
		RhythmAction_Mgr.m_Instance = this;
		this.m_NowTime = 0f;
		this.m_LastTime = 0f;
		this.m_DanceMain = GameObject.Find("_DanceMain_").GetComponent<DanceMain>();
		if (!base.transform.parent)
		{
			GameObject gameObject = GameObject.Find("UI Root");
			base.transform.SetParent(gameObject.transform, false);
		}
		GameObject gameObject2 = base.transform.parent.Find("Camera").gameObject;
		this.m_RhythmActionCam = UnityEngine.Object.Instantiate<GameObject>(gameObject2, base.transform.parent).GetComponent<Camera>();
		this.m_RhythmActionCam.name = "RhythmActionCam";
		this.m_NguiCam = gameObject2.GetComponent<Camera>();
		if (!GameMain.Instance.VRMode || !this.IsNewController)
		{
			this.m_NguiCam.cullingMask = this.m_RhythmAction2DLayer;
			this.m_RhythmActionCam.gameObject.SetActive(false);
		}
		else
		{
			this.m_OrijinLimit = GameMain.Instance.OvrMgr.OvrCamera.HandLimitMode;
			GameMain.Instance.OvrMgr.OvrCamera.HandLimitMode = AVRControllerBehavior.LIMIT_MODE.NO_WARP;
			this.m_RhythmActionCam.cullingMask = this.m_RhythmActionLayer;
			this.m_LeftPenlight = Utility.CreatePrefab(GameMain.Instance.OvrMgr.GetVRControllerTransform(true).gameObject, "SceneDance/Rhythm_Action/Prefab/StickLight", true);
			this.m_LeftPenlight.name = "PenLight(left)";
			this.m_RightPenlight = Utility.CreatePrefab(GameMain.Instance.OvrMgr.GetVRControllerTransform(false).gameObject, "SceneDance/Rhythm_Action/Prefab/StickLight", true);
			this.m_RightPenlight.name = "PenLight(light)";
			Transform transform = this.m_LeftPenlight.transform;
			Vector3 vector = Vector3.zero;
			this.m_RightPenlight.transform.localEulerAngles = vector;
			transform.localEulerAngles = vector;
			Transform transform2 = this.m_LeftPenlight.transform;
			vector = this.m_PenlightOffset;
			this.m_RightPenlight.transform.localPosition = vector;
			transform2.localPosition = vector;
			Transform transform3 = this.m_LeftPenlight.transform;
			vector = this.m_PenlightScale;
			this.m_RightPenlight.transform.localScale = vector;
			transform3.localScale = vector;
			UnityEngine.Object.Destroy(this.m_LeftPenlight.GetComponent<OvrControllerHit>());
			UnityEngine.Object.Destroy(this.m_RightPenlight.GetComponent<OvrControllerHit>());
			UnityEngine.Object.Destroy(this.m_LeftPenlight.GetComponent<ViveControllerHit>());
			UnityEngine.Object.Destroy(this.m_RightPenlight.GetComponent<ViveControllerHit>());
		}
		if (!DanceMain.KaraokeMode && GameMain.Instance.VRMode)
		{
			this.m_OvrUI = GameMain.Instance.OvrMgr.OvrCamera.m_goOvrUiScreen.GetComponent<OvrUI>();
			GameMain.Instance.OvrMgr.OvrCamera.m_goOvrUiScreen.SetActive(true);
			this.UIScreen = this.m_OvrUI.transform.Find("ovr_screen").gameObject;
			this.m_FirstScreen = this.UIScreen.transform.localPosition;
			if (this.IsNewController)
			{
				this.m_RhythmActionTex = Resources.Load<RenderTexture>("SceneDance/Rhythm_Action/rtRhythmActionUI");
				this.m_RhythmActionCam.targetTexture = this.m_RhythmActionTex;
				this.m_ScreenMat = this.UIScreen.transform.Find("default").GetComponent<MeshRenderer>().material;
				this.m_ScreenMat.mainTexture = this.m_RhythmActionTex;
				this.UIScreen.transform.Find("hit").gameObject.SetActive(false);
			}
			GameMain.Instance.OvrMgr.OvrCamera.HandDanceMode = (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS_Skip);
		}
		this.m_MainCamDepth = GameMain.Instance.MainCamera.GetComponent<DepthOfFieldScatter>();
		if (this.m_MainCamDepth)
		{
			this.m_OrijinDepthEnable = this.m_MainCamDepth.enabled;
			this.m_OrijinFocalSize = this.m_MainCamDepth.focalSize;
			this.m_MainCamDepth.focalSize = this.m_DanceMain.DepthFocalSize;
			this.m_MainCamDepth.enabled = DanceSetting.Settings.IsDepthOfFieldOn;
		}
		foreach (RhythmAction_Mgr.ChoiceObjpair choiceObjpair in this.m_ChoiceUIList)
		{
			choiceObjpair.UIImage = choiceObjpair.EventUI.GetComponent<UISprite>();
			switch (choiceObjpair.Choice)
			{
			case RhythmAction_Mgr.PauseChoices.Continue:
				this.AddEventMethod(choiceObjpair.EventUI, new EventDelegate.Callback(this.SelectContinue));
				break;
			case RhythmAction_Mgr.PauseChoices.End:
				if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS_Skip)
				{
					this.AddEventMethod(choiceObjpair.EventUI, new EventDelegate.Callback(this.SelectEnd));
				}
				else
				{
					choiceObjpair.EventUI.SetActive(false);
				}
				break;
			case RhythmAction_Mgr.PauseChoices.Recet:
				if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Free)
				{
					this.AddEventMethod(choiceObjpair.EventUI, new EventDelegate.Callback(this.SelectRecet));
				}
				else
				{
					choiceObjpair.EventUI.SetActive(false);
					choiceObjpair.EventUI.transform.parent.localPosition += Vector3.down * this.m_ChoiceUIDown;
				}
				break;
			case RhythmAction_Mgr.PauseChoices.Skip:
				if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS_Skip)
				{
					this.AddEventMethod(choiceObjpair.EventUI, new EventDelegate.Callback(this.SelectSkip));
				}
				else
				{
					choiceObjpair.EventUI.SetActive(false);
				}
				break;
			}
		}
		this.ChoicesUIRecet();
		this.m_PausePanel.SetActive(false);
		GameObject gameObject3 = GameObject.Find("LiveGimic");
		if (gameObject3)
		{
			this.Search_AllEffect(gameObject3.transform, false);
		}
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			GameMain.Instance.SysShortcut.gameObject.SetActive(false);
		}
	}

	private void Update()
	{
		if (this.m_LastTime != 0f)
		{
			this.m_NowTime = Time.realtimeSinceStartup;
		}
		if (this.m_LeftPenlight && this.m_RightPenlight)
		{
			this.m_LeftPenlight.SetActive(GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller.HandDanceMode);
			this.m_RightPenlight.SetActive(GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller.HandDanceMode);
		}
		this.DanceDeltaTime = this.m_NowTime - this.m_LastTime;
		this.m_LastTime = Time.realtimeSinceStartup;
		if (!this.IsPause && this.m_IsStart)
		{
			this.DanceTimer += this.DanceDeltaTime;
		}
		if (GameMain.Instance.VRMode && this.m_OvrUI)
		{
			if (!this.IsNewController && !Note_Mgr.Instance.IsActive)
			{
				return;
			}
			Vector3 eulerAngles = this.m_OvrUI.m_goCenter.transform.eulerAngles;
			eulerAngles.z = 0f;
			this.m_OvrUI.transform.eulerAngles = eulerAngles;
			this.UIScreen.transform.localPosition = new Vector3(0f, -this.m_UIDown, this.m_CameraLength);
			this.m_RhythmActionCam.transform.localPosition = this.m_NguiCam.transform.localPosition;
		}
	}

	private void OnDestroy()
	{
		if (this.m_RhythmActionCam)
		{
			UnityEngine.Object.DestroyImmediate(this.m_RhythmActionCam.gameObject);
		}
		if (GameMain.Instance.VRMode && !this.IsNewController)
		{
			this.m_NguiCam.cullingMask = LayerMask.GetMask(new string[]
			{
				"NGUI"
			});
		}
		if (!DanceMain.KaraokeMode && GameMain.Instance.VRMode && GameMain.Instance.VRFamily != GameMain.VRFamilyType.NON)
		{
			if (this.IsNewController)
			{
				GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true);
				GameMain.Instance.OvrMgr.OvrCamera.HandLimitMode = this.m_OrijinLimit;
				if (GameMain.Instance.OvrMgr.OvrCamera.m_goOvrUiScreen)
				{
					GameMain.Instance.OvrMgr.OvrCamera.m_goOvrUiScreen.SetActive(false);
				}
			}
			else if (this.m_OvrUI)
			{
				this.m_OvrUI.enabled = true;
			}
			GameMain.Instance.OvrMgr.OvrCamera.HandDanceMode = false;
		}
		if (this.m_MainCamDepth)
		{
			this.m_MainCamDepth.focalSize = this.m_OrijinFocalSize;
			this.m_MainCamDepth.enabled = this.m_OrijinDepthEnable;
		}
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			if (GameMain.Instance && GameMain.Instance.SysShortcut)
			{
				GameMain.Instance.SysShortcut.gameObject.SetActive(true);
			}
			BenchSetting.SettingRecet();
		}
		foreach (Maid maid in this.DanceMaid)
		{
			if (maid)
			{
				maid.MabatakiUpdateStop = false;
			}
		}
		if (this.m_LeftPenlight && this.m_RightPenlight)
		{
			UnityEngine.Object.Destroy(this.m_LeftPenlight);
			UnityEngine.Object.Destroy(this.m_RightPenlight);
		}
	}

	private IEnumerator CheckPause()
	{
		float timer = 0f;
		UIPanel ready_panel = (!this.m_ReadyPanel) ? null : this.m_ReadyPanel.GetComponent<UIPanel>();
		bool ready_fade = false;
		bool ready_display = false;
		for (;;)
		{
			if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.BenchMark)
			{
				if (this.m_ReadyPanel)
				{
					if (!ready_display)
					{
						ready_display = GameMain.Instance.MainCamera.IsFadeProc();
					}
					else if (!ready_fade)
					{
						if (!this.IsPause && !this.m_ReadyNotStop)
						{
							this.SwitchPause(true, true);
						}
						timer += this.DanceDeltaTime;
						if (timer > this.m_ReadyWaitTime)
						{
							this.SwitchPause(false, true);
							ready_fade = true;
							timer = 0f;
						}
					}
					else
					{
						timer += this.DanceDeltaTime;
						ready_panel.alpha = 1f - Mathf.Sin(Mathf.Clamp01(timer / this.m_ReadyFadeTime) * 90f * 0.0174532924f);
						if (timer > this.m_ReadyFadeTime)
						{
							ready_fade = false;
							ready_display = false;
							UnityEngine.Object.Destroy(this.m_ReadyPanel);
							timer = 0f;
						}
					}
				}
				else if (!GameMain.Instance.MainCamera.IsFadeOut() && Input.GetKeyDown(KeyCode.Return))
				{
					this.SwitchPause(!this.m_IsPause, false);
				}
			}
			yield return null;
		}
		yield break;
	}

	private void DanceStart()
	{
		this.m_IsStart = true;
		if (GameMain.Instance.VRMode)
		{
			this.m_NguiCam.clearFlags = CameraClearFlags.Color;
			this.m_RhythmActionCam.clearFlags = CameraClearFlags.Color;
		}
		else
		{
			this.m_NguiCam.clearFlags = CameraClearFlags.Depth;
		}
		this.m_BlackBG.SetActive(DanceSetting.Settings.IsblackBGon && Note_Mgr.Instance.IsActive);
		if (this.m_OvrUI)
		{
			if (this.IsNewController)
			{
				GameMain.Instance.OvrMgr.OvrCamera.ShowUI(!Note_Mgr.Instance.IsActive);
				this.m_OvrUI.enabled = false;
			}
			else
			{
				this.m_OvrUI.enabled = !Note_Mgr.Instance.IsActive;
			}
		}
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			GameMain.Instance.SysShortcut.gameObject.SetActive(false);
		}
		if (!Note_Mgr.Instance.IsActive || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
		{
			UnityEngine.Object.Destroy(this.m_ReadyPanel);
		}
		if (DanceMain.KaraokeMode)
		{
			return;
		}
		foreach (Maid maid in this.DanceMaid)
		{
			this.SetMaidFaceStop(maid, false);
			this.SetMaidFaceBlendStop(maid, false);
			this.Search_AllEffect(maid.transform, true);
		}
		base.StartCoroutine(this.CheckPause());
	}

	private void ToNextState()
	{
		if (DanceMain.KaraokeMode)
		{
			return;
		}
		RhythmAction_Mgr.DanceState nowState = RhythmAction_Mgr.NowState;
		if (nowState != RhythmAction_Mgr.DanceState.Dance_First)
		{
			if (nowState == RhythmAction_Mgr.DanceState.Dance_Second)
			{
				GameMain.Instance.CharacterMgr.status.SetFlag("バトル回数", 2);
				RhythmAction_Mgr.NowState = RhythmAction_Mgr.DanceState.Dance_First;
			}
		}
		else
		{
			GameMain.Instance.CharacterMgr.status.SetFlag("バトル回数", 1);
			if (RhythmAction_Mgr.IsVSDance)
			{
				RhythmAction_Mgr.NowState = RhythmAction_Mgr.DanceState.Dance_Second;
			}
		}
	}

	private void SwitchPause(bool is_pause, bool is_ready = false)
	{
		this.m_IsPause = is_pause;
		this.m_PausePanel.SetActive(this.m_IsPause && !is_ready);
		if (this.IsNewController && this.m_PausePanel.activeSelf)
		{
			GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true);
		}
		this.ChoicesUIRecet();
		if (this.m_IsPause)
		{
			if (this.MovieMgr)
			{
				this.MovieMgr.Stop();
			}
			foreach (ParticleSystem particleSystem in this.m_AllParticleSystem)
			{
				if (particleSystem && particleSystem.gameObject.activeInHierarchy)
				{
					particleSystem.Pause();
				}
			}
			foreach (Animator animator in this.m_OtherAnimator)
			{
				animator.speed = 0f;
			}
			foreach (AudioSource audioSource in this.m_AudioMgrList)
			{
				audioSource.Pause();
			}
			GameMain.Instance.SoundMgr.GetAudioSourceBgm().Pause();
		}
		else
		{
			if (this.MovieMgr)
			{
				this.MovieMgr.Play();
			}
			foreach (ParticleSystem particleSystem2 in this.m_AllParticleSystem)
			{
				if (particleSystem2 && particleSystem2.gameObject.activeInHierarchy)
				{
					particleSystem2.Play();
				}
			}
			foreach (Animator animator2 in this.m_OtherAnimator)
			{
				animator2.speed = 1f;
			}
			foreach (AudioSource audioSource2 in this.m_AudioMgrList)
			{
				audioSource2.UnPause();
			}
			GameMain.Instance.SoundMgr.GetAudioSourceBgm().UnPause();
		}
		foreach (EllipsoidParticleEmitter ellipsoidParticleEmitter in this.m_AllParticleEmitter)
		{
			if (ellipsoidParticleEmitter)
			{
				ellipsoidParticleEmitter.enabled = !this.m_IsPause;
			}
		}
		foreach (Maid maid in this.DanceMaid)
		{
			if (GameMain.Instance.VRMode && GameMain.Instance.CMSystem.GetTmpGenericFlag("ダンスOVRカメラタイプ") == 0)
			{
				if (this.m_IsPause)
				{
					maid.EyeToCamera(Maid.EyeMoveType.無視する, 0f);
				}
				else
				{
					maid.EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
				}
			}
			maid.MabatakiUpdateStop = this.m_IsPause;
		}
		if (!is_ready)
		{
			GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
		}
	}

	private void SelectContinue()
	{
		this.m_SelectEnd = false;
		this.m_SelectRecet = false;
		this.m_SelectSkip = false;
		this.ChoicesSelect(RhythmAction_Mgr.PauseChoices.Continue, true);
	}

	private void SelectEnd()
	{
		this.m_SelectEnd = true;
		this.m_SelectRecet = false;
		this.m_SelectSkip = false;
		this.ChoicesSelect(RhythmAction_Mgr.PauseChoices.End, true);
	}

	private void SelectRecet()
	{
		this.m_SelectEnd = true;
		this.m_SelectRecet = true;
		this.m_SelectSkip = false;
		this.ChoicesSelect(RhythmAction_Mgr.PauseChoices.Recet, true);
	}

	private void SelectSkip()
	{
		this.m_SelectEnd = false;
		this.m_SelectRecet = false;
		this.m_SelectSkip = true;
		this.ChoicesSelect(RhythmAction_Mgr.PauseChoices.Skip, true);
	}

	private void ChoicesSelect(RhythmAction_Mgr.PauseChoices select_choice, bool playse = true)
	{
		if (playse)
		{
			GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
		}
		foreach (RhythmAction_Mgr.ChoiceObjpair choiceObjpair in this.m_ChoiceUIList)
		{
			if (choiceObjpair.Choice == select_choice)
			{
				choiceObjpair.UIImage.spriteName = choiceObjpair.CursorOnImage;
			}
			else
			{
				choiceObjpair.UIImage.spriteName = choiceObjpair.CursorOffImage;
			}
		}
	}

	private void ChoicesUIRecet()
	{
		this.m_SelectEnd = false;
		this.m_SelectRecet = false;
		this.m_SelectSkip = false;
		this.ChoicesSelect(RhythmAction_Mgr.PauseChoices.Continue, false);
	}

	private void Decide_GameEnd()
	{
		GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
		this.m_DanceMain.IsForceDanceEnd = this.m_SelectEnd;
		this.m_DanceMain.IsDanceSkip = this.m_SelectSkip;
		DanceMain.IsDanceRecet = this.m_SelectRecet;
		if (!this.m_DanceMain.IsForceDanceEnd && !this.m_SelectSkip)
		{
			this.SwitchPause(false, false);
		}
		else
		{
			foreach (Maid maid in this.DanceMaid)
			{
				maid.boMabataki = true;
			}
		}
	}

	private void AddEventMethod(GameObject ui, EventDelegate.Callback callback)
	{
		UIEventTrigger component = ui.GetComponent<UIEventTrigger>();
		EventDelegate.Add(component.onHoverOver, callback);
		EventDelegate.Add(component.onPress, new EventDelegate.Callback(this.Decide_GameEnd));
	}

	public void Search_AllEffect(Transform parent, bool isIgnoreAnime = false)
	{
		IEnumerator enumerator = parent.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform transform = (Transform)obj;
				ParticleSystem component = transform.GetComponent<ParticleSystem>();
				EllipsoidParticleEmitter component2 = transform.GetComponent<EllipsoidParticleEmitter>();
				Animator component3 = transform.GetComponent<Animator>();
				AVProVideoPlayer component4 = transform.GetComponent<AVProVideoPlayer>();
				if (component)
				{
					this.m_AllParticleSystem.Add(component);
				}
				else if (component2)
				{
					this.m_AllParticleEmitter.Add(component2);
				}
				else if (component3 && !isIgnoreAnime)
				{
					this.m_OtherAnimator.Add(component3);
				}
				else if (component4)
				{
					this.MovieMgr = component4;
				}
				this.Search_AllEffect(transform, isIgnoreAnime);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}

	public void AddMgrParts(PartsMgrBase parts)
	{
		this.m_MgrPartsList.Add(parts);
	}

	public T GetMgrParts<T>() where T : PartsMgrBase
	{
		foreach (PartsMgrBase partsMgrBase in this.m_MgrPartsList)
		{
			if (partsMgrBase is T)
			{
				return (T)((object)partsMgrBase);
			}
		}
		Debug.LogErrorFormat("指定した管理クラスを取得できませんでした", new object[0]);
		return (T)((object)null);
	}

	public void RhythmGame_Start()
	{
		this.DanceStart();
		foreach (PartsMgrBase partsMgrBase in this.m_MgrPartsList)
		{
			if (partsMgrBase.IsActive)
			{
				partsMgrBase.StartAction();
			}
		}
	}

	public void RhythmGame_End()
	{
		if (GameMain.Instance.VRMode && this.m_OvrUI)
		{
			this.m_OvrUI.enabled = true;
		}
		base.StopAllCoroutines();
		foreach (PartsMgrBase partsMgrBase in this.m_MgrPartsList)
		{
			if (partsMgrBase.IsActive)
			{
				partsMgrBase.EndAction();
			}
		}
		this.ToNextState();
	}

	public void Pause()
	{
		this.SwitchPause(true, false);
	}

	public void Play()
	{
		this.SwitchPause(false, false);
	}

	public void AddParticleSystem(ParticleSystem particle)
	{
		if (!this.m_AllParticleSystem.Contains(particle))
		{
			this.m_AllParticleSystem.Add(particle);
		}
		if (particle.subEmitters.subEmittersCount > 0)
		{
			for (int i = 0; i < particle.subEmitters.subEmittersCount; i++)
			{
				this.AddParticleSystem(particle.subEmitters.GetSubEmitterSystem(i));
			}
		}
	}

	public void AddParticleSystem(ParticleSystem[] particle)
	{
		foreach (ParticleSystem particle2 in particle)
		{
			this.AddParticleSystem(particle2);
		}
	}

	public void RemoveParticleSystem(ParticleSystem particle)
	{
		if (this.m_AllParticleSystem.Contains(particle))
		{
			this.m_AllParticleSystem.Remove(particle);
		}
		if (particle.subEmitters.subEmittersCount > 0)
		{
			for (int i = 0; i < particle.subEmitters.subEmittersCount; i++)
			{
				this.RemoveParticleSystem(particle.subEmitters.GetSubEmitterSystem(i));
			}
		}
	}

	public void RemoveParticleSystem(ParticleSystem[] particle)
	{
		foreach (ParticleSystem particle2 in particle)
		{
			this.RemoveParticleSystem(particle2);
		}
	}

	public void AddAudioMgr(AudioSource[] audio_array)
	{
		foreach (AudioSource audio in audio_array)
		{
			this.AddAudioMgr(audio);
		}
	}

	public void AddAudioMgr(AudioSource audio)
	{
		if (!this.m_AudioMgrList.Contains(audio))
		{
			this.m_AudioMgrList.Add(audio);
		}
	}

	public void RemoveAudioMgr(AudioSource[] audio_array)
	{
		foreach (AudioSource audio in audio_array)
		{
			this.RemoveAudioMgr(audio);
		}
	}

	public void RemoveAudioMgr(AudioSource audio)
	{
		if (this.m_AudioMgrList.Contains(audio))
		{
			this.m_AudioMgrList.Remove(audio);
		}
	}

	public bool GetCamMoveStop()
	{
		return this.TimeLineStopInfo.CamMoveStop;
	}

	public void SetCamMoveStop(bool set)
	{
		this.TimeLineStopInfo.CamMoveStop = set;
	}

	public void SetTimeLineFace(int maid_no, string face)
	{
		Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maid_no);
		if (this.TimeLineStopInfo.TimeLineFace.ContainsKey(maid))
		{
			this.TimeLineStopInfo.TimeLineFace[maid] = face;
		}
		else
		{
			this.TimeLineStopInfo.TimeLineFace.Add(maid, face);
		}
	}

	public void SetTimeLineFaceBlend(int maid_no, string face)
	{
		Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maid_no);
		if (this.TimeLineStopInfo.TimeLineFaceBlend.ContainsKey(maid))
		{
			this.TimeLineStopInfo.TimeLineFaceBlend[maid] = face;
		}
		else
		{
			this.TimeLineStopInfo.TimeLineFaceBlend.Add(maid, face);
		}
	}

	public bool GetMaidFaceStop(int maid_no)
	{
		Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maid_no);
		return this.GetMaidFaceStop(maid);
	}

	public bool GetMaidFaceStop(Maid maid)
	{
		return this.TimeLineStopInfo.FaceStop.ContainsKey(maid) && this.TimeLineStopInfo.FaceStop[maid];
	}

	public bool GetMaidFaceBlendStop(int maid_no)
	{
		Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maid_no);
		return this.GetMaidFaceBlendStop(maid);
	}

	public bool GetMaidFaceBlendStop(Maid maid)
	{
		return this.TimeLineStopInfo.FaceBlendStop.ContainsKey(maid) && this.TimeLineStopInfo.FaceBlendStop[maid];
	}

	public void SetMaidFaceStop(Maid maid, bool set)
	{
		if (!this.TimeLineStopInfo.FaceStop.ContainsKey(maid) || !this.TimeLineStopInfo.TimeLineFace.ContainsKey(maid))
		{
			if (!this.TimeLineStopInfo.FaceStop.ContainsKey(maid))
			{
				this.TimeLineStopInfo.FaceStop.Add(maid, set);
			}
			return;
		}
		if (this.TimeLineStopInfo.FaceStop[maid] != set)
		{
			this.TimeLineStopInfo.FaceStop[maid] = set;
			if (!set)
			{
				maid.FaceAnime(this.TimeLineStopInfo.TimeLineFace[maid], 1f, 0);
			}
		}
	}

	public void SetMaidFaceBlendStop(Maid maid, bool set)
	{
		if (!this.TimeLineStopInfo.FaceBlendStop.ContainsKey(maid) || !this.TimeLineStopInfo.TimeLineFaceBlend.ContainsKey(maid))
		{
			if (!this.TimeLineStopInfo.FaceBlendStop.ContainsKey(maid))
			{
				this.TimeLineStopInfo.FaceBlendStop.Add(maid, set);
			}
			return;
		}
		if (this.TimeLineStopInfo.FaceBlendStop[maid] != set)
		{
			this.TimeLineStopInfo.FaceBlendStop[maid] = set;
			if (!set)
			{
				maid.FaceBlend(this.TimeLineStopInfo.TimeLineFaceBlend[maid]);
			}
		}
	}

	public void SetDanceReward(int reward)
	{
		if (RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.Challenge)
		{
			return;
		}
		RhythmAction_Mgr.DanceReward += reward;
	}

	public void SetFocalSize(float focal_size)
	{
		if (this.m_MainCamDepth)
		{
			this.m_MainCamDepth.focalSize = focal_size;
		}
	}

	public IEnumerator DanceTimeCoroutine(float time_rimmit, Action<float> update_call, Action end_call = null)
	{
		float timer = 0f;
		for (;;)
		{
			if (!this.IsPause)
			{
				timer += this.DanceDeltaTime;
				if (update_call != null)
				{
					update_call(timer);
				}
				if (time_rimmit > 0f && timer > time_rimmit)
				{
					break;
				}
			}
			yield return null;
		}
		if (end_call != null)
		{
			end_call();
		}
		yield break;
		yield break;
	}

	public IEnumerator DanceTimeCoroutine(Action update_call, Func<bool> endcheck_call = null)
	{
		for (;;)
		{
			if (!this.IsPause)
			{
				if (update_call != null)
				{
					update_call();
				}
				if (endcheck_call != null && endcheck_call())
				{
					break;
				}
			}
			yield return null;
		}
		yield break;
		yield break;
	}

	public void StartTimeCroutine(float time_rimmit, Action<float> update_call, Action end_call = null)
	{
		base.StartCoroutine(this.DanceTimeCoroutine(time_rimmit, update_call, end_call));
	}

	public void StartTimeCroutine(Action update_call, Func<bool> endcheck_call = null)
	{
		base.StartCoroutine(this.DanceTimeCoroutine(update_call, endcheck_call));
	}

	public void InstanceInit()
	{
		RhythmAction_Mgr.m_Instance = this;
	}

	public void KaraokeEnd()
	{
		if (this.m_RhythmActionCam)
		{
			UnityEngine.Object.Destroy(this.m_RhythmActionCam.gameObject);
		}
		UnityEngine.Object.Destroy(base.gameObject);
	}

	public static void RewardRecet()
	{
		RhythmAction_Mgr.DanceReward = 0;
	}

	public static void KaraokeRecet()
	{
		RhythmAction_Mgr.NowState = RhythmAction_Mgr.DanceState.Dance_First;
		MotionAction_Mgr.CaptureFlagRecet();
	}

	public static void SetDanceType(RhythmAction_Mgr.DanceType type)
	{
		if (type == RhythmAction_Mgr.DanceType.VrDance)
		{
			return;
		}
		RhythmAction_Mgr.m_DanceType = type;
		if (RhythmAction_Mgr.m_DanceType != RhythmAction_Mgr.DanceType.VS_Skip)
		{
			ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Player);
		}
		RhythmAction_Mgr.NowState = RhythmAction_Mgr.DanceState.Dance_First;
		MotionAction_Mgr.CaptureFlagRecet();
		if (RhythmAction_Mgr.m_DanceType == RhythmAction_Mgr.DanceType.Challenge)
		{
			RhythmAction_Mgr.DoChallengeDance = true;
			RhythmAction_Mgr.RewardRecet();
		}
	}

	public const string RhythmResouce_Path = "SceneDance/Rhythm_Action/";

	public const string DanceSelectResouce_Path = "SceneDanceSelect/Rhythm_Action/";

	public const string RhythmCSVPath = "csv_rhythm_action/";

	public const int BenchMarkID = -100;

	public const string TestResourcePath = "SceneDance/Rhythm_Action/TestResources/";

	public const string ToolResource_path = "SceneDance/Rhythm_Action/Tools/";

	private static RhythmAction_Mgr.DanceType m_DanceType = RhythmAction_Mgr.DanceType.View;

	public static bool DoChallengeDance;

	private static RhythmAction_Mgr m_Instance;

	private List<PartsMgrBase> m_MgrPartsList = new List<PartsMgrBase>();

	[SerializeField]
	private GameObject m_PausePanel;

	[SerializeField]
	[Header("「Ready?」の表示時間")]
	private float m_ReadyWaitTime = 2f;

	[SerializeField]
	[Header("「Ready?」フェードアウト時間")]
	private float m_ReadyFadeTime = 0.5f;

	[SerializeField]
	private GameObject m_ReadyPanel;

	[SerializeField]
	[Header("csvフォルダ名")]
	private string m_UseMusicName;

	private DanceMain m_DanceMain;

	private bool m_IsPause;

	private List<ParticleSystem> m_AllParticleSystem = new List<ParticleSystem>();

	private List<EllipsoidParticleEmitter> m_AllParticleEmitter = new List<EllipsoidParticleEmitter>();

	private List<Animator> m_OtherAnimator = new List<Animator>();

	private List<AudioSource> m_AudioMgrList = new List<AudioSource>();

	private float m_NowTime;

	private float m_LastTime;

	private OvrUI m_OvrUI;

	private Vector3 m_FirstScreen;

	[Header("VR時カメラ設定")]
	[SerializeField]
	[Header("VR時のカメラとの距離")]
	private float m_CameraLength = 1f;

	[SerializeField]
	[Header("VR時はnGUIを少し下げる")]
	private float m_UIDown = 0.5f;

	private RhythmAction_Mgr.TimeLineStop TimeLineStopInfo = new RhythmAction_Mgr.TimeLineStop();

	private bool m_SelectEnd;

	private bool m_SelectRecet;

	private bool m_SelectSkip;

	[SerializeField]
	[Header("フリー以外の時は選択肢UIを少し下に下げる")]
	private float m_ChoiceUIDown = 65f;

	[SerializeField]
	[Header("ポーズ中の各選択肢毎に設定するUI")]
	private List<RhythmAction_Mgr.ChoiceObjpair> m_ChoiceUIList = new List<RhythmAction_Mgr.ChoiceObjpair>();

	private bool m_OrijinDepthEnable;

	private DepthOfFieldScatter m_MainCamDepth;

	private float m_OrijinFocalSize;

	[SerializeField]
	[Header("黒背景")]
	private GameObject m_BlackBG;

	[SerializeField]
	[Header("Readyでもダンスを止めないフラグ")]
	private bool m_ReadyNotStop;

	[SerializeField]
	[Header("音ゲーのレイヤー")]
	private LayerMask m_RhythmActionLayer = -1;

	[SerializeField]
	[Header("音ゲーのレイヤー(2D時)")]
	private LayerMask m_RhythmAction2DLayer = -1;

	private List<Maid> m_FactOrderList = new List<Maid>();

	private bool m_IsOrijinTablet;

	private Camera m_RhythmActionCam;

	private RenderTexture m_RhythmActionTex;

	private Material m_ScreenMat;

	private Camera m_NguiCam;

	private AVRControllerBehavior.LIMIT_MODE m_OrijinLimit;

	private bool m_IsStart;

	[SerializeField]
	[Header("ペンライトのオフセット")]
	private Vector3 m_PenlightOffset = new Vector3(0f, -0.01f, -0.06f);

	[SerializeField]
	[Header("ペンライトのサイズ")]
	private Vector3 m_PenlightScale = new Vector3(1.25f, 1.25f, 2f);

	private GameObject m_LeftPenlight;

	private GameObject m_RightPenlight;

	public enum DanceType
	{
		Free,
		Challenge,
		VS,
		Encore,
		View,
		BenchMark,
		Touch,
		VS_Skip,
		VrDance
	}

	public enum DanceState
	{
		Dance_First,
		Dance_Second
	}

	private class TimeLineStop
	{
		public bool CamMoveStop;

		public Dictionary<Maid, bool> FaceStop = new Dictionary<Maid, bool>();

		public Dictionary<Maid, bool> FaceBlendStop = new Dictionary<Maid, bool>();

		public Dictionary<Maid, string> TimeLineFace = new Dictionary<Maid, string>();

		public Dictionary<Maid, string> TimeLineFaceBlend = new Dictionary<Maid, string>();
	}

	private enum PauseChoices
	{
		Continue,
		End,
		Recet,
		Skip
	}

	[Serializable]
	private class ChoiceObjpair
	{
		public RhythmAction_Mgr.PauseChoices Choice;

		public GameObject EventUI;

		public string CursorOnImage;

		public string CursorOffImage;

		[HideInInspector]
		public UISprite UIImage;
	}
}
