GameMain.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Globalization;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Threading;
  9. using I2.Loc;
  10. using Kasizuki;
  11. using MaidStatus;
  12. using Schedule;
  13. using UnityEngine;
  14. using UnityEngine.SceneManagement;
  15. using UnityEngine.VR;
  16. using Yotogis;
  17. public class GameMain : MonoSingleton<GameMain>
  18. {
  19. public bool IsDebugCharaLoad
  20. {
  21. get
  22. {
  23. return this.m_boDebugCharaLoad;
  24. }
  25. }
  26. public static GameMain Instance
  27. {
  28. get
  29. {
  30. return GameMain.m_objInstance;
  31. }
  32. }
  33. public static int tick_count
  34. {
  35. get
  36. {
  37. return GameMain.m_TickCount;
  38. }
  39. }
  40. public CameraMain MainCamera
  41. {
  42. get
  43. {
  44. return this.m_camMainCamera;
  45. }
  46. }
  47. public Camera ThumCamera
  48. {
  49. get
  50. {
  51. return this.m_camThumCamera;
  52. }
  53. }
  54. public LightMain MainLight
  55. {
  56. get
  57. {
  58. return this.m_camMainLight;
  59. }
  60. }
  61. public CMSystem CMSystem
  62. {
  63. get
  64. {
  65. return this.m_System;
  66. }
  67. }
  68. public ScriptManager ScriptMgr
  69. {
  70. get
  71. {
  72. return this.script_mgr_;
  73. }
  74. }
  75. public ScriptManagerFast ScriptMgrFast
  76. {
  77. get
  78. {
  79. return this.script_mgr_fast_;
  80. }
  81. }
  82. public AnmParse AnmParse
  83. {
  84. get
  85. {
  86. return this.anm_parse_;
  87. }
  88. }
  89. public EnumData EnumDataMPN { get; private set; }
  90. public EnumData EnumDataPartsColor { get; private set; }
  91. public MenuDataBase MenuDataBase { get; private set; }
  92. public SoundMgr SoundMgr
  93. {
  94. get
  95. {
  96. return this.m_SoundMgr;
  97. }
  98. }
  99. public CharacterMgr CharacterMgr
  100. {
  101. get
  102. {
  103. return this.m_CharacterMgr;
  104. }
  105. }
  106. public BgMgr BgMgr
  107. {
  108. get
  109. {
  110. return this.m_BgMgr;
  111. }
  112. }
  113. public FacilityManager FacilityMgr
  114. {
  115. get
  116. {
  117. return this.m_FacilityMgr;
  118. }
  119. }
  120. public KasizukiManager KasizukiMgr
  121. {
  122. get
  123. {
  124. return this.m_KasizukiMgr;
  125. }
  126. }
  127. public ScenarioSelectMgr ScenarioSelectMgr
  128. {
  129. get
  130. {
  131. return this.m_ScenarioSelectMgr;
  132. }
  133. }
  134. public EmpireLifeModeManager LifeModeMgr
  135. {
  136. get
  137. {
  138. return this.m_LifeModeMgr;
  139. }
  140. }
  141. public SystemDialog SysDlg
  142. {
  143. get
  144. {
  145. return this.m_SysDlg;
  146. }
  147. }
  148. public LoadIcon LoadIcon
  149. {
  150. get
  151. {
  152. return this.m_LoadIcon;
  153. }
  154. }
  155. public SystemShortcut SysShortcut
  156. {
  157. get
  158. {
  159. return this.m_SysShortcut;
  160. }
  161. }
  162. public FpsCounter FpsCounter
  163. {
  164. get
  165. {
  166. return this.m_FpsCounter;
  167. }
  168. }
  169. public MessageWindowMgr MsgWnd
  170. {
  171. get
  172. {
  173. return this.m_MsgWnd;
  174. }
  175. }
  176. public TutorialPanel TutorialPanel
  177. {
  178. get
  179. {
  180. return this.m_TutorialPanel;
  181. }
  182. }
  183. public bool isQuitting
  184. {
  185. get
  186. {
  187. return this.m_bQuitting;
  188. }
  189. }
  190. public bool IsForceSkip()
  191. {
  192. return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
  193. }
  194. public bool VRMode
  195. {
  196. get
  197. {
  198. return this.m_bVRMode;
  199. }
  200. }
  201. public bool VRDummyMode
  202. {
  203. get
  204. {
  205. return this.m_bVRDummyMode;
  206. }
  207. set
  208. {
  209. if (value || this.m_bVRDummyMode)
  210. {
  211. this.m_bVRMode = value;
  212. this.m_bVRDummyMode = value;
  213. }
  214. else
  215. {
  216. this.m_bVRDummyMode = value;
  217. }
  218. }
  219. }
  220. public bool IsVRDeviceReady
  221. {
  222. get
  223. {
  224. return this.m_bIsVRDeviceReady;
  225. }
  226. }
  227. public GameMain.VRFamilyType VRFamily
  228. {
  229. get
  230. {
  231. return this.m_eVRFamily;
  232. }
  233. }
  234. public GameMain.VRDeviceType VRDeviceTypeID
  235. {
  236. get
  237. {
  238. if (this.m_eVRDeviceType == GameMain.VRDeviceType.FOVE && SceneVRCommunication.Instance != null)
  239. {
  240. return GameMain.VRDeviceType.RIFT;
  241. }
  242. return this.m_eVRDeviceType;
  243. }
  244. set
  245. {
  246. this.m_eVRDeviceType = value;
  247. }
  248. }
  249. public OvrMgr OvrMgr
  250. {
  251. get
  252. {
  253. return this.m_OvrMgr;
  254. }
  255. }
  256. public OVRLipSync LipSyncMgr
  257. {
  258. get
  259. {
  260. return this.m_LipSyncMgr;
  261. }
  262. }
  263. public OvrIK OvrIK
  264. {
  265. get
  266. {
  267. return OvrIK.Instance;
  268. }
  269. }
  270. public Webs Webs
  271. {
  272. get
  273. {
  274. return this.m_Webs;
  275. }
  276. }
  277. public override void OnInitialize()
  278. {
  279. string[] commandLineArgs = Environment.GetCommandLineArgs();
  280. GameMain.m_objInstance = this;
  281. bool flag = false;
  282. if (!string.IsNullOrEmpty(Array.Find<string>(commandLineArgs, (string s) => s.ToLower().Contains("/reboot"))))
  283. {
  284. flag = true;
  285. }
  286. if (!flag)
  287. {
  288. Process currentProcess = Process.GetCurrentProcess();
  289. string processName = currentProcess.ProcessName;
  290. Process[] processesByName = Process.GetProcessesByName(processName);
  291. foreach (Process process in processesByName)
  292. {
  293. if (process.Id != currentProcess.Id)
  294. {
  295. NUty.WinMessageBox(NUty.GetWindowHandle(), "ゲームは既に起動しています。", "警告", 48);
  296. Application.Quit();
  297. return;
  298. }
  299. }
  300. }
  301. UnityEngine.Debug.Log("TestSingleton#OnInitialize");
  302. LocalizationManager.CurrentLanguage = "Japanese";
  303. Thread.CurrentThread.CurrentCulture = new CultureInfo("ja-JP");
  304. UnityEngine.Debug.Log(SystemInfo.operatingSystem);
  305. UnityEngine.Debug.Log(string.Concat(new object[]
  306. {
  307. SystemInfo.processorType,
  308. " : ",
  309. SystemInfo.processorCount,
  310. "Core"
  311. }));
  312. UnityEngine.Debug.Log(SystemInfo.systemMemorySize + " MB System Memory ");
  313. UnityEngine.Debug.Log(string.Concat(new object[]
  314. {
  315. SystemInfo.graphicsDeviceName,
  316. " : ",
  317. SystemInfo.graphicsMemorySize,
  318. "MB : ",
  319. SystemInfo.graphicsDeviceType
  320. }));
  321. string text = SystemInfo.graphicsDeviceName.ToLower();
  322. if (text.Contains("radeon") && text.Contains("hd") && NUty.WinMessageBox(NUty.GetWindowHandle(), "ご利用中のグラフィックボード・ビデオカード(" + SystemInfo.graphicsDeviceName + ")は非対応の機種です。\nゲーム中にクラッシュする場合があります。\n公式ページより対応GPUをご確認下さい。\nこのままゲームを続行しますか?", "ご注意", 52) == 7)
  323. {
  324. Application.Quit();
  325. }
  326. if (!string.IsNullOrEmpty(Array.Find<string>(commandLineArgs, (string s) => s.ToLower().Contains("/vr"))))
  327. {
  328. this.m_bVRMode = true;
  329. }
  330. else
  331. {
  332. this.m_bVRMode = false;
  333. }
  334. VRSettings.enabled = this.m_bVRMode;
  335. if (!this.m_bVRMode)
  336. {
  337. VRSettings.LoadDeviceByName("None");
  338. }
  339. string fullPath = Path.GetFullPath(".\\");
  340. if (!UTY.IsLowercaseAlphanumeric(fullPath))
  341. {
  342. }
  343. this.m_boDebugCharaLoad = false;
  344. NDebug.Assert(this.m_camMainCamera != null, "GameMainにメインカメラが設定されていません。");
  345. NDebug.Assert(this.m_camThumCamera != null, "GameMainにサムネイル用カメラが設定されていません。");
  346. NDebug.Assert(this.m_camMainLight != null, "GameMainにメインライトが設定されていません。");
  347. UTY.InitDll();
  348. base.transform.position = Vector3.zero;
  349. Transform transform = base.transform.Find("BG");
  350. NDebug.Assert(transform != null, "__GameMain__の子にBGが居ません。");
  351. transform.position = Vector3.zero;
  352. Transform transform2 = base.transform.Find("Camera");
  353. NDebug.Assert(transform2 != null, "__GameMain__の子にCameraが居ません。");
  354. transform2.position = Vector3.zero;
  355. GameUty.DeviceInitialize();
  356. this.m_System = new CMSystem();
  357. GameUty.Init();
  358. this.m_SoundMgr = base.gameObject.AddComponent<SoundMgr>().GetComponent<SoundMgr>();
  359. this.m_SoundMgr.Init(base.gameObject);
  360. GameObject childObject = UTY.GetChildObject(base.gameObject, "SystemUI Root/FpsCounter", false);
  361. this.m_FpsCounter = childObject.GetComponent<FpsCounter>();
  362. this.m_System.LoadIni();
  363. if ((!this.VRMode || this.VRDummyMode) && Application.targetFrameRate != 60)
  364. {
  365. NUty.WinMessageBox(NUty.GetWindowHandle(), "TargetFPS が 60 以外の設定になっています。\n60 以外では描画が乱れる場合があり、サポート対象外の設定となります。", "targetFrameRate Warning", 0);
  366. }
  367. Skill.CreateData();
  368. this.m_BgMgr = base.gameObject.AddComponent<BgMgr>().GetComponent<BgMgr>();
  369. GameObject childObject2 = UTY.GetChildObject(base.gameObject, "SystemUI Root/SystemDialog", false);
  370. this.m_SysDlg = childObject2.GetComponent<SystemDialog>();
  371. this.m_SysDlg.Init();
  372. this.m_LoadIcon = UTY.GetChildObject(base.gameObject, "LoadIcon", false).GetComponent<LoadIcon>();
  373. GameObject childObject3 = UTY.GetChildObject(base.gameObject, "SystemUI Root/SystemShortcut", false);
  374. this.m_SysShortcut = childObject3.GetComponent<SystemShortcut>();
  375. this.m_CharacterMgr = base.gameObject.AddComponent<CharacterMgr>().GetComponent<CharacterMgr>();
  376. this.m_CharacterMgr.Init(this);
  377. this.m_FacilityMgr = base.gameObject.AddComponent<FacilityManager>();
  378. this.m_FacilityMgr.Init(this);
  379. this.m_KasizukiMgr = base.gameObject.AddComponent<KasizukiManager>();
  380. this.m_KasizukiMgr.Init();
  381. this.m_LifeModeMgr = base.gameObject.AddComponent<EmpireLifeModeManager>();
  382. if (this.CMSystem.NetUse)
  383. {
  384. this.m_Webs = base.gameObject.AddComponent<Webs>();
  385. this.m_Webs.Init();
  386. }
  387. this.m_ScenarioSelectMgr.InitScenarioData();
  388. CasinoDataMgr.Instance.InitShopData();
  389. VsDanceDataMgr.CreateInstance();
  390. this.m_LipSyncMgr = base.gameObject.AddComponent<OVRLipSync>();
  391. this.m_LipSyncMgr.Init();
  392. GameObject gameObject = GameObject.Find("SystemUI Root/Manager_SystemUI/MessageWindowMgr");
  393. NDebug.Assert(gameObject != null, "MessageWindowMgrが見つかりません");
  394. this.m_MsgWnd = gameObject.GetComponent<MessageWindowMgr>();
  395. NDebug.Assert(this.m_MsgWnd != null, "コンポーネント:MessageWindowMgrが見つかりません");
  396. this.m_TutorialPanel = GameObject.Find("SystemUI Root/TutorialPanel").GetComponent<TutorialPanel>();
  397. this.anm_parse_ = new AnmParse();
  398. this.EnumDataMPN = new EnumData();
  399. IEnumerator enumerator = Enum.GetValues(typeof(MPN)).GetEnumerator();
  400. try
  401. {
  402. while (enumerator.MoveNext())
  403. {
  404. object obj = enumerator.Current;
  405. string text2 = obj.ToString();
  406. MPN id = MPN.null_mpn;
  407. try
  408. {
  409. id = (MPN)Enum.Parse(typeof(MPN), text2);
  410. }
  411. catch (Exception e)
  412. {
  413. NDebug.AssertParseError("MPN", e);
  414. }
  415. this.EnumDataMPN.AddMember((int)id, text2);
  416. }
  417. }
  418. finally
  419. {
  420. IDisposable disposable;
  421. if ((disposable = (enumerator as IDisposable)) != null)
  422. {
  423. disposable.Dispose();
  424. }
  425. }
  426. this.EnumDataPartsColor = new EnumData();
  427. IEnumerator enumerator2 = Enum.GetValues(typeof(MaidParts.PARTS_COLOR)).GetEnumerator();
  428. try
  429. {
  430. while (enumerator2.MoveNext())
  431. {
  432. object obj2 = enumerator2.Current;
  433. string text3 = obj2.ToString();
  434. MaidParts.PARTS_COLOR id2 = MaidParts.PARTS_COLOR.EYE_L;
  435. try
  436. {
  437. id2 = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text3);
  438. }
  439. catch (Exception e2)
  440. {
  441. NDebug.AssertParseError("MaidParts.PARTS_COLOR", e2);
  442. }
  443. this.EnumDataPartsColor.AddMember((int)id2, text3);
  444. }
  445. }
  446. finally
  447. {
  448. IDisposable disposable2;
  449. if ((disposable2 = (enumerator2 as IDisposable)) != null)
  450. {
  451. disposable2.Dispose();
  452. }
  453. }
  454. this.MenuDataBase = new MenuDataBase(GameUty.FileSystem.NativePointerToInterfaceFileSystemWide, this.EnumDataMPN, this.EnumDataPartsColor);
  455. this.MenuDataBase.StartAnalysis();
  456. this.script_mgr_ = new ScriptManager();
  457. this.script_mgr_.Initialize();
  458. this.script_mgr_fast_ = new ScriptManagerFast(this.script_mgr_);
  459. this.script_mgr_fast_.Initialize();
  460. this.UpdateSaveDataDay();
  461. GameMain.Instance.SysShortcut.gameObject.SetActive(true);
  462. DeskManager.CreateCsvData();
  463. DeskManager.Deserialize();
  464. if (this.m_bVRMode)
  465. {
  466. string loadedDeviceName = VRSettings.loadedDeviceName;
  467. string model = VRDevice.model;
  468. UnityEngine.Debug.Log("VR Device " + loadedDeviceName + " / " + model);
  469. if (loadedDeviceName.ToLower().Contains("oculus"))
  470. {
  471. this.m_eVRFamily = GameMain.VRFamilyType.Oculus;
  472. this.m_eVRDeviceType = GameMain.VRDeviceType.RIFT_TOUCH;
  473. UnityEngine.Debug.Log("VR Family is Oculus! " + this.m_eVRDeviceType.ToString());
  474. this.OvrInit();
  475. base.StartCoroutine(this.CoOvrStart());
  476. }
  477. else if (loadedDeviceName.ToLower().Contains("openvr"))
  478. {
  479. this.m_eVRFamily = GameMain.VRFamilyType.HTC;
  480. this.m_eVRDeviceType = GameMain.VRDeviceType.VIVE;
  481. UnityEngine.Debug.Log("VR Family is HTC!");
  482. this.OvrInit();
  483. this.m_bIsVRDeviceReady = true;
  484. }
  485. else
  486. {
  487. VRSettings.enabled = false;
  488. this.m_bVRMode = false;
  489. }
  490. }
  491. }
  492. private IEnumerator CoOvrStart()
  493. {
  494. yield return null;
  495. VRSettings.enabled = true;
  496. this.m_bIsVRDeviceReady = true;
  497. yield break;
  498. }
  499. public void OvrInit()
  500. {
  501. this.m_OvrMgr = base.gameObject.AddComponent<OvrMgr>();
  502. this.m_OvrMgr.Init();
  503. this.m_camBackupMainCamera = this.m_camMainCamera;
  504. this.m_camMainCamera = this.m_OvrMgr.OvrCamera;
  505. if (this.VRFamily != GameMain.VRFamilyType.NON)
  506. {
  507. this.m_System.LoadIni();
  508. }
  509. GameMain.Instance.MainCamera.SetPos(new Vector3(0f, -100f, 0f));
  510. }
  511. public void OvrUninit()
  512. {
  513. if (this.VRFamily != GameMain.VRFamilyType.NON)
  514. {
  515. this.m_System.SaveIni();
  516. }
  517. this.m_camMainCamera = this.m_camBackupMainCamera;
  518. this.m_bVRMode = false;
  519. this.m_bVRDummyMode = false;
  520. this.m_eVRFamily = GameMain.VRFamilyType.NON;
  521. this.m_eVRDeviceType = GameMain.VRDeviceType.NON;
  522. this.m_bIsVRDeviceReady = false;
  523. if (this.m_OvrMgr != null)
  524. {
  525. this.m_OvrMgr.Uninit();
  526. UnityEngine.Object.DestroyImmediate(this.m_OvrMgr);
  527. this.m_OvrMgr = null;
  528. }
  529. Cursor.visible = true;
  530. Cursor.lockState = CursorLockMode.None;
  531. }
  532. public void OnStartDay()
  533. {
  534. this.FacilityMgr.UpdateNextDay();
  535. this.LifeModeMgr.OnNextDay();
  536. ScheduleAPI.DayStartManage();
  537. bool flag = false;
  538. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetStockMaidCount(); i++)
  539. {
  540. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
  541. if (stockMaid != null && stockMaid.status.leader)
  542. {
  543. flag = true;
  544. break;
  545. }
  546. }
  547. if (!flag)
  548. {
  549. bool flag2 = false;
  550. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetMaidCount(); j++)
  551. {
  552. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(j);
  553. if (maid != null)
  554. {
  555. maid.status.leader = true;
  556. flag2 = true;
  557. break;
  558. }
  559. }
  560. if (!flag2)
  561. {
  562. for (int k = 0; k < GameMain.Instance.CharacterMgr.GetStockMaidCount(); k++)
  563. {
  564. Maid stockMaid2 = GameMain.Instance.CharacterMgr.GetStockMaid(k);
  565. if (stockMaid2 != null)
  566. {
  567. stockMaid2.status.leader = true;
  568. break;
  569. }
  570. }
  571. }
  572. }
  573. this.m_CharacterMgr.status.days++;
  574. if (GameMain.Instance.CharacterMgr.status.isAvailableRanking)
  575. {
  576. int flag3 = GameMain.Instance.CharacterMgr.status.GetFlag("__ランキング日数");
  577. GameMain.Instance.CharacterMgr.status.SetFlag("__ランキング日数", flag3 + 1);
  578. }
  579. Dictionary<int, List<Maid>> dictionary = new Dictionary<int, List<Maid>>();
  580. for (int l = 0; l < this.CharacterMgr.GetStockMaidCount(); l++)
  581. {
  582. Maid stockMaid3 = this.CharacterMgr.GetStockMaid(l);
  583. if (stockMaid3 != null && stockMaid3.status.heroineType == HeroineType.Sub)
  584. {
  585. int id = stockMaid3.status.subCharaData.id;
  586. if (stockMaid3.ActiveSlotNo != -1)
  587. {
  588. this.CharacterMgr.DeactivateMaid(stockMaid3);
  589. }
  590. if (!dictionary.ContainsKey(id))
  591. {
  592. dictionary.Add(id, new List<Maid>());
  593. }
  594. else
  595. {
  596. dictionary[id].Add(stockMaid3);
  597. }
  598. }
  599. }
  600. foreach (KeyValuePair<int, List<Maid>> keyValuePair in dictionary)
  601. {
  602. List<Maid> value = keyValuePair.Value;
  603. foreach (Maid maid2 in value)
  604. {
  605. UnityEngine.Debug.Log("■増殖確認がとれたサブメイド[" + maid2.status.subCharaData.uniqueName + "]を削除します");
  606. this.CharacterMgr.BanishmentMaid(maid2);
  607. }
  608. }
  609. ScheduleAPI.DayStartManage();
  610. }
  611. public void OnEndDay()
  612. {
  613. for (int i = 0; i < this.m_CharacterMgr.GetStockMaidCount(); i++)
  614. {
  615. Maid stockMaid = this.m_CharacterMgr.GetStockMaid(i);
  616. stockMaid.status.RemoveFeature(Feature.GetData("疲労"));
  617. if (stockMaid.status.currentHp <= 0 && stockMaid.status.currentMind <= 0)
  618. {
  619. stockMaid.status.AddFeature(Feature.GetData("疲労"));
  620. }
  621. stockMaid.status.currentHp = stockMaid.status.maxHp;
  622. stockMaid.status.currentMind = stockMaid.status.maxMind;
  623. }
  624. }
  625. public bool Serialize(int f_nSaveNo, string f_strComment)
  626. {
  627. MemoryStream memoryStream = new MemoryStream();
  628. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  629. string strSaveTime = DateTime.Now.ToString("yyyyMMddHHmmss");
  630. GameMain.SerializeHeader serializeHeader = new GameMain.SerializeHeader();
  631. serializeHeader.strSaveTime = strSaveTime;
  632. serializeHeader.nGameDay = this.m_CharacterMgr.status.days;
  633. serializeHeader.strPlayerName = this.m_CharacterMgr.status.playerName;
  634. serializeHeader.nMaidNum = this.m_CharacterMgr.GetStockMaidCount();
  635. serializeHeader.strComment = f_strComment;
  636. binaryWriter.Write("COM3D2_SAVE");
  637. binaryWriter.Write(1210);
  638. this.SerializeWriteHeader(binaryWriter, serializeHeader);
  639. binaryWriter.Write("bookmark_kk_01");
  640. GameMain.BinaryBookmark binaryBookmark = new GameMain.BinaryBookmark(binaryWriter);
  641. binaryWriter.Write("bookmark_kk_02");
  642. GameMain.BinaryBookmark binaryBookmark2 = new GameMain.BinaryBookmark(binaryWriter);
  643. bool value = false;
  644. foreach (Maid maid in this.m_CharacterMgr.GetStockMaidList())
  645. {
  646. if (maid.status.isCompatiblePersonality)
  647. {
  648. value = true;
  649. break;
  650. }
  651. }
  652. binaryWriter.Write(value);
  653. binaryWriter.Write(GameUty.ExistCsvPathList.Count);
  654. foreach (string value2 in GameUty.ExistCsvPathList)
  655. {
  656. binaryWriter.Write(value2);
  657. }
  658. binaryWriter.Write(GameUty.ExistCsvPathListOld.Count);
  659. foreach (string value3 in GameUty.ExistCsvPathListOld)
  660. {
  661. binaryWriter.Write(value3);
  662. }
  663. this.m_CharacterMgr.Serialize(binaryWriter);
  664. this.script_mgr_.Serialize(binaryWriter);
  665. DeskManager.SerializeSingleSaveData(binaryWriter);
  666. this.m_ScenarioSelectMgr.Serialize(binaryWriter);
  667. this.m_FacilityMgr.Serialize(binaryWriter);
  668. binaryBookmark.WriteBinaryLength(binaryWriter);
  669. this.m_KasizukiMgr.Serialize(binaryWriter);
  670. binaryBookmark2.WriteBinaryLength(binaryWriter);
  671. CasinoDataMgr.Instance.Serialize(binaryWriter);
  672. VsDanceDataMgr.Instance.Serialize(binaryWriter);
  673. string path = this.MakeSavePathFileName(f_nSaveNo);
  674. File.WriteAllBytes(path, memoryStream.ToArray());
  675. memoryStream.Close();
  676. memoryStream.Dispose();
  677. memoryStream = null;
  678. this.UpdateSaveDataDay();
  679. return true;
  680. }
  681. private bool SerializeWriteHeader(BinaryWriter bwWrite, GameMain.SerializeHeader f_head)
  682. {
  683. bwWrite.Write(f_head.strSaveTime);
  684. bwWrite.Write(f_head.nGameDay);
  685. bwWrite.Write(f_head.strPlayerName);
  686. bwWrite.Write(f_head.nMaidNum);
  687. bwWrite.Write(f_head.strComment);
  688. return true;
  689. }
  690. public string MakeSavePathFileName(int f_nSaveNo)
  691. {
  692. string fullPath = Path.GetFullPath(".\\");
  693. string text = fullPath + "SaveData";
  694. if (!Directory.Exists(text))
  695. {
  696. Directory.CreateDirectory(text);
  697. }
  698. return text + "/" + string.Format("SaveData{0:D3}", f_nSaveNo) + ".save";
  699. }
  700. public int GetSaveFileNameToSaveNo(string f_strFileName)
  701. {
  702. string text = Path.GetFileName(f_strFileName);
  703. if (Path.GetExtension(text) != Path.GetExtension(".save"))
  704. {
  705. return -1;
  706. }
  707. text = Path.GetFileNameWithoutExtension(text);
  708. if (text.Length != 11)
  709. {
  710. return -1;
  711. }
  712. int num = text.IndexOf("SaveData");
  713. if (num != 0)
  714. {
  715. return -1;
  716. }
  717. string s = text.Substring(8);
  718. int result = -1;
  719. if (!int.TryParse(s, out result))
  720. {
  721. return -1;
  722. }
  723. return result;
  724. }
  725. public bool SaveDataCommentSave(int f_nSaveNo, string f_strComment)
  726. {
  727. GameMain.SerializeHeader saveDataHeader = this.GetSaveDataHeader(f_nSaveNo);
  728. if (saveDataHeader == null)
  729. {
  730. UnityEngine.Debug.LogWarning("このスロットにはセーブデータはありません。" + f_nSaveNo);
  731. return false;
  732. }
  733. saveDataHeader.strComment = f_strComment;
  734. string path = this.MakeSavePathFileName(f_nSaveNo);
  735. FileStream fileStream = new FileStream(path, FileMode.Open);
  736. if (fileStream == null)
  737. {
  738. return false;
  739. }
  740. byte[] array = new byte[fileStream.Length];
  741. fileStream.Read(array, 0, (int)fileStream.Length);
  742. fileStream.Close();
  743. fileStream.Dispose();
  744. MemoryStream memoryStream = new MemoryStream();
  745. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  746. binaryWriter.Write("COM3D2_SAVE");
  747. binaryWriter.Write(1210);
  748. this.SerializeWriteHeader(binaryWriter, saveDataHeader);
  749. binaryWriter.Write(array, (int)saveDataHeader.lHeaderSize, (int)((long)array.Length - saveDataHeader.lHeaderSize));
  750. File.WriteAllBytes(path, memoryStream.ToArray());
  751. memoryStream.Close();
  752. memoryStream.Dispose();
  753. return true;
  754. }
  755. public void DeleteSerializeData(int f_nSaveNo)
  756. {
  757. string text = this.MakeSavePathFileName(f_nSaveNo);
  758. try
  759. {
  760. if (File.Exists(text))
  761. {
  762. File.Delete(text);
  763. }
  764. else
  765. {
  766. UnityEngine.Debug.LogWarning("SaveDataDelete削除失敗 ファイルが有りません。" + text);
  767. }
  768. }
  769. catch (Exception ex)
  770. {
  771. UnityEngine.Debug.LogWarning("SaveDataDelete削除失敗 " + ex.Message);
  772. }
  773. }
  774. public bool SerializeKasizukiOnly(int f_nSaveNo)
  775. {
  776. using (MemoryStream memoryStream = new MemoryStream())
  777. {
  778. using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
  779. {
  780. if (this.GetSaveDataHeader(f_nSaveNo) == null)
  781. {
  782. UnityEngine.Debug.LogWarning("このスロットにはセーブデータはありません。" + f_nSaveNo);
  783. return false;
  784. }
  785. string path = this.MakeSavePathFileName(f_nSaveNo);
  786. FileStream fileStream = new FileStream(path, FileMode.Open);
  787. if (fileStream == null)
  788. {
  789. return false;
  790. }
  791. byte[] buffer = new byte[fileStream.Length];
  792. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  793. fileStream.Read(buffer, 0, (int)fileStream.Length);
  794. fileStream.Close();
  795. fileStream.Dispose();
  796. binaryWriter.Write(binaryReader.ReadString());
  797. binaryWriter.Write(binaryReader.ReadInt32());
  798. this.SerializeWriteHeader(binaryWriter, this.DeserializeReadHeader(binaryReader));
  799. if (!this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_01"))
  800. {
  801. NDebug.MessageBox("傅きセーブ", "元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  802. UnityEngine.Debug.LogWarning("[GameMain.SerializeKasizukiOnly]\u3000元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  803. binaryReader.Close();
  804. return false;
  805. }
  806. GameMain.BinaryBookmark binaryBookmark = new GameMain.BinaryBookmark(binaryReader);
  807. if (!this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_02"))
  808. {
  809. NDebug.MessageBox("傅きセーブ", "元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  810. UnityEngine.Debug.LogWarning("[GameMain.SerializeKasizukiOnly]\u3000元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  811. binaryReader.Close();
  812. return false;
  813. }
  814. GameMain.BinaryBookmark binaryBookmark2 = new GameMain.BinaryBookmark(binaryReader);
  815. binaryWriter.Write("bookmark_kk_01");
  816. GameMain.BinaryBookmark binaryBookmark3 = new GameMain.BinaryBookmark(binaryWriter);
  817. binaryWriter.Write("bookmark_kk_02");
  818. GameMain.BinaryBookmark binaryBookmark4 = new GameMain.BinaryBookmark(binaryWriter);
  819. binaryReader.BaseStream.Seek(binaryBookmark.bookmark_write_position, SeekOrigin.Begin);
  820. binaryWriter.BaseStream.Seek(binaryBookmark.bookmark_write_position, SeekOrigin.Begin);
  821. binaryWriter.Write(binaryReader.ReadBytes((int)binaryBookmark.bookmark_value + 8));
  822. binaryBookmark3.WriteBinaryLength(binaryWriter);
  823. this.KasizukiMgr.Serialize(binaryWriter);
  824. binaryBookmark4.WriteBinaryLength(binaryWriter);
  825. long num = binaryBookmark2.bookmark_value + binaryBookmark2.bookmark_write_position + 8L;
  826. binaryReader.BaseStream.Seek(num, SeekOrigin.Begin);
  827. binaryWriter.Write(binaryReader.ReadBytes((int)binaryReader.BaseStream.Length - (int)num));
  828. binaryReader.Close();
  829. File.WriteAllBytes(path, memoryStream.ToArray());
  830. }
  831. }
  832. return true;
  833. }
  834. private bool TryBinaryReadString(Stream stream, Func<string, bool> func)
  835. {
  836. BinaryReader binaryReader = new BinaryReader(stream);
  837. long position = binaryReader.BaseStream.Position;
  838. string arg = binaryReader.ReadString();
  839. bool flag = func(arg);
  840. if (!flag)
  841. {
  842. binaryReader.BaseStream.Seek(position, SeekOrigin.Begin);
  843. }
  844. return flag;
  845. }
  846. public bool Deserialize(int f_nSaveNo, bool scriptExec = true)
  847. {
  848. this.CMSystem.m_GenericTmpFlag.Clear();
  849. this.m_TutorialPanel.Reset();
  850. GameObject gameObject = GameObject.Find("SystemUI Root/TrophyAchieveEffect");
  851. if (gameObject != null)
  852. {
  853. TrophyAchieveEffect component = gameObject.GetComponent<TrophyAchieveEffect>();
  854. if (component != null)
  855. {
  856. component.EffectStackClear();
  857. }
  858. }
  859. string text = this.MakeSavePathFileName(f_nSaveNo);
  860. NDebug.Assert(File.Exists(text), "ファイルを開けません。" + text);
  861. FileStream fileStream = new FileStream(text, FileMode.Open);
  862. if (fileStream == null)
  863. {
  864. return false;
  865. }
  866. byte[] buffer = new byte[fileStream.Length];
  867. fileStream.Read(buffer, 0, (int)fileStream.Length);
  868. fileStream.Close();
  869. fileStream.Dispose();
  870. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  871. string text2 = binaryReader.ReadString();
  872. if (!(text2 == "COM3D2_SAVE"))
  873. {
  874. NDebug.MessageBox("エラー", "セーブデータファイルのヘッダーが不正です\n" + text2);
  875. binaryReader.Close();
  876. return false;
  877. }
  878. int num = binaryReader.ReadInt32();
  879. GameMain.SerializeHeader serializeHeader = this.DeserializeReadHeader(binaryReader);
  880. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_01"))
  881. {
  882. GameMain.BinaryBookmark binaryBookmark = new GameMain.BinaryBookmark(binaryReader);
  883. }
  884. else
  885. {
  886. UnityEngine.Debug.Log("[GameMain.Deserialize()]\u3000しおりの取得に失敗しました。\u3000古いセーブデータかもしれないです。");
  887. }
  888. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_02"))
  889. {
  890. GameMain.BinaryBookmark binaryBookmark2 = new GameMain.BinaryBookmark(binaryReader);
  891. }
  892. else
  893. {
  894. UnityEngine.Debug.Log("[GameMain.Deserialize()]\u3000しおりの取得に失敗しました。\u3000古いセーブデータかもしれないです。");
  895. }
  896. bool flag = false;
  897. if (215 < num)
  898. {
  899. flag = binaryReader.ReadBoolean();
  900. if (flag)
  901. {
  902. bool flag2 = false;
  903. if (!GameUty.IsEnabledCompatibilityMode)
  904. {
  905. UnityEngine.Debug.LogError("カスタムメイド3D2のメイドがいますが、カスタムメイド3D2の互換設定が正しくありません");
  906. NDebug.MessageBox("エラー", "カスタムメイド3D2のメイドがいますが、カスタムメイド3D2の互換設定が正しくありません");
  907. flag2 = true;
  908. }
  909. if (!flag2 && !PluginData.IsEnabled("Legacy"))
  910. {
  911. UnityEngine.Debug.LogError("カスタムメイド3D2のメイドがいますが、互換アップデートパッチがインストールされていません");
  912. NDebug.MessageBox("エラー", "カスタムメイド3D2のメイドがいますが、互換アップデートパッチがインストールされていません");
  913. flag2 = true;
  914. }
  915. if (flag2)
  916. {
  917. binaryReader.Close();
  918. return false;
  919. }
  920. }
  921. List<string> list = new List<string>();
  922. int num2 = binaryReader.ReadInt32();
  923. for (int i = 0; i < num2; i++)
  924. {
  925. list.Add(binaryReader.ReadString());
  926. }
  927. List<string> list2 = new List<string>();
  928. foreach (string item in list)
  929. {
  930. if (!GameUty.ExistCsvPathList.Contains(item))
  931. {
  932. list2.Add(item);
  933. }
  934. }
  935. if (list2.Count > 0)
  936. {
  937. string str4 = "カスタムオーダーメイド3D2";
  938. string text3 = str4 + "に以下のプラグインが存在しません。\n不具合が出る可能性があります。\n";
  939. num2 = 1;
  940. foreach (string str2 in list2)
  941. {
  942. text3 += str2;
  943. if (num2 % 5 == 0)
  944. {
  945. text3 += "\n";
  946. }
  947. else
  948. {
  949. text3 += ",";
  950. }
  951. num2++;
  952. }
  953. UnityEngine.Debug.LogError(text3);
  954. NDebug.MessageBox("エラー", text3);
  955. }
  956. List<string> list3 = new List<string>();
  957. num2 = binaryReader.ReadInt32();
  958. for (int j = 0; j < num2; j++)
  959. {
  960. list3.Add(binaryReader.ReadString());
  961. }
  962. if (flag)
  963. {
  964. list2 = new List<string>();
  965. foreach (string item2 in list3)
  966. {
  967. if (!GameUty.ExistCsvPathListOld.Contains(item2))
  968. {
  969. list2.Add(item2);
  970. }
  971. }
  972. if (list2.Count > 0)
  973. {
  974. string text4 = "カスタムメイド3D2に以下のプラグインが存在しません。\n不具合が出る可能性があります。\n";
  975. num2 = 1;
  976. foreach (string str3 in list2)
  977. {
  978. text4 += str3;
  979. if (num2 % 5 == 0)
  980. {
  981. text4 += "\n";
  982. }
  983. else
  984. {
  985. text4 += ",";
  986. }
  987. num2++;
  988. }
  989. UnityEngine.Debug.LogError(text4);
  990. NDebug.MessageBox("エラー", text4);
  991. }
  992. }
  993. }
  994. try
  995. {
  996. this.m_CharacterMgr.Deserialize(binaryReader);
  997. this.script_mgr_.Deserialize(binaryReader);
  998. DeskManager.DeserializeSingleSaveData(binaryReader, num);
  999. if (num >= 206)
  1000. {
  1001. this.m_ScenarioSelectMgr.Deserialize(binaryReader);
  1002. }
  1003. this.m_FacilityMgr.Deserialize(binaryReader);
  1004. this.m_LifeModeMgr.Deserialize(binaryReader);
  1005. GameModeManager.Deserialize(binaryReader);
  1006. this.m_KasizukiMgr.Deserialize(f_nSaveNo, binaryReader);
  1007. CasinoDataMgr.Instance.Deserialize(binaryReader, num);
  1008. VsDanceDataMgr.Instance.Deserialize(binaryReader, num);
  1009. binaryReader.Close();
  1010. binaryReader = null;
  1011. }
  1012. catch (Exception ex)
  1013. {
  1014. UnityEngine.Debug.LogError(ex.Message + "\n\n" + ex.StackTrace);
  1015. NDebug.MessageBox("エラー", ex.Message + "\n\n" + ex.StackTrace);
  1016. binaryReader.Close();
  1017. return false;
  1018. }
  1019. if (scriptExec)
  1020. {
  1021. this.ScriptMgr.adv_kag.Exec();
  1022. }
  1023. return true;
  1024. }
  1025. private GameMain.SerializeHeader DeserializeReadHeader(BinaryReader brRead)
  1026. {
  1027. return new GameMain.SerializeHeader
  1028. {
  1029. strSaveTime = brRead.ReadString(),
  1030. nGameDay = brRead.ReadInt32(),
  1031. strPlayerName = brRead.ReadString(),
  1032. nMaidNum = brRead.ReadInt32(),
  1033. strComment = brRead.ReadString()
  1034. };
  1035. }
  1036. public GameMain.SerializeHeader GetSaveDataHeader(int f_nSaveNo)
  1037. {
  1038. string path = this.MakeSavePathFileName(f_nSaveNo);
  1039. if (File.Exists(path))
  1040. {
  1041. GameMain.SerializeHeader serializeHeader;
  1042. using (FileStream fileStream = new FileStream(path, FileMode.Open))
  1043. {
  1044. if (fileStream == null)
  1045. {
  1046. return null;
  1047. }
  1048. BinaryReader binaryReader = new BinaryReader(fileStream);
  1049. string a = binaryReader.ReadString();
  1050. if (a == "COM3D2_CBL_SAVE")
  1051. {
  1052. return null;
  1053. }
  1054. NDebug.Assert(a == "COM3D2_SAVE", "セーブデータファイルのヘッダーが不正です。_SAVE 2");
  1055. int nVer = binaryReader.ReadInt32();
  1056. serializeHeader = this.DeserializeReadHeader(binaryReader);
  1057. serializeHeader.nVer = nVer;
  1058. serializeHeader.lHeaderSize = binaryReader.BaseStream.Position;
  1059. }
  1060. return serializeHeader;
  1061. }
  1062. return null;
  1063. }
  1064. public bool IsSaveDataNew(int f_nSaveNo)
  1065. {
  1066. return (long)f_nSaveNo == this.m_lNewSaveDataNo;
  1067. }
  1068. public long NewSaveDataNo()
  1069. {
  1070. return this.m_lNewSaveDataNo;
  1071. }
  1072. public void UpdateSaveDataDay()
  1073. {
  1074. string fullPath = Path.GetFullPath(".\\");
  1075. string path = fullPath + "SaveData";
  1076. int num = -1;
  1077. if (Directory.Exists(path))
  1078. {
  1079. string[] files = Directory.GetFiles(path, "*.save");
  1080. long num2 = -1L;
  1081. foreach (string f_strFileName in files)
  1082. {
  1083. int saveFileNameToSaveNo = this.GetSaveFileNameToSaveNo(f_strFileName);
  1084. if (saveFileNameToSaveNo != -1)
  1085. {
  1086. GameMain.SerializeHeader saveDataHeader = this.GetSaveDataHeader(saveFileNameToSaveNo);
  1087. if (saveDataHeader != null)
  1088. {
  1089. long num3 = 0L;
  1090. if (long.TryParse(saveDataHeader.strSaveTime, out num3))
  1091. {
  1092. if (num2 < num3)
  1093. {
  1094. num2 = num3;
  1095. num = saveFileNameToSaveNo;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. }
  1101. }
  1102. this.m_lNewSaveDataNo = (long)num;
  1103. }
  1104. public override void OnFinalize()
  1105. {
  1106. UnityEngine.Debug.Log("GameMain::OnFinalize Start");
  1107. base.BroadcastMessage("OnPreFinalize", SendMessageOptions.DontRequireReceiver);
  1108. UnityEngine.Object.DestroyImmediate(this.CharacterMgr);
  1109. UnityEngine.Object.DestroyImmediate(this.SoundMgr);
  1110. this.anm_parse_.Dispose();
  1111. this.script_mgr_fast_.SelfDispose();
  1112. this.script_mgr_.Dispose();
  1113. if (this.MenuDataBase != null)
  1114. {
  1115. this.MenuDataBase.Dispose();
  1116. this.MenuDataBase = null;
  1117. }
  1118. this.EnumDataMPN.Dispose();
  1119. this.EnumDataPartsColor.Dispose();
  1120. GameUty.Finish();
  1121. UTY.FreeDll();
  1122. UnityEngine.Debug.Log("GameMain::OnFinalize Finish");
  1123. }
  1124. public string GetNowSceneName()
  1125. {
  1126. return this.m_strBeforeSceneName;
  1127. }
  1128. public List<string> GetAddSceneName()
  1129. {
  1130. return this.m_listStackScene;
  1131. }
  1132. public void LoadScene(string f_strSceneName)
  1133. {
  1134. this.m_listStackScene.Clear();
  1135. SceneManager.LoadScene(f_strSceneName, LoadSceneMode.Single);
  1136. this.m_strBeforeSceneName = f_strSceneName;
  1137. UnityEngine.Debug.Log("GameMain::LoadScene " + f_strSceneName);
  1138. }
  1139. public void AddScene(string f_strSceneName)
  1140. {
  1141. if (this.m_listStackScene.Contains(f_strSceneName))
  1142. {
  1143. NDebug.Assert("AddScene 既に同名のシーンがロードされています。" + f_strSceneName, false);
  1144. return;
  1145. }
  1146. SceneManager.LoadScene(f_strSceneName, LoadSceneMode.Additive);
  1147. this.m_listStackScene.Add(f_strSceneName);
  1148. base.StartCoroutine(this.CoAddScene(SceneManager.GetSceneByName(f_strSceneName)));
  1149. }
  1150. private IEnumerator CoAddScene(Scene f_scene)
  1151. {
  1152. while (!f_scene.isLoaded)
  1153. {
  1154. yield return null;
  1155. }
  1156. base.BroadcastMessage("OnLevelWasLoaded", f_scene.buildIndex, SendMessageOptions.DontRequireReceiver);
  1157. yield break;
  1158. }
  1159. public void SceneActivate(string f_strSceneName)
  1160. {
  1161. Scene sceneByName = SceneManager.GetSceneByName(f_strSceneName);
  1162. NDebug.Assert(true, f_strSceneName + " シーンはありません。");
  1163. NDebug.Assert(sceneByName.isLoaded, "未だ " + f_strSceneName + " はロードされていません。Start()以降で利用可能です。");
  1164. bool flag = SceneManager.SetActiveScene(sceneByName);
  1165. NDebug.Assert(flag, "シーンをアクティブ化できませんでした。");
  1166. }
  1167. public void UnloadScene(string f_strSceneName)
  1168. {
  1169. if (!this.m_listStackScene.Contains(f_strSceneName))
  1170. {
  1171. UnityEngine.Debug.LogWarning("追加シーンではないシーンを破棄しようとしました。" + f_strSceneName);
  1172. }
  1173. SceneManager.UnloadScene(f_strSceneName);
  1174. this.m_listStackScene.Remove(f_strSceneName);
  1175. string name;
  1176. if (this.m_listStackScene.Count<string>() == 0)
  1177. {
  1178. name = this.m_strBeforeSceneName;
  1179. }
  1180. else
  1181. {
  1182. name = this.m_listStackScene.Last<string>();
  1183. }
  1184. base.BroadcastMessage("OnLevelWasLoaded", SceneManager.GetSceneByName(name).buildIndex, SendMessageOptions.DontRequireReceiver);
  1185. UnityEngine.Debug.Log("シーンを破棄しました。" + f_strSceneName);
  1186. }
  1187. public void UnloadPopScene()
  1188. {
  1189. if (this.m_listStackScene.Count<string>() == 0)
  1190. {
  1191. return;
  1192. }
  1193. string f_strSceneName = this.m_listStackScene.Last<string>();
  1194. this.UnloadScene(f_strSceneName);
  1195. }
  1196. public void OnLevelWasLoaded(int level)
  1197. {
  1198. UnityEngine.Debug.Log("シーン切り替え完了 Level=" + level);
  1199. if (GameMain.Instance != null)
  1200. {
  1201. GameMain.Instance.SysShortcut.gameObject.SetActive(true);
  1202. }
  1203. }
  1204. private void Update()
  1205. {
  1206. if (GameMain.Instance.VRMode)
  1207. {
  1208. NInput.SelfUpdateVR();
  1209. }
  1210. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  1211. {
  1212. if (Input.GetKeyUp(KeyCode.Escape))
  1213. {
  1214. Cursor.visible = true;
  1215. Cursor.lockState = CursorLockMode.None;
  1216. }
  1217. if (NInput.GetMouseButtonUp(0) && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height)
  1218. {
  1219. Cursor.visible = false;
  1220. Cursor.lockState = CursorLockMode.Locked;
  1221. }
  1222. }
  1223. GameMain.m_TickCount = (int)(Time.realtimeSinceStartup * 1000f);
  1224. this.script_mgr_.Update();
  1225. }
  1226. public void ToApplicationQuit(bool f_bForceQuit = false)
  1227. {
  1228. if (f_bForceQuit)
  1229. {
  1230. Application.Quit();
  1231. }
  1232. else
  1233. {
  1234. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/終了しますか?", SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.OnToEnd), new SystemDialog.OnClick(this.OnCancel));
  1235. }
  1236. }
  1237. public void OnToEnd()
  1238. {
  1239. GameMain.Instance.SysDlg.Close();
  1240. Application.Quit();
  1241. }
  1242. public void OnCancel()
  1243. {
  1244. GameMain.Instance.SysDlg.Close();
  1245. }
  1246. protected override void OnApplicationQuit()
  1247. {
  1248. if (GameMain.Instance.VRMode)
  1249. {
  1250. this.BgMgr.OnSaveDD();
  1251. }
  1252. this.CMSystem.SaveSystem();
  1253. this.CMSystem.SaveIni();
  1254. this.m_bQuitting = true;
  1255. base.OnApplicationQuit();
  1256. UnityEngine.Debug.Log("GameMain::OnApplicationQuit");
  1257. }
  1258. private static GameMain m_objInstance;
  1259. [SerializeField]
  1260. private bool m_boDebugCharaLoad = true;
  1261. private CMSystem m_System;
  1262. private ScriptManager script_mgr_;
  1263. private ScriptManagerFast script_mgr_fast_;
  1264. private static int m_TickCount;
  1265. [SerializeField]
  1266. private CameraMain m_camMainCamera;
  1267. private CameraMain m_camBackupMainCamera;
  1268. [SerializeField]
  1269. private Camera m_camThumCamera;
  1270. [SerializeField]
  1271. private LightMain m_camMainLight;
  1272. private AnmParse anm_parse_;
  1273. private SoundMgr m_SoundMgr;
  1274. private CharacterMgr m_CharacterMgr;
  1275. private BgMgr m_BgMgr;
  1276. private FacilityManager m_FacilityMgr;
  1277. private KasizukiManager m_KasizukiMgr;
  1278. private ScenarioSelectMgr m_ScenarioSelectMgr = new ScenarioSelectMgr();
  1279. private EmpireLifeModeManager m_LifeModeMgr;
  1280. private SystemDialog m_SysDlg;
  1281. private LoadIcon m_LoadIcon;
  1282. private SystemShortcut m_SysShortcut;
  1283. private FpsCounter m_FpsCounter;
  1284. private List<KeyValuePair<Material, string>> m_listMozaMat = new List<KeyValuePair<Material, string>>();
  1285. private MessageWindowMgr m_MsgWnd;
  1286. private TutorialPanel m_TutorialPanel;
  1287. private bool m_bQuitting;
  1288. private long m_lNewSaveDataNo = -1L;
  1289. [SerializeField]
  1290. [Header("VRモード")]
  1291. private bool m_bVRMode;
  1292. private bool m_bVRDummyMode;
  1293. private bool m_bIsVRDeviceReady;
  1294. private GameMain.VRFamilyType m_eVRFamily;
  1295. private GameMain.VRDeviceType m_eVRDeviceType;
  1296. private OvrMgr m_OvrMgr;
  1297. private OVRLipSync m_LipSyncMgr;
  1298. private Webs m_Webs;
  1299. private AsyncOperation m_aoLoadScene;
  1300. private string m_strBeforeSceneName;
  1301. private List<string> m_listStackScene = new List<string>();
  1302. public enum VRFamilyType
  1303. {
  1304. NON,
  1305. Oculus,
  1306. HTC,
  1307. FOVE
  1308. }
  1309. public enum VRDeviceType
  1310. {
  1311. NON,
  1312. VIVE,
  1313. RIFT,
  1314. RIFT_TOUCH,
  1315. FOVE
  1316. }
  1317. public class SerializeHeader
  1318. {
  1319. public string strSaveTime;
  1320. public int nGameDay;
  1321. public string strPlayerName;
  1322. public int nMaidNum;
  1323. public string strComment;
  1324. public int nVer;
  1325. public long lHeaderSize;
  1326. }
  1327. private struct BinaryBookmark
  1328. {
  1329. public BinaryBookmark(BinaryWriter bwWrite)
  1330. {
  1331. this.bookmark_write_position = bwWrite.BaseStream.Position;
  1332. bwWrite.Write(-1L);
  1333. this.bookmark_value = -1L;
  1334. }
  1335. public BinaryBookmark(BinaryReader brRead)
  1336. {
  1337. this.bookmark_write_position = brRead.BaseStream.Position;
  1338. this.bookmark_value = brRead.ReadInt64();
  1339. }
  1340. public void WriteBinaryLength(BinaryWriter bwWrite)
  1341. {
  1342. long position = bwWrite.BaseStream.Position;
  1343. long value = position - this.bookmark_write_position - 8L;
  1344. bwWrite.Seek((int)this.bookmark_write_position, SeekOrigin.Begin);
  1345. bwWrite.Write(value);
  1346. bwWrite.Seek((int)position, SeekOrigin.Begin);
  1347. this.bookmark_value = value;
  1348. }
  1349. public readonly long bookmark_write_position;
  1350. public long bookmark_value;
  1351. }
  1352. }