using System;
using System.Collections;
using UnityEngine;

public class StaffRollAPI
{
	public void SceneStart(MonoBehaviour f_parent, StaffRollAPI.dgOnSceneStartCallBack f_dgLoadedFinish)
	{
		this.m_dgStart = f_dgLoadedFinish;
		GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
		GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr.CloseMessageWindowPanel();
		GameMain.Instance.MainLight.Reset();
		GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
		GameMain.Instance.MainCamera.Vignett(false);
		GameMain.Instance.MainCamera.SetControl(true);
		GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
		GameMain.Instance.MainCamera.SetDistance(1.6f, true);
		GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
		GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
		GameMain.Instance.MainLight.SetIntensity(0.65f);
		GameMain.Instance.CharacterMgr.DeactivateCharaAll();
		f_parent.StartCoroutine(this.CoCharaLoad());
	}

	private IEnumerator CoCharaLoad()
	{
		while (GameMain.Instance.CharacterMgr.IsBusy())
		{
			yield return null;
		}
		GameMain.Instance.CharacterMgr.ResetCharaPosAll();
		GameMain.Instance.MainCamera.FadeIn(1f, false, null, true, true, default(Color));
		if (this.m_dgStart != null)
		{
			this.m_dgStart();
		}
		yield break;
	}

	public void EndNextScene(StaffRollAPI.dgOnSceneFinalCallBack f_dgEnd)
	{
		this.m_dgFinal = f_dgEnd;
		GameMain.Instance.SoundMgr.StopBGM(1f);
		GameMain.Instance.MainCamera.FadeOut(1f, false, new CameraMain.dgOnCompleteFade(this.OnFinishFadeOut), true, default(Color));
	}

	private void OnFinishFadeOut()
	{
		GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
		GameMain.Instance.MainCamera.SetControl(true);
		if (this.m_dgFinal != null)
		{
			this.m_dgFinal();
		}
	}

	public void SceneFinish()
	{
		if (GameMain.Instance.MainCamera != null)
		{
			GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
		}
		if (GameMain.Instance.CharacterMgr != null)
		{
			GameMain.Instance.CharacterMgr.DeactivateCharaAll();
		}
	}

	private StaffRollAPI.dgOnSceneStartCallBack m_dgStart;

	private StaffRollAPI.dgOnSceneFinalCallBack m_dgFinal;

	public delegate void dgOnSceneStartCallBack();

	public delegate void dgOnSceneFinalCallBack();
}
