using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;

public class SceneVRCommunication : MonoBehaviour
{
	public static SceneVRCommunication Instance
	{
		get
		{
			return SceneVRCommunication.m_this;
		}
	}

	public bool IsFreeMode
	{
		get
		{
			return this.m_bFreeMode;
		}
	}

	public bool IsEnableSkip
	{
		get
		{
			return this.m_bEnableSkip;
		}
	}

	public bool UiNoMoveMode
	{
		get
		{
			return this.m_bUiNoMove;
		}
		set
		{
			this.m_bUiNoMove = value;
		}
	}

	public bool UiNoTimeMode
	{
		get
		{
			return this.m_bUiNoTime;
		}
		set
		{
			this.m_bUiNoTime = value;
		}
	}

	public bool UiNoHomeMode
	{
		get
		{
			return this.m_bUiNoHome;
		}
		set
		{
			this.m_bUiNoHome = value;
		}
	}

	public bool MouseOnlyMode
	{
		get
		{
			return this.m_bMouseOnlyMode;
		}
	}

	public VRChoices Choices
	{
		get
		{
			return this.m_VRChoices;
		}
	}

	public VRMiniGameManager MiniGameMgr
	{
		get
		{
			return this.m_VRMinigameMgr;
		}
	}

	public VRTouchComm TouchComm
	{
		get
		{
			return this.m_VRTouchComm;
		}
	}

	public bool KaraokeMode
	{
		get
		{
			return this.m_bKaraokeMode;
		}
	}

	private void Awake()
	{
		if (!GameMain.Instance.VRMode || GameMain.Instance.VRFamily == GameMain.VRFamilyType.NON)
		{
			GameMain.Instance.VRDummyMode = true;
			GameMain.Instance.OvrInit();
			GameMain.Instance.MainCamera.SetPos(new Vector3(0f, 1.6f, 0f));
			GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
		}
		UICamera.isDisableRightClick = true;
		GameMain.Instance.OvrMgr.OvrCamera.ChangeControllerNew(true);
		GameMain.Instance.OvrMgr.OvrCamera.IsForceRightClickUiToggle = true;
		this.m_VRMinigameMgr = base.GetComponent<VRMiniGameManager>();
		if (this.m_VRMinigameMgr == null)
		{
			this.m_VRMinigameMgr = base.gameObject.AddComponent<VRMiniGameManager>();
		}
		NDebug.Assert(this.m_VRMinigameMgr != null, "MiniGameManagerがみつかりません。");
		this.m_VRTouchComm = base.GetComponent<VRTouchComm>();
		if (this.m_VRTouchComm == null)
		{
			this.m_VRTouchComm = base.gameObject.AddComponent<VRTouchComm>();
		}
		NDebug.Assert(this.m_VRTouchComm != null, "VRTouchCommがみつかりません。");
	}

	private void Start()
	{
		SceneVRCommunication.m_this = this;
		this.m_goUiRoot = GameObject.Find("UI Root");
		NDebug.Assert(this.m_goUiRoot != null, "UI Rootが見つかりません。");
		this.m_VRChoices = base.GetComponent<VRChoices>();
		if (this.m_VRChoices == null)
		{
			this.m_VRChoices = base.gameObject.AddComponent<VRChoices>();
		}
		GameMain.Instance.MsgWnd.CloseMessageWindowPanel();
		GameMain.Instance.MsgWnd.ForceDisableWindow(true);
		GameMain.Instance.ScriptMgr.adv_kag.vr_commu_mode = true;
		if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.NON)
		{
			this.m_bManShow = GameMain.Instance.CMSystem.VRManShow;
		}
		Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
		if (man != null)
		{
			man.body0.SetManHide(!this.m_bManShow);
		}
		this.m_dicTagBackup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup;
		Dictionary<string, string> dicTagBackup = this.m_dicTagBackup;
		string text;
		if (dicTagBackup != null && dicTagBackup.TryGetValue("name", out text) && text.Contains("SceneVRCommunication"))
		{
			string text2;
			if (dicTagBackup.TryGetValue("start_jump_file", out text2))
			{
				this.m_strStartScriptFile = text2 + ".ks";
			}
			if (dicTagBackup.TryGetValue("start_jump_label", out text2))
			{
				this.m_strStartScriptLabel = text2;
			}
			if (dicTagBackup.TryGetValue("karaoke", out text))
			{
				this.m_bKaraokeMode = true;
			}
		}
		base.StartCoroutine(this.CoScriptStart());
	}

	private IEnumerator CoScriptStart()
	{
		yield return null;
		Debug.Log("Canvas Manager attach start.");
		if (!this.m_bKaraokeMode)
		{
			this.m_goCanvas = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("SceneVRCommunication/Tablet/Canvas Manager"));
		}
		else
		{
			this.m_goCanvas = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("SceneVRCommunication/Tablet/Karaoke/Prefab/Canvas Manager Mini"));
		}
		NDebug.Assert(this.m_goCanvas != null, "Canvas Managerが見つかりません。");
		VRCanvasManager.Instance.SetSkipButtonEvent(new UnityAction(this.OnSkipScenario));
		this.m_goCanvas.transform.SetParent(GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.transform, false);
		this.m_goCanvas.transform.localPosition = Vector3.zero;
		this.m_goCanvas.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
		Debug.Log("Canvas Manager attach finish.");
		yield return null;
		Debug.Log("Canvas Manager attach wait1.");
		yield return null;
		Debug.Log("Canvas Manager attach wait2.");
		bool bStart = false;
		if (!string.IsNullOrEmpty(this.m_strStartScriptFile))
		{
			GameMain.Instance.ScriptMgr.LoadAdvScenarioScript(this.m_strStartScriptFile, string.Empty);
			bStart = true;
		}
		if (!string.IsNullOrEmpty(this.m_strStartScriptLabel))
		{
			GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strStartScriptLabel);
			bStart = true;
		}
		if (bStart)
		{
			GameMain.Instance.ScriptMgr.adv_kag.Exec();
		}
		yield break;
	}

	private void OnDestroy()
	{
		this.Uninit();
	}

	private void Uninit()
	{
		if (!this.m_bFinished)
		{
			GameMain instance = GameMain.Instance;
			if (instance != null)
			{
				if (this.TouchComm != null)
				{
					this.TouchComm.Touch_End();
					this.TouchComm.enabled = false;
				}
				if (this.Choices != null)
				{
					this.Choices.Clear();
					this.Choices.enabled = false;
				}
				UnityEngine.Object.DestroyImmediate(this.m_goCanvas);
				if (instance.SoundMgr != null)
				{
					instance.SoundMgr.VoiceStopAll();
					instance.SoundMgr.StopBGM(0.5f);
				}
				CharacterMgr characterMgr = instance.CharacterMgr;
				if (characterMgr != null)
				{
					for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
					{
						Maid stockMaid = characterMgr.GetStockMaid(i);
						if (stockMaid != null && stockMaid.body0 != null && stockMaid.body0.isLoadedBody)
						{
							stockMaid.body0.MuneYureL(1f);
							stockMaid.body0.MuneYureR(1f);
							stockMaid.IKTargetToBone("左手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
							stockMaid.IKTargetToBone("右手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
							stockMaid.transform.localScale = Vector3.one;
							stockMaid.StopKuchipakuPattern();
							stockMaid.EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
							stockMaid.DelPrefabAll();
						}
					}
					for (int j = 0; j < characterMgr.GetStockManCount(); j++)
					{
						Maid stockMan = characterMgr.GetStockMan(j);
						if (stockMan != null && stockMan.body0 != null && stockMan.body0.isLoadedBody)
						{
							stockMan.IKTargetToBone("左手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
							stockMan.IKTargetToBone("右手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
							stockMan.DelPrefabAll();
						}
					}
					string[] array = new string[]
					{
						"handitem",
						"kousoku_upper",
						"kousoku_lower",
						"skirt",
						"panz",
						"mizugi",
						"onepiece",
						"accanl",
						"accvag",
						"KubiScl",
						"UdeScl",
						"DouPer",
						"sintyou",
						"kata"
					};
					for (int k = 0; k < characterMgr.GetMaidCount(); k++)
					{
						Maid maid = characterMgr.GetMaid(k);
						if (maid != null && maid.Visible)
						{
							maid.OpenMouth(false);
							maid.DelPrefabAll();
							for (int l = 0; l < array.Length; l++)
							{
								maid.ResetProp(array[l], true);
							}
							maid.AllProcPropSeqStart();
						}
					}
					for (int m = 0; m < characterMgr.GetManCount(); m++)
					{
						Maid man = characterMgr.GetMan(m);
						if (man != null && man.Visible)
						{
							man.DelPrefabAll();
							for (int n = 0; n < array.Length; n++)
							{
								man.ResetProp(array[n], false);
							}
							man.AllProcPropSeqStart();
						}
					}
				}
				if (VRTestInputModule.Instance != null)
				{
					VRTestInputModule.Instance.enabled = false;
				}
				if (instance.OvrMgr.OvrCamera != null)
				{
					VRTestInputModule[] componentsInChildren = instance.OvrMgr.OvrCamera.GetComponentsInChildren<VRTestInputModule>(true);
					foreach (VRTestInputModule vrtestInputModule in componentsInChildren)
					{
						vrtestInputModule.enabled = false;
						UnityEngine.Object.DestroyImmediate(vrtestInputModule.gameObject);
					}
					VRControllerLaserCast[] componentsInChildren2 = instance.OvrMgr.OvrCamera.GetComponentsInChildren<VRControllerLaserCast>(true);
					foreach (VRControllerLaserCast vrcontrollerLaserCast in componentsInChildren2)
					{
						vrcontrollerLaserCast.enabled = false;
						UnityEngine.Object.DestroyImmediate(vrcontrollerLaserCast.gameObject);
					}
					instance.OvrMgr.OvrCamera.ForceHideUI(false);
					instance.OvrMgr.OvrCamera.HandLimitMode = AVRControllerBehavior.LIMIT_MODE.NORMAL;
					instance.OvrMgr.OvrCamera.ChangeControllerNew(GameMain.Instance.CMSystem.OvrUseNewControllerType);
					instance.OvrMgr.OvrCamera.IsForceRightClickUiToggle = false;
				}
				UICamera.isDisableRightClick = false;
				instance.MsgWnd.ForceDisableWindow(false);
				ScriptManager scriptMgr = instance.ScriptMgr;
				if (scriptMgr != null && scriptMgr.adv_kag != null)
				{
					scriptMgr.adv_kag.vr_commu_mode = false;
					if (scriptMgr.adv_kag.kag != null)
					{
						scriptMgr.adv_kag.kag.TextClear();
					}
				}
				Maid man2 = instance.CharacterMgr.GetMan(0);
				if (man2 != null)
				{
					man2.body0.SetManHide(false);
				}
				instance.CMSystem.SetTmpGenericFlag("VR夜伽中", 0);
				instance.CMSystem.SetTmpGenericFlag("VRエディット中", 0);
				if (instance.VRDeviceTypeID == GameMain.VRDeviceType.NON)
				{
					instance.OvrUninit();
				}
				else if (instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT || instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH)
				{
					instance.OvrMgr.OvrCamera.ChangeTouchUse(true);
				}
			}
			this.m_bFinished = true;
		}
	}

	public void kagFreeSceneSwitch(bool f_bFreeMode, bool f_bEnableSkip = true, bool f_bNoStartText = false)
	{
		this.m_bEnableSkip = false;
		if (!f_bFreeMode)
		{
			this.TouchComm.Touch_End();
			if (this.m_coFreeSceneStartText != null)
			{
				base.StopCoroutine(this.m_coFreeSceneStartText);
			}
			ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
			this.m_strFreeSceneEndScriptName = scriptMgr.adv_kag.kag.GetCurrentFileName();
			this.m_bEnableSkip = f_bEnableSkip;
		}
		else
		{
			if (!this.m_bKaraokeMode && !f_bNoStartText)
			{
				this.StartFreeSceneText();
			}
			this.m_strFreeSceneEndScriptName = string.Empty;
		}
		GameMain.Instance.OvrMgr.OvrCamera.HandLimitMode = ((!f_bFreeMode) ? AVRControllerBehavior.LIMIT_MODE.NO_WARP : AVRControllerBehavior.LIMIT_MODE.NORMAL);
		if (!this.m_bFreeMode || !f_bFreeMode)
		{
		}
		this.m_bFreeMode = f_bFreeMode;
		this.KagTabletUIUpdate();
	}

	public void StartDay()
	{
		Farm_Mng.Instance.Day_Start();
		this.KagTabletUIUpdate();
	}

	public void KagTabletUIUpdate()
	{
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.UpdateCanvas();
	}

	private void DupCheck(GameObject[] value)
	{
	}

	public void KagBGChangeInit(Dictionary<string, string> f_tag_backup)
	{
		try
		{
			GameObject[] array = GameObject.FindGameObjectsWithTag("OvrEventObj");
			this.DupCheck(array);
			this.m_dicEventObj = array.ToDictionary((GameObject n) => n.name, (GameObject n) => n);
			GameObject[] array2 = GameObject.FindGameObjectsWithTag("OvrEventGroup");
			this.DupCheck(array2);
			this.m_dicEventGroup = array2.ToDictionary((GameObject n) => n.name, (GameObject n) => new SceneVRCommunication.EventGroup(n, this.FindChild(n.transform, null)));
		}
		catch (Exception ex)
		{
			NDebug.Assert("同じ名前のオブジェクトが入ったプレハブをロードしようとしませんでしたか？\n" + ex.Message, false);
		}
		if (f_tag_backup != null && f_tag_backup.ContainsKey("farm"))
		{
			Farm_Mng.Instance.Farm_Start();
		}
	}

	public void KagEventObj(string f_strName, int f_nVisible, int f_nTrigger, int f_nGrab, string f_strAnimation)
	{
		GameObject gameObject;
		if (this.m_dicEventObj.TryGetValue(f_strName, out gameObject))
		{
			if (f_nVisible != 0)
			{
				gameObject.SetActive(f_nVisible == 1);
			}
			if (f_nTrigger != 0)
			{
				VREventTrigger component = gameObject.GetComponent<VREventTrigger>();
				if (component != null)
				{
					component.SetEnableEvent(f_nTrigger == 1);
				}
			}
			if (f_nGrab != 0)
			{
				VREventTrigger component2 = gameObject.GetComponent<VREventTrigger>();
				if (component2 != null)
				{
					component2.SetEnableCollider(f_nGrab == 1);
				}
			}
			if (!string.IsNullOrEmpty(f_strAnimation))
			{
				Animator component3 = gameObject.GetComponent<Animator>();
				if (component3 != null)
				{
					component3.SetTrigger(f_strAnimation);
				}
			}
		}
		else
		{
			NDebug.Assert("指定名のオブジェクトがありません。" + f_strName, false);
		}
	}

	public void KagEventObjGroup(string f_strName, int f_nVisible, int f_nTrigger, int f_nGrab)
	{
		SceneVRCommunication.EventGroup eventGroup;
		if (this.m_dicEventGroup.TryGetValue(f_strName, out eventGroup))
		{
			if (f_nVisible != 0 || f_nTrigger != 0 || f_nGrab != 0)
			{
				for (int i = 0; i < eventGroup.listChild.Count; i++)
				{
					if (f_nVisible != 0)
					{
						eventGroup.listChild[i].SetActive(f_nVisible == 1);
					}
					VREventTrigger component = eventGroup.listChild[i].GetComponent<VREventTrigger>();
					if (component != null)
					{
						if (f_nTrigger != 0)
						{
							component.SetEnableEvent(f_nTrigger == 1);
						}
						if (f_nGrab != 0)
						{
							component.SetEnableCollider(f_nGrab == 1);
						}
					}
				}
			}
		}
		else
		{
			NDebug.Assert("指定名のオブジェクトグループがありません。" + f_strName, false);
		}
	}

	public void KagDoNextTime()
	{
		string str = "VRmainOP_0001";
		string label_name = string.Empty;
		SceneVRCommunication.VR_TIME nowTime = this.GetNowTime();
		if (nowTime == SceneVRCommunication.VR_TIME.MONING)
		{
			GameMain.Instance.CharacterMgr.status.SetFlag("時間帯", 2);
			label_name = "*昼＿ループ";
		}
		else if (nowTime == SceneVRCommunication.VR_TIME.DAY)
		{
			GameMain.Instance.CharacterMgr.status.SetFlag("時間帯", 3);
			label_name = "*夜＿ループ";
		}
		else if (nowTime == SceneVRCommunication.VR_TIME.NIGHT)
		{
			GameMain.Instance.CharacterMgr.status.SetFlag("時間帯", 1);
			label_name = "*朝＿ループ";
			this.StartDay();
		}
		this.KagTabletUIUpdate();
		GameMain.Instance.ScriptMgr.LoadAdvScenarioScript(str + ".ks", string.Empty);
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(label_name);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	private List<GameObject> FindChild(Transform f_trParent, List<GameObject> f_list = null)
	{
		if (f_list == null)
		{
			f_list = new List<GameObject>();
		}
		for (int i = 0; i < f_trParent.childCount; i++)
		{
			this.FindChild(f_trParent.GetChild(i), f_list);
		}
		if (f_trParent.tag == "OvrEventObj")
		{
			f_list.Add(f_trParent.gameObject);
		}
		return f_list;
	}

	public void YotogiStart(Action f_actDecide, Action f_actCancel)
	{
		this.m_actDecide = f_actDecide;
		this.m_actCancel = f_actCancel;
	}

	public void MaidEditStart()
	{
		if (GameMain.Instance.CharacterMgr.GetMaid(0) == null)
		{
			Debug.LogError("エディット対象メイドが居ません。");
			return;
		}
		ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
		string currentFileName = scriptMgr.adv_kag.kag.GetCurrentFileName();
		GameMain.Instance.ScriptMgr.EvalScript("tf['back_edit_script_name'] = '" + currentFileName + "';");
		scriptMgr.LoadAdvScenarioScript(Path.ChangeExtension("vr_edit_call", ".ks"), "*start_vr");
		scriptMgr.adv_kag.Exec();
	}

	public SceneVRCommunication.VR_TIME GetNowTime()
	{
		SceneVRCommunication.VR_TIME result = SceneVRCommunication.VR_TIME.DAY;
		int flag = GameMain.Instance.CharacterMgr.status.GetFlag("時間帯");
		if (flag == 0 || flag == 1)
		{
			result = SceneVRCommunication.VR_TIME.MONING;
		}
		else if (flag == 2)
		{
			result = SceneVRCommunication.VR_TIME.DAY;
		}
		else if (flag == 3)
		{
			result = SceneVRCommunication.VR_TIME.NIGHT;
		}
		else
		{
			NDebug.Assert("現在の時間帯が不正です", false);
		}
		return result;
	}

	public void KagStartDayTimeShow(string f_strReturnFile, string f_strReturnLabel)
	{
		this.m_strRetrunFile = f_strReturnFile;
		this.m_strRetrunLabel = f_strReturnLabel;
		Day_UI.Day_UI_Start(new Action(this.OnEndDayTimeShow));
	}

	private void OnEndDayTimeShow()
	{
		ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
		if (!string.IsNullOrEmpty(this.m_strRetrunFile))
		{
			scriptMgr.LoadAdvScenarioScript(this.m_strRetrunFile + ".ks", string.Empty);
		}
		if (!string.IsNullOrEmpty(this.m_strRetrunLabel))
		{
			scriptMgr.adv_kag.JumpLabel(this.m_strRetrunLabel);
		}
		scriptMgr.adv_kag.Exec();
	}

	public void KagDialog(string f_strText, string f_strLabelOk, string f_strLabelCancel, string f_strLabelYes, string strLabelNo)
	{
		this.m_DialogMenu = VRDialogMenu.CreateDialog();
		VRDialogMenu.TYPE_STYLE type_STYLE = (VRDialogMenu.TYPE_STYLE)0;
		this.m_strLabelOk = f_strLabelOk;
		this.m_strLabelCancel = f_strLabelCancel;
		this.m_strLabelYes = f_strLabelYes;
		this.m_strLabelNo = strLabelNo;
		if (!string.IsNullOrEmpty(this.m_strLabelOk))
		{
			type_STYLE |= VRDialogMenu.TYPE_STYLE.OK;
		}
		if (!string.IsNullOrEmpty(this.m_strLabelCancel))
		{
			type_STYLE |= VRDialogMenu.TYPE_STYLE.CANCEL;
		}
		if (!string.IsNullOrEmpty(this.m_strLabelYes))
		{
			type_STYLE |= VRDialogMenu.TYPE_STYLE.YES;
		}
		if (!string.IsNullOrEmpty(this.m_strLabelNo))
		{
			type_STYLE |= VRDialogMenu.TYPE_STYLE.NO;
		}
		this.m_DialogMenu.OpenDialog(f_strText, type_STYLE, new UnityAction<VRDialogMenu.TYPE_STYLE>(this.OnEndDialog));
	}

	private void OnEndDialog(VRDialogMenu.TYPE_STYLE style)
	{
		string text = string.Empty;
		if (style == VRDialogMenu.TYPE_STYLE.OK)
		{
			text = this.m_strLabelOk;
		}
		else if (style == VRDialogMenu.TYPE_STYLE.CANCEL)
		{
			text = this.m_strLabelCancel;
		}
		if (style == VRDialogMenu.TYPE_STYLE.YES)
		{
			text = this.m_strLabelYes;
		}
		else if (style == VRDialogMenu.TYPE_STYLE.NO)
		{
			text = this.m_strLabelNo;
		}
		this.m_DialogMenu.CloseDialog();
		NDebug.Assert(!string.IsNullOrEmpty(text), "ダイアログとび先ラベルがありません");
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(text);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	public void KagStartMovieMusicPlayerTV()
	{
		VRExternalFileLoader.Event_OpenSelect();
	}

	public void KagVRMovieTV(bool f_bStart, string f_strFileName = "", bool f_bLoop = false)
	{
		if (f_bStart)
		{
			VRExternalFileLoader.Event_PlayMovie(f_strFileName);
		}
		else
		{
			VRExternalFileLoader.Event_CloseMovie();
		}
	}

	public void KagPlantWindowShow(string strFileName, string strLabelOK, string strLabelCancel)
	{
		this.m_strFilePlant = strFileName;
		this.m_strLabelPlantOk = strLabelOK;
		this.m_strLabelPlantCancel = strLabelCancel;
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.OpenVRCulture(new UnityAction(this.OnPlantOk), new UnityAction(this.OnPlantCancel));
	}

	private void OnPlantOk()
	{
		if (!string.IsNullOrEmpty(this.m_strFilePlant))
		{
			GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(this.m_strFilePlant, string.Empty);
		}
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strLabelPlantOk);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	private void OnPlantCancel()
	{
		if (!string.IsNullOrEmpty(this.m_strFilePlant))
		{
			GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(this.m_strFilePlant, string.Empty);
		}
		GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strLabelPlantCancel);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	public void KagPlantUpdate()
	{
		Farm_Mng.Instance.SyuKaku();
	}

	public void KagTutorialStart(string f_strReturnLabel)
	{
		this.m_strRetrunLabel = f_strReturnLabel;
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.OpenVRTutorialMenu(new UnityAction(this.OnEndTutorial));
	}

	private void OnEndTutorial()
	{
		if (!string.IsNullOrEmpty(this.m_strRetrunLabel))
		{
			GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strRetrunLabel);
		}
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	public void KagVRNoChangeBG(bool f_bStart)
	{
		this.m_bUiNoMove = f_bStart;
	}

	public void KagVRTrophyGet(string f_strText)
	{
		Trophy_UI.Trophy_Start(f_strText);
	}

	private void StartFreeSceneText()
	{
		if (this.m_coFreeSceneStartText != null)
		{
			base.StopCoroutine(this.m_coFreeSceneStartText);
		}
		this.m_coFreeSceneStartText = base.StartCoroutine(this.CoFreeSceneText());
	}

	private IEnumerator CoFreeSceneText()
	{
		yield return new WaitForSeconds(1f);
		SceneVRCommunication.VR_TIME time = this.GetNowTime();
		string[] aryTimeStr = new string[]
		{
			"朝",
			"昼",
			"夜"
		};
		string strBGName = string.Empty;
		if (GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa".ToLower() || GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa_Night".ToLower())
		{
			strBGName = "ヴィラ１Ｆ";
		}
		else if (GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa_BedRoom".ToLower() || GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa_BedRoom_Night".ToLower())
		{
			strBGName = "ヴィラ２Ｆ";
		}
		else if (GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa_Farm".ToLower() || GameMain.Instance.BgMgr.GetBGName().ToLower() == "Villa_Farm_Night".ToLower())
		{
			strBGName = "庭";
		}
		else if (GameMain.Instance.BgMgr.GetBGName().ToLower() == "Sea_VR".ToLower() || GameMain.Instance.BgMgr.GetBGName().ToLower() == "Sea_VR_Night".ToLower())
		{
			strBGName = "海岸";
		}
		else if (GameMain.Instance.BgMgr.GetBGName().ToLower() == "Rotenburo".ToLower() || GameMain.Instance.BgMgr.GetBGName().ToLower() == "Rotenburo_Night".ToLower())
		{
			strBGName = "露天風呂";
		}
		if (!string.IsNullOrEmpty(strBGName))
		{
			FreeScene_UI.FreeScene_Start(strBGName + "\u3000" + aryTimeStr[(int)this.GetNowTime()], null);
		}
		this.m_coFreeSceneStartText = null;
		yield break;
	}

	public void KagRentalMaidSelectStart()
	{
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.OpenVRRentalMaid();
	}

	public void KagTouchUseSelect(string f_strReturnLabel)
	{
		this.m_strRetrunLabel = f_strReturnLabel;
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.OpenVRDecideUseTouch(new UnityAction<bool>(this.OnTouchUseSelect));
	}

	private void OnTouchUseSelect(bool f_bUseTouch)
	{
		GameMain.Instance.OvrMgr.OvrCamera.ChangeTouchUse(f_bUseTouch);
		if (!string.IsNullOrEmpty(this.m_strRetrunLabel))
		{
			GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strRetrunLabel);
		}
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	private void OnSkipScenario()
	{
		if (!string.IsNullOrEmpty(this.m_strFreeSceneEndScriptName))
		{
			GameMain.Instance.SoundMgr.VoiceStopAll();
			GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(this.m_strFreeSceneEndScriptName, string.Empty);
			GameMain.Instance.ScriptMgr.adv_kag.JumpLabel("*アフターファイル挿入箇所");
			GameMain.Instance.ScriptMgr.adv_kag.Exec();
		}
	}

	public void KagHintShow(string f_strHintMsg)
	{
		SelectMessage_UI.Message_Start(f_strHintMsg);
	}

	public void KagKaraokeWindowShow(string f_strReturnFile, string f_strReturnLabel)
	{
		this.m_strKaraokeRetrunFile = f_strReturnFile;
		this.m_strKaraokeRetrunLabel = f_strReturnLabel;
		VRCanvasManager instance = VRCanvasManager.Instance;
		instance.StartKaraokeMode(new Action(this.OnKaraokeCancel));
	}

	private void OnKaraokeCancel()
	{
		if (!string.IsNullOrEmpty(this.m_strKaraokeRetrunFile))
		{
			GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(this.m_strKaraokeRetrunFile, string.Empty);
		}
		if (!string.IsNullOrEmpty(this.m_strKaraokeRetrunLabel))
		{
			GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_strKaraokeRetrunLabel);
		}
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	public void OnEnd()
	{
		GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
		base.StartCoroutine(this.CoEnd());
	}

	private IEnumerator CoEnd()
	{
		yield return null;
		GameMain.Instance.UnloadPopScene();
		yield return null;
		this.Uninit();
		yield return null;
		Debug.Log("vr_end_call");
		GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile("vr_end_call.ks", string.Empty);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
		yield break;
	}

	private void Update()
	{
		if (GameMain.Instance.VRFamily == GameMain.VRFamilyType.NON && this.m_bManShow != GameMain.Instance.CMSystem.VRManShow)
		{
			this.m_bManShow = GameMain.Instance.CMSystem.VRManShow;
			Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
			if (man != null)
			{
				man.body0.SetManHide(!this.m_bManShow);
			}
		}
	}

	private static SceneVRCommunication m_this;

	private bool m_bFreeMode = true;

	private bool m_bEnableSkip;

	private bool m_bUiNoMove;

	private bool m_bUiNoTime;

	private bool m_bUiNoHome;

	private bool m_bMouseOnlyMode;

	private Dictionary<string, GameObject> m_dicEventObj;

	private VRChoices m_VRChoices;

	private VRMiniGameManager m_VRMinigameMgr;

	private VRTouchComm m_VRTouchComm;

	private GameObject m_goUiRoot;

	private string m_strRetrunFile = string.Empty;

	private string m_strRetrunLabel = string.Empty;

	private string m_strKaraokeRetrunFile = string.Empty;

	private string m_strKaraokeRetrunLabel = string.Empty;

	private Dictionary<string, SceneVRCommunication.EventGroup> m_dicEventGroup;

	public Dictionary<string, string> m_dicTagBackup;

	private Coroutine m_coFreeSceneStartText;

	private GameObject m_goCanvas;

	private string m_strFreeSceneEndScriptName;

	private bool m_bManShow;

	private bool m_bFinished;

	private bool m_bKaraokeMode;

	private string m_strStartScriptFile;

	private string m_strStartScriptLabel;

	private Action m_actDecide;

	private Action m_actCancel;

	private VRDialogMenu m_DialogMenu;

	private string m_strLabelOk = string.Empty;

	private string m_strLabelCancel = string.Empty;

	private string m_strLabelYes = string.Empty;

	private string m_strLabelNo = string.Empty;

	private string m_strFilePlant = string.Empty;

	private string m_strLabelPlantOk = string.Empty;

	private string m_strLabelPlantCancel = string.Empty;

	public enum VR_TIME
	{
		MONING,
		DAY,
		NIGHT,
		MAX
	}

	private class EventGroup
	{
		public EventGroup(GameObject go, List<GameObject> lst)
		{
			this.goParent = go;
			this.listChild = lst;
		}

		public GameObject goParent;

		public List<GameObject> listChild = new List<GameObject>();
	}
}
