using System;
using UnityEngine;
using UnityEngine.UI;

public class KasaSceneMgr<T> : MonoBehaviour where T : KasaSceneMgr<T>
{
	public static T Instance { get; protected set; }

	protected virtual void Awake()
	{
		KasaSceneMgr<T>.Instance = (this as T);
		this.MainRecet();
		GameMain.Instance.BgMgr.ChangeBg(this.m_BgName);
		GameMain.Instance.SoundMgr.PlayBGM(this.m_BgmName, 0f, true);
		GameMain.Instance.MainCamera.SetControl(this.m_IsControll);
		this.SetCamera();
		uGUIUtility.GetEventSystem();
		if (this.m_uGUIRaycaster)
		{
			this.m_uGUIRaycaster.enabled = false;
		}
		if (this.m_IscharaLoad)
		{
			base.StartCoroutine(KasaiUtility.CharaLoadWait(new Action(this.LoadEnd)));
		}
		else
		{
			GameMain.Instance.CharacterMgr.DeactivateCharaAll();
			GameMain.Instance.MainCamera.FadeIn(0.5f, false, new CameraMain.dgOnCompleteFade(this.FadeInEnd), true, true, default(Color));
		}
	}

	protected virtual void FadeInEnd()
	{
		if (this.m_uGUIRaycaster)
		{
			this.m_uGUIRaycaster.enabled = true;
		}
	}

	protected virtual void LoadEnd()
	{
		GameMain.Instance.MainCamera.FadeIn(0.5f, false, new CameraMain.dgOnCompleteFade(this.FadeInEnd), true, true, default(Color));
	}

	protected void SetCamera()
	{
		GameMain.Instance.MainCamera.SetTargetPos(this.m_TargetPos, true);
		GameMain.Instance.MainCamera.SetDistance(this.m_Distance, true);
		GameMain.Instance.MainCamera.SetAroundAngle(this.m_AroundAngle, true);
	}

	protected void MainRecet()
	{
		GameMain.Instance.CharacterMgr.ResetCharaPosAll();
		GameMain.Instance.CharacterMgr.CharaAllOfsetRot(Vector3.zero);
		GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
		GameMain.Instance.MainLight.Reset();
	}

	protected virtual void FadeOut()
	{
		GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.FadeOutEnd), true, default(Color));
	}

	protected virtual void FadeOutEnd()
	{
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_JumpLabel);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	[SerializeField]
	[Header("背景名")]
	protected string m_BgName;

	[SerializeField]
	[Header("BGM")]
	protected string m_BgmName;

	[SerializeField]
	[Header("カメラ設定")]
	protected Vector3 m_TargetPos = Vector3.up * 1.61f;

	[SerializeField]
	protected float m_Distance = 2f;

	[SerializeField]
	protected Vector2 m_AroundAngle = new Vector2(-180f, 10f);

	[SerializeField]
	protected bool m_IsControll = true;

	[SerializeField]
	[Header("キャラクターロードするか")]
	protected bool m_IscharaLoad;

	[SerializeField]
	[Header("uGUI操作管理")]
	private GraphicRaycaster m_uGUIRaycaster;

	protected string m_NextLabel = string.Empty;

	protected string m_CancelLabel = string.Empty;

	protected string m_JumpLabel = string.Empty;
}
