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

public class SceneNetorareCheck : BaseMgr<SceneNetorareCheck>
{
	private void Start()
	{
		this.SceneStart();
		this.toggleDic.Add(SceneNetorareCheck.Type.LockNTRPlay, UTY.GetChildObject(this.toggleParent, "Toggle_LockNTRPlay/Toggle_On", false).GetComponent<UIToggle>());
		this.toggleDic.Add(SceneNetorareCheck.Type.LockUserDraftMaid, UTY.GetChildObject(this.toggleParent, "Toggle_LockUserDraftMaid/Toggle_On", false).GetComponent<UIToggle>());
		this.toggleDic.Add(SceneNetorareCheck.Type.IsComPlayer, UTY.GetChildObject(this.toggleParent, "Toggle_IsComPlayer/Toggle_On", false).GetComponent<UIToggle>());
		EventDelegate.Add(this.buttonOk.onClick, new EventDelegate.Callback(this.EndNextScene));
		this.uiTable = this.toggleParent.GetComponent<UITable>();
	}

	public void SceneStart()
	{
		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(false);
		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.BgMgr.ChangeBg("ShinShitsumu");
		GameMain.Instance.MainLight.SetIntensity(0.65f);
		GameMain.Instance.CharacterMgr.DeactivateCharaAll();
		GameMain.Instance.CharacterMgr.ResetCharaPosAll();
		GameMain.Instance.MainCamera.FadeIn(1f, false, null, true, true, default(Color));
	}

	public void EndNextScene()
	{
		GameMain.Instance.CharacterMgr.status.lockNTRPlay = this.toggleDic[SceneNetorareCheck.Type.LockNTRPlay].value;
		GameMain.Instance.CharacterMgr.status.lockUserDraftMaid = !this.toggleDic[SceneNetorareCheck.Type.LockUserDraftMaid].value;
		GameMain.Instance.CharacterMgr.status.isOldPlayer = this.toggleDic[SceneNetorareCheck.Type.IsComPlayer].value;
		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);
		string label_name = GameMain.Instance.ScriptMgr.adv_kag.tag_backup["label"];
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(label_name);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

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

	[SerializeField]
	private GameObject toggleParent;

	[SerializeField]
	private UIButton buttonOk;

	private UITable uiTable;

	private Dictionary<SceneNetorareCheck.Type, UIToggle> toggleDic = new Dictionary<SceneNetorareCheck.Type, UIToggle>();

	public enum Type
	{
		LockNTRPlay,
		LockUserDraftMaid,
		IsComPlayer
	}
}
