GameMain.cs 39 KB

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