VRMainMenu.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class VRMainMenu : MonoBehaviour, InterfaceVRCanvas
  6. {
  7. private void Awake()
  8. {
  9. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Edit, this.m_ButtonEdit);
  10. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Yotogi, this.m_ButtonYotogi);
  11. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Nei, this.m_ButtonNei);
  12. this.m_ButtonArray.Add(VRMainMenu.ButtonType.ChangeBG, this.m_ButtonChangeBG);
  13. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Time, this.m_ButtonTime);
  14. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Config, this.m_ButtonConfig);
  15. this.m_ButtonArray.Add(VRMainMenu.ButtonType.VRConfig, this.m_ButtonVRConfig);
  16. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Trohy, this.m_ButtonTrohy);
  17. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Manual, this.m_ButtonManual);
  18. this.m_ButtonArray.Add(VRMainMenu.ButtonType.EndButton, this.m_ButtonEnd);
  19. this.m_ButtonArray.Add(VRMainMenu.ButtonType.Skip, this.m_ButtonSkip);
  20. }
  21. private void Start()
  22. {
  23. this.MainMenuUpdate();
  24. }
  25. public void Event_SetButtonEnabled(VRMainMenu.ButtonType type, bool flag)
  26. {
  27. if (!this.m_ButtonArray.ContainsKey(type))
  28. {
  29. return;
  30. }
  31. Button button = this.m_ButtonArray[type];
  32. if (button == null)
  33. {
  34. return;
  35. }
  36. button.interactable = flag;
  37. }
  38. public void Event_SetButtonActive(VRMainMenu.ButtonType type, bool flag)
  39. {
  40. if (!this.m_ButtonArray.ContainsKey(type))
  41. {
  42. return;
  43. }
  44. Button button = this.m_ButtonArray[type];
  45. if (button == null)
  46. {
  47. return;
  48. }
  49. button.gameObject.SetActive(flag);
  50. }
  51. public void ButtonEvent_OpenDialogEndVacation()
  52. {
  53. VRDialogMenu dialogMenu = VRDialogMenu.CreateDialog();
  54. VRDialogMenu.TYPE_STYLE style = (VRDialogMenu.TYPE_STYLE)12;
  55. dialogMenu.OpenDialog("本当にバカンスを終了する?", style, delegate(VRDialogMenu.TYPE_STYLE buttonType)
  56. {
  57. dialogMenu.CloseDialog();
  58. if (buttonType == VRDialogMenu.TYPE_STYLE.OK)
  59. {
  60. VRExternalFileLoader.Event_CloseMovie();
  61. SceneVRCommunication.Instance.OnEnd();
  62. }
  63. });
  64. }
  65. public void ButtonEvent_NextTime()
  66. {
  67. SceneVRCommunication sceneVRCom = SceneVRCommunication.Instance;
  68. if (sceneVRCom == null)
  69. {
  70. return;
  71. }
  72. VRExternalFileLoader.Event_CloseMovie();
  73. SceneVRCommunication.VR_TIME nowTime = sceneVRCom.GetNowTime();
  74. if (nowTime != SceneVRCommunication.VR_TIME.NIGHT)
  75. {
  76. sceneVRCom.KagDoNextTime();
  77. }
  78. else
  79. {
  80. VRSelectorMenu selector = VRSelectorMenu.CreateSelector();
  81. selector.SetSelectType(VRChoices.SelectPair.Type.Text);
  82. List<VRChoices.SelectPair> list = new List<VRChoices.SelectPair>();
  83. list.Add(new VRChoices.SelectPair("VIPへ進む", "0", 0, VRChoices.SelectPair.Type.Text, 0, -1f));
  84. list.Add(new VRChoices.SelectPair("翌日ヘ進む", "1", 0, VRChoices.SelectPair.Type.Text, 0, -1f));
  85. selector.SelectStart(list, delegate(VRChoices.SelectPair choice)
  86. {
  87. selector.SelectFinalize(null);
  88. if (choice.strLabel == "0")
  89. {
  90. VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.VIP);
  91. }
  92. else
  93. {
  94. VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu);
  95. sceneVRCom.KagDoNextTime();
  96. }
  97. });
  98. }
  99. }
  100. public void ButtonEvent_OpenConfig()
  101. {
  102. if (BaseMgr<ConfigMgr>.Instance != null)
  103. {
  104. BaseMgr<ConfigMgr>.Instance.OpenConfigPanel();
  105. }
  106. }
  107. public void ButtonEvent_OpenEdit()
  108. {
  109. VRDialogMenu dialog = VRDialogMenu.CreateDialog();
  110. VRDialogMenu.TYPE_STYLE style = (VRDialogMenu.TYPE_STYLE)12;
  111. dialog.OpenDialog("エディット画面を開きます。", style, delegate(VRDialogMenu.TYPE_STYLE type)
  112. {
  113. dialog.CloseDialog();
  114. if (type == VRDialogMenu.TYPE_STYLE.OK)
  115. {
  116. VRExternalFileLoader.Event_CloseMovie();
  117. SceneVRCommunication.Instance.MaidEditStart();
  118. }
  119. else
  120. {
  121. VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu);
  122. }
  123. });
  124. }
  125. public void ButtonEvent_OpenYotogi()
  126. {
  127. VRCanvasManager.Instance.IsYotogiSelecting = true;
  128. VRCanvasManager.Instance.CloseVRCanvas();
  129. VRCanvasManager.Instance.ClearCanvasStack();
  130. SceneVRCommunication.Instance.YotogiStart(delegate
  131. {
  132. VRExternalFileLoader.Event_CloseMovie();
  133. VRCanvasManager.Instance.IsYotogiSelecting = false;
  134. }, delegate
  135. {
  136. Canvas vrcanvas = VRCanvasManager.Instance.GetVRCanvas(VRCanvasManager.VRCanvasType.VRConfig);
  137. if (vrcanvas)
  138. {
  139. if (VRCanvasManager.Instance.m_CallbackCloseVRConfig != null)
  140. {
  141. VRCanvasManager.Instance.m_CallbackCloseVRConfig();
  142. }
  143. Transform transform = vrcanvas.transform.Find("Button return");
  144. Button component = transform.GetComponent<Button>();
  145. UICanvasFade component2 = vrcanvas.GetComponent<UICanvasFade>();
  146. component.onClick.RemoveAllListeners();
  147. }
  148. VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu);
  149. VRCanvasManager.Instance.IsYotogiSelecting = false;
  150. });
  151. }
  152. public void OnUpdateCanvas()
  153. {
  154. this.MainMenuUpdate();
  155. }
  156. private void MainMenuUpdate()
  157. {
  158. SceneVRCommunication instance = SceneVRCommunication.Instance;
  159. if (instance == null)
  160. {
  161. return;
  162. }
  163. Text componentInChildren = this.m_ButtonTime.GetComponentInChildren<Text>();
  164. if (componentInChildren != null)
  165. {
  166. SceneVRCommunication.VR_TIME nowTime = instance.GetNowTime();
  167. if (nowTime == SceneVRCommunication.VR_TIME.MONING)
  168. {
  169. componentInChildren.text = "昼へ進む";
  170. }
  171. else if (nowTime == SceneVRCommunication.VR_TIME.DAY)
  172. {
  173. componentInChildren.text = "夜へ進む";
  174. }
  175. else if (nowTime == SceneVRCommunication.VR_TIME.NIGHT)
  176. {
  177. componentInChildren.text = "翌日へ進む";
  178. }
  179. else
  180. {
  181. Debug.LogError("[VRMainMenu]ゲーム内の時間指定が分かりません");
  182. }
  183. }
  184. bool flag = false;
  185. if (GameMain.Instance.CharacterMgr.GetMaid(0) != null)
  186. {
  187. string text = "vrcom_nei_letter.nei";
  188. if (!GameUty.FileSystem.IsExistentFile(text))
  189. {
  190. NDebug.Assert("表がありません。" + text, false);
  191. }
  192. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  193. {
  194. using (CsvParser csvParser = new CsvParser())
  195. {
  196. bool condition = csvParser.Open(afileBase);
  197. NDebug.Assert(condition, text + "\nopen failed.");
  198. for (int i = 1; i < csvParser.max_cell_y; i++)
  199. {
  200. string cellAsString = csvParser.GetCellAsString(2, i);
  201. if (GameMain.Instance.CharacterMgr.GetMaid(0).status.GetFlag(cellAsString) == 1)
  202. {
  203. flag = true;
  204. break;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. this.Event_SetButtonEnabled(VRMainMenu.ButtonType.Nei, flag);
  211. }
  212. [SerializeField]
  213. [Tooltip("ボタン「エディット」")]
  214. private Button m_ButtonEdit;
  215. [SerializeField]
  216. [Tooltip("ボタン「夜伽」")]
  217. private Button m_ButtonYotogi;
  218. [SerializeField]
  219. [Tooltip("ボタン「ねい人形からの手紙」")]
  220. private Button m_ButtonNei;
  221. [SerializeField]
  222. [Tooltip("ボタン「背景移動」")]
  223. private Button m_ButtonChangeBG;
  224. [SerializeField]
  225. [Tooltip("ボタン「時間」")]
  226. private Button m_ButtonTime;
  227. [SerializeField]
  228. [Tooltip("ボタン「コンフィグ」")]
  229. private Button m_ButtonConfig;
  230. [SerializeField]
  231. [Tooltip("ボタン「VRコンフィグ」")]
  232. private Button m_ButtonVRConfig;
  233. [SerializeField]
  234. [Tooltip("ボタン「トロフィー」")]
  235. private Button m_ButtonTrohy;
  236. [SerializeField]
  237. [Tooltip("ボタン「マニュアル」")]
  238. private Button m_ButtonManual;
  239. [SerializeField]
  240. [Tooltip("ボタン「終了」")]
  241. private Button m_ButtonEnd;
  242. [SerializeField]
  243. [Tooltip("ボタン「SKIP」")]
  244. private Button m_ButtonSkip;
  245. private Dictionary<VRMainMenu.ButtonType, Button> m_ButtonArray = new Dictionary<VRMainMenu.ButtonType, Button>();
  246. public enum ButtonType
  247. {
  248. Edit,
  249. Yotogi,
  250. Nei,
  251. ChangeBG,
  252. Time,
  253. Config,
  254. VRConfig,
  255. Trohy,
  256. Manual,
  257. EndButton,
  258. Skip
  259. }
  260. }