using System;
using Fove;
using UnityEngine;

public class SceneLogo : MonoBehaviour
{
	private void Start()
	{
		GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
		if (GameMain.Instance.VRMode)
		{
			GameMain.Instance.BgMgr.ChangeBg("EmpireClub_Rotary_Night");
			GameMain.Instance.MainCamera.SetPos(new Vector3(0f, 1.855f, 20f));
			GameMain.Instance.MainCamera.SetRotation(new Vector3(0f, -180f, 0f));
			GameMain.Instance.OvrMgr.OvrCamera.ReCallcOffset();
			GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f);
		}
		GameMain.Instance.MainCamera.FadeOutNoUI(0f, true);
		GameMain.Instance.MainCamera.FadeIn(1f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeIn), true, true, default(Color));
		this.m_eMode = SceneLogo.Mode.FadeIn;
		GameMain.Instance.SysShortcut.gameObject.SetActive(false);
		if (GameMain.Instance.VRMode)
		{
			this.m_guiStyle = new GUIStyle();
			this.m_guiStyle.fontSize = 15;
			this.m_styleState = new GUIStyleState();
			this.m_styleState.textColor = Color.gray;
			this.m_guiStyle.normal = this.m_styleState;
		}
	}

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

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

	private void OnCompleteFadeOut()
	{
		if (GameMain.Instance.VRMode && GameMain.Instance.VRFamily == GameMain.VRFamilyType.NON)
		{
			Application.Quit();
			return;
		}
		GameMain.Instance.LoadScene("SceneWarning");
	}

	private void OnGUI()
	{
		if (GameMain.Instance.VRMode)
		{
			string text = "VR デバイスが見つけられません。";
			if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.Oculus)
			{
				text = string.Concat(new object[]
				{
					"Oculus Ver.",
					OVRPlugin.version,
					" Wrapper Ver.",
					OVRPlugin.wrapperVersion
				});
			}
			else if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.HTC)
			{
				SteamVR instance = SteamVR.instance;
				if (instance != null)
				{
					text = "SteamVR Ver.1.1.0 Model Number." + instance.hmd_ModelNumber + " TrackingSystemName." + instance.hmd_TrackingSystemName;
				}
			}
			else if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.FOVE)
			{
				try
				{
					FoveHeadset headset = FoveHeadset.GetHeadset();
					if (headset.IsHardwareConnected() && headset.IsHardwareReady())
					{
						SFVR_Versions softwareVersions = headset.GetSoftwareVersions();
						string text2 = string.Concat(new object[]
						{
							softwareVersions.runtimeMajor,
							".",
							softwareVersions.runtimeMinor,
							".",
							softwareVersions.runtimeBuild
						});
						string text3 = string.Concat(new object[]
						{
							softwareVersions.clientMajor,
							".",
							softwareVersions.clientMinor,
							".",
							softwareVersions.clientBuild
						});
						text = string.Concat(new object[]
						{
							"FOVE ClientVersion.",
							text3,
							" RuntimeVersion.",
							text2,
							" FirmwareVersion.",
							softwareVersions.firmware
						});
					}
				}
				catch (Exception ex)
				{
					Debug.LogError("FoveInterface 例外発生 in Logo：" + ex.Message);
				}
			}
			if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.NON)
			{
				GUI.Label(new Rect(10f, 10f, 200f, 40f), text + " クリックするとゲームを終了します。");
			}
			else
			{
				GUI.Label(new Rect(10f, 10f, 200f, 40f), text, this.m_guiStyle);
			}
		}
	}

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

	private SceneLogo.Mode m_eMode;

	private GUIStyle m_guiStyle;

	private GUIStyleState m_styleState;

	private enum Mode
	{
		FadeIn,
		ClickWait,
		FadeOut
	}
}
