using System;
using UnityEngine;

public class SceneWarning : MonoBehaviour
{
	private void Awake()
	{
		string name = "Warning_eng_try";
		GameObject gameObject = GameObject.Find("UI Root");
		gameObject.transform.Find(name).gameObject.SetActive(true);
	}

	private void Start()
	{
		GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
		GameMain.Instance.MainCamera.FadeOutNoUI(0f, true);
		GameMain.Instance.MainCamera.FadeIn(1f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeIn), true, true, default(Color));
		this.m_eMode = SceneWarning.Mode.FadeIn;
		GameMain.Instance.SysShortcut.gameObject.SetActive(false);
	}

	private void Update()
	{
		if (this.m_eMode == SceneWarning.Mode.ClickWait)
		{
			if (this.GetAnyMouseAndKey())
			{
				GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.IClick);
				GameMain.Instance.LoadIcon.SetForceDraw(true);
				GameMain.Instance.CharacterMgr.LoadDefault();
				this.m_eMode = SceneWarning.Mode.Loading;
			}
		}
		else if (this.m_eMode == SceneWarning.Mode.Loading && !GameMain.Instance.CharacterMgr.IsBusy())
		{
			GameMain.Instance.LoadIcon.SetForceDraw(false);
			GameMain.Instance.CharacterMgr.VisibleAll(false);
			GameMain.Instance.MainCamera.FadeOut(1f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeOut), true, default(Color));
			GameMain.Instance.MainCamera.FadeInNoUI(0f, true);
			this.m_eMode = SceneWarning.Mode.FadeOut;
		}
	}

	private void OnCompleteFadeIn()
	{
		this.m_eMode = SceneWarning.Mode.ClickWait;
	}

	private void OnCompleteFadeOut()
	{
		GameMain.Instance.ScriptMgr.LoadAdvScenarioScript("AllMain.ks", string.Empty);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	private bool GetAnyMouseAndKey()
	{
		return NInput.GetMouseButtonUp(0) || NInput.GetMouseButtonUp(1) || NInput.GetMouseButtonUp(2) || Input.GetKeyUp(KeyCode.Return) || GameMain.Instance.IsForceSkip();
	}

	private SceneWarning.Mode m_eMode;

	private enum Mode
	{
		FadeIn,
		ClickWait,
		Loading,
		FadeOut
	}
}
