using System;
using System.Collections;
using UnityEngine;

public class StartDailyAPI
{
	public void SceneStart(MonoBehaviour f_parent, StartDailyAPI.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(true);
		GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
		Action<string> action = delegate(string bgName)
		{
			CameraMain mainCamera = GameMain.Instance.MainCamera;
			if (bgName == "EmpireClub_Rotary")
			{
				mainCamera.SetTargetPos(new Vector3(-17.42608f, 1.62898f, 18.58508f), true);
				mainCamera.SetDistance(0.7999998f, true);
				mainCamera.SetAroundAngle(new Vector2(-227.0059f, -10.18634f), true);
			}
			else if (bgName == "EmpireClub_Entrance")
			{
				mainCamera.SetTargetPos(new Vector3(4.084215f, 5.501422f, 11.13918f), true);
				mainCamera.SetDistance(1.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-165.0296f, 11.24223f), true);
			}
			else if (bgName == "MyRoom")
			{
				mainCamera.SetTargetPos(new Vector3(5.273936f, 2.515735f, 3.353783f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-110.838f, 16.8323f), true);
			}
			else if (bgName == "HeroineRoom_B1")
			{
				mainCamera.SetTargetPos(new Vector3(2.837114f, 2.19285f, 3.352386f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-128.5022f, 12.48449f), true);
			}
			else if (bgName == "HeroineRoom_A1")
			{
				mainCamera.SetTargetPos(new Vector3(2.837114f, 2.19285f, 3.352386f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-128.5022f, 12.48449f), true);
			}
			else if (bgName == "HeroineRoom_C1")
			{
				mainCamera.SetTargetPos(new Vector3(2.837114f, 2.19285f, 3.352386f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-128.5022f, 12.48449f), true);
			}
			else if (bgName == "ShinShitsumu")
			{
				mainCamera.SetTargetPos(new Vector3(-2.828141f, 2.77968f, 4.463314f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-210.2392f, 18.07455f), true);
			}
			else if (bgName == "Theater")
			{
				mainCamera.SetTargetPos(new Vector3(-10.00124f, 0.8031937f, 3.407116f), true);
				mainCamera.SetDistance(0.1f, true);
				mainCamera.SetAroundAngle(new Vector2(-311.137f, 2.236061f), true);
			}
			else if (bgName == "DanceRoom")
			{
				mainCamera.SetTargetPos(new Vector3(0.7564614f, 1.38443f, -1.607882f), true);
				mainCamera.SetDistance(2f, true);
				mainCamera.SetAroundAngle(new Vector2(-138.9819f, 14.03727f), true);
			}
			else
			{
				mainCamera.SetTargetPos(new Vector3(0.7564614f, 1.38443f, -1.607882f), true);
				mainCamera.SetDistance(2f, true);
				mainCamera.SetAroundAngle(new Vector2(-138.9819f, 14.03727f), true);
				bgName = "DanceRoom";
			}
			GameMain.Instance.BgMgr.ChangeBg(bgName);
		};
		string[] array = new string[]
		{
			"EmpireClub_Rotary",
			"EmpireClub_Entrance",
			"MyRoom",
			"HeroineRoom_B1",
			"HeroineRoom_A1",
			"HeroineRoom_C1",
			"ShinShitsumu",
			"Theater",
			"DanceRoom"
		};
		string obj = array[UnityEngine.Random.Range(0, array.Length)];
		action(obj);
		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(StartDailyAPI.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);
		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 StartDailyAPI.dgOnSceneStartCallBack m_dgStart;

	private StartDailyAPI.dgOnSceneFinalCallBack m_dgFinal;

	public delegate void dgOnSceneStartCallBack();

	public delegate void dgOnSceneFinalCallBack();
}
