GameMain.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  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 PrivateMaidMode;
  12. using SceneNPCEdit;
  13. using Schedule;
  14. using UnityEngine;
  15. using UnityEngine.SceneManagement;
  16. using UnityEngine.VR;
  17. using Yotogis;
  18. public class GameMain : MonoSingleton<GameMain>
  19. {
  20. public bool IsDebugCharaLoad
  21. {
  22. get
  23. {
  24. return this.m_boDebugCharaLoad;
  25. }
  26. }
  27. public static GameMain Instance
  28. {
  29. get
  30. {
  31. return GameMain.m_objInstance;
  32. }
  33. }
  34. public static int tick_count
  35. {
  36. get
  37. {
  38. return GameMain.m_TickCount;
  39. }
  40. }
  41. public CameraMain MainCamera
  42. {
  43. get
  44. {
  45. return this.m_camMainCamera;
  46. }
  47. }
  48. public Camera ThumCamera
  49. {
  50. get
  51. {
  52. return this.m_camThumCamera;
  53. }
  54. }
  55. public LightMain MainLight
  56. {
  57. get
  58. {
  59. return this.m_camMainLight;
  60. }
  61. }
  62. public CMSystem CMSystem
  63. {
  64. get
  65. {
  66. return this.m_System;
  67. }
  68. }
  69. public ScriptManager ScriptMgr
  70. {
  71. get
  72. {
  73. return this.script_mgr_;
  74. }
  75. }
  76. public ScriptManagerFast ScriptMgrFast
  77. {
  78. get
  79. {
  80. return this.script_mgr_fast_;
  81. }
  82. }
  83. public AnmParse AnmParse
  84. {
  85. get
  86. {
  87. return this.anm_parse_;
  88. }
  89. }
  90. public EnumData EnumDataMPN { get; private set; }
  91. public EnumData EnumDataPartsColor { get; private set; }
  92. public MenuDataBase MenuDataBase { get; private set; }
  93. public SoundMgr SoundMgr
  94. {
  95. get
  96. {
  97. return this.m_SoundMgr;
  98. }
  99. }
  100. public CharacterMgr CharacterMgr
  101. {
  102. get
  103. {
  104. return this.m_CharacterMgr;
  105. }
  106. }
  107. public BgMgr BgMgr
  108. {
  109. get
  110. {
  111. return this.m_BgMgr;
  112. }
  113. }
  114. public FacilityManager FacilityMgr
  115. {
  116. get
  117. {
  118. return this.m_FacilityMgr;
  119. }
  120. }
  121. public KasizukiManager KasizukiMgr
  122. {
  123. get
  124. {
  125. return this.m_KasizukiMgr;
  126. }
  127. }
  128. public ScenarioSelectMgr ScenarioSelectMgr
  129. {
  130. get
  131. {
  132. return this.m_ScenarioSelectMgr;
  133. }
  134. }
  135. public EmpireLifeModeManager LifeModeMgr
  136. {
  137. get
  138. {
  139. return this.m_LifeModeMgr;
  140. }
  141. }
  142. public SystemDialog SysDlg
  143. {
  144. get
  145. {
  146. return this.m_SysDlg;
  147. }
  148. }
  149. public LoadIcon LoadIcon
  150. {
  151. get
  152. {
  153. return this.m_LoadIcon;
  154. }
  155. }
  156. public SystemShortcut SysShortcut
  157. {
  158. get
  159. {
  160. return this.m_SysShortcut;
  161. }
  162. }
  163. public FpsCounter FpsCounter
  164. {
  165. get
  166. {
  167. return this.m_FpsCounter;
  168. }
  169. }
  170. public MessageWindowMgr MsgWnd
  171. {
  172. get
  173. {
  174. return this.m_MsgWnd;
  175. }
  176. }
  177. public TutorialPanel TutorialPanel
  178. {
  179. get
  180. {
  181. return this.m_TutorialPanel;
  182. }
  183. }
  184. public bool isQuitting
  185. {
  186. get
  187. {
  188. return this.m_bQuitting;
  189. }
  190. }
  191. public bool IsForceSkip()
  192. {
  193. return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
  194. }
  195. public bool VRMode
  196. {
  197. get
  198. {
  199. return this.m_bVRMode;
  200. }
  201. }
  202. public bool VRDummyMode
  203. {
  204. get
  205. {
  206. return this.m_bVRDummyMode;
  207. }
  208. set
  209. {
  210. if (value || this.m_bVRDummyMode)
  211. {
  212. this.m_bVRMode = value;
  213. this.m_bVRDummyMode = value;
  214. }
  215. else
  216. {
  217. this.m_bVRDummyMode = value;
  218. }
  219. }
  220. }
  221. public bool IsVRDeviceReady
  222. {
  223. get
  224. {
  225. return this.m_bIsVRDeviceReady;
  226. }
  227. }
  228. public GameMain.VRFamilyType VRFamily
  229. {
  230. get
  231. {
  232. return this.m_eVRFamily;
  233. }
  234. }
  235. public GameMain.VRDeviceType VRDeviceTypeID
  236. {
  237. get
  238. {
  239. if (this.m_eVRDeviceType == GameMain.VRDeviceType.FOVE && SceneVRCommunication.Instance != null)
  240. {
  241. return GameMain.VRDeviceType.RIFT;
  242. }
  243. return this.m_eVRDeviceType;
  244. }
  245. set
  246. {
  247. this.m_eVRDeviceType = value;
  248. }
  249. }
  250. public OvrMgr OvrMgr
  251. {
  252. get
  253. {
  254. return this.m_OvrMgr;
  255. }
  256. }
  257. public OVRLipSync LipSyncMgr
  258. {
  259. get
  260. {
  261. return this.m_LipSyncMgr;
  262. }
  263. }
  264. public OvrIK OvrIK
  265. {
  266. get
  267. {
  268. return OvrIK.Instance;
  269. }
  270. }
  271. public Webs Webs
  272. {
  273. get
  274. {
  275. return this.m_Webs;
  276. }
  277. }
  278. public override void OnInitialize()
  279. {
  280. string[] commandLineArgs = Environment.GetCommandLineArgs();
  281. GameMain.m_objInstance = this;
  282. bool flag = false;
  283. if (!string.IsNullOrEmpty(Array.Find<string>(commandLineArgs, (string s) => s.ToLower().Contains("/reboot"))))
  284. {
  285. flag = true;
  286. }
  287. if (!flag)
  288. {
  289. Process currentProcess = Process.GetCurrentProcess();
  290. string processName = currentProcess.ProcessName;
  291. Process[] processesByName = Process.GetProcessesByName(processName);
  292. foreach (Process process in processesByName)
  293. {
  294. if (process.Id != currentProcess.Id)
  295. {
  296. NUty.WinMessageBox(NUty.GetWindowHandle(), "ゲームは既に起動しています。", "警告", 48);
  297. Application.Quit();
  298. return;
  299. }
  300. }
  301. }
  302. UnityEngine.Debug.Log("TestSingleton#OnInitialize");
  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 target = UTY.gameProjectPath + "\\";
  340. if (!UTY.IsLowercaseAlphanumeric(target))
  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. serializeHeader.productTypeID = (int)Product.type;
  637. binaryWriter.Write("COM3D2_SAVE");
  638. binaryWriter.Write(1430);
  639. this.SerializeWriteHeader(binaryWriter, serializeHeader);
  640. binaryWriter.Write("bookmark_kk_01");
  641. GameMain.BinaryBookmark binaryBookmark = new GameMain.BinaryBookmark(binaryWriter);
  642. binaryWriter.Write("bookmark_kk_02");
  643. GameMain.BinaryBookmark binaryBookmark2 = new GameMain.BinaryBookmark(binaryWriter);
  644. bool value = false;
  645. foreach (Maid maid in this.m_CharacterMgr.GetStockMaidList())
  646. {
  647. if (maid.status.isCompatiblePersonality)
  648. {
  649. value = true;
  650. break;
  651. }
  652. }
  653. binaryWriter.Write(value);
  654. binaryWriter.Write(GameUty.ExistCsvPathList.Count);
  655. foreach (string value2 in GameUty.ExistCsvPathList)
  656. {
  657. binaryWriter.Write(value2);
  658. }
  659. binaryWriter.Write(GameUty.ExistCsvPathListOld.Count);
  660. foreach (string value3 in GameUty.ExistCsvPathListOld)
  661. {
  662. binaryWriter.Write(value3);
  663. }
  664. this.m_CharacterMgr.Serialize(binaryWriter);
  665. this.script_mgr_.Serialize(binaryWriter);
  666. DeskManager.SerializeSingleSaveData(binaryWriter);
  667. this.m_ScenarioSelectMgr.Serialize(binaryWriter);
  668. this.m_FacilityMgr.Serialize(binaryWriter);
  669. this.m_LifeModeMgr.Serialize(binaryWriter);
  670. GameModeManager.Serialize(binaryWriter);
  671. binaryBookmark.WriteBinaryLength(binaryWriter);
  672. this.m_KasizukiMgr.Serialize(binaryWriter);
  673. binaryBookmark2.WriteBinaryLength(binaryWriter);
  674. CasinoDataMgr.Instance.Serialize(binaryWriter);
  675. VsDanceDataMgr.Instance.Serialize(binaryWriter);
  676. SaveData.Serialize(binaryWriter);
  677. binaryWriter.Write(1001);
  678. PrivateModeMgr.Instance.Serialize(binaryWriter);
  679. string path = this.MakeSavePathFileName(f_nSaveNo);
  680. File.WriteAllBytes(path, memoryStream.ToArray());
  681. memoryStream.Close();
  682. memoryStream.Dispose();
  683. memoryStream = null;
  684. this.UpdateSaveDataDay();
  685. return true;
  686. }
  687. private bool SerializeWriteHeader(BinaryWriter bwWrite, GameMain.SerializeHeader f_head)
  688. {
  689. bwWrite.Write(f_head.strSaveTime);
  690. bwWrite.Write(f_head.nGameDay);
  691. bwWrite.Write(f_head.strPlayerName);
  692. bwWrite.Write(f_head.nMaidNum);
  693. bwWrite.Write(f_head.strComment);
  694. bwWrite.Write(f_head.productTypeID);
  695. return true;
  696. }
  697. public string MakeSavePathFileName(int f_nSaveNo)
  698. {
  699. string str = UTY.gameProjectPath + "\\";
  700. string text = str + "SaveData";
  701. if (!Directory.Exists(text))
  702. {
  703. Directory.CreateDirectory(text);
  704. }
  705. return text + "/" + string.Format("SaveData{0:D3}", f_nSaveNo) + ".save";
  706. }
  707. public int GetSaveFileNameToSaveNo(string f_strFileName)
  708. {
  709. string text = Path.GetFileName(f_strFileName);
  710. if (Path.GetExtension(text) != Path.GetExtension(".save"))
  711. {
  712. return -1;
  713. }
  714. text = Path.GetFileNameWithoutExtension(text);
  715. if (text.Length != 11)
  716. {
  717. return -1;
  718. }
  719. int num = text.IndexOf("SaveData");
  720. if (num != 0)
  721. {
  722. return -1;
  723. }
  724. string s = text.Substring(8);
  725. int result = -1;
  726. if (!int.TryParse(s, out result))
  727. {
  728. return -1;
  729. }
  730. return result;
  731. }
  732. public bool SaveDataCommentSave(int f_nSaveNo, string f_strComment)
  733. {
  734. GameMain.SerializeHeader saveDataHeader = this.GetSaveDataHeader(f_nSaveNo);
  735. if (saveDataHeader == null)
  736. {
  737. UnityEngine.Debug.LogWarning("このスロットにはセーブデータはありません。" + f_nSaveNo);
  738. return false;
  739. }
  740. saveDataHeader.strComment = f_strComment;
  741. string path = this.MakeSavePathFileName(f_nSaveNo);
  742. FileStream fileStream = new FileStream(path, FileMode.Open);
  743. if (fileStream == null)
  744. {
  745. return false;
  746. }
  747. byte[] array = new byte[fileStream.Length];
  748. fileStream.Read(array, 0, (int)fileStream.Length);
  749. fileStream.Close();
  750. fileStream.Dispose();
  751. MemoryStream memoryStream = new MemoryStream();
  752. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  753. binaryWriter.Write("COM3D2_SAVE");
  754. binaryWriter.Write(1430);
  755. this.SerializeWriteHeader(binaryWriter, saveDataHeader);
  756. binaryWriter.Write(array, (int)saveDataHeader.lHeaderSize, (int)((long)array.Length - saveDataHeader.lHeaderSize));
  757. File.WriteAllBytes(path, memoryStream.ToArray());
  758. memoryStream.Close();
  759. memoryStream.Dispose();
  760. return true;
  761. }
  762. public void DeleteSerializeData(int f_nSaveNo)
  763. {
  764. string text = this.MakeSavePathFileName(f_nSaveNo);
  765. try
  766. {
  767. if (File.Exists(text))
  768. {
  769. File.Delete(text);
  770. }
  771. else
  772. {
  773. UnityEngine.Debug.LogWarning("SaveDataDelete削除失敗 ファイルが有りません。" + text);
  774. }
  775. }
  776. catch (Exception ex)
  777. {
  778. UnityEngine.Debug.LogWarning("SaveDataDelete削除失敗 " + ex.Message);
  779. }
  780. }
  781. public bool SerializeKasizukiOnly(int f_nSaveNo)
  782. {
  783. using (MemoryStream memoryStream = new MemoryStream())
  784. {
  785. using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
  786. {
  787. if (this.GetSaveDataHeader(f_nSaveNo) == null)
  788. {
  789. UnityEngine.Debug.LogWarning("このスロットにはセーブデータはありません。" + f_nSaveNo);
  790. return false;
  791. }
  792. string path = this.MakeSavePathFileName(f_nSaveNo);
  793. FileStream fileStream = new FileStream(path, FileMode.Open);
  794. if (fileStream == null)
  795. {
  796. return false;
  797. }
  798. byte[] buffer = new byte[fileStream.Length];
  799. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  800. fileStream.Read(buffer, 0, (int)fileStream.Length);
  801. fileStream.Close();
  802. fileStream.Dispose();
  803. binaryWriter.Write(binaryReader.ReadString());
  804. int num = binaryReader.ReadInt32();
  805. binaryWriter.Write(num);
  806. this.SerializeWriteHeader(binaryWriter, this.DeserializeReadHeader(binaryReader, num));
  807. GameMain.BinaryBookmark binaryBookmark;
  808. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_01"))
  809. {
  810. binaryBookmark = new GameMain.BinaryBookmark(binaryReader);
  811. }
  812. else
  813. {
  814. if (num >= 1280)
  815. {
  816. NDebug.MessageBox("傅きセーブ", "元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  817. UnityEngine.Debug.LogWarning("[GameMain.SerializeKasizukiOnly]\u3000元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  818. binaryReader.Close();
  819. return false;
  820. }
  821. long offset = (long)("bookmark_kk_01".Length + 1 - 4);
  822. binaryReader.BaseStream.Seek(offset, SeekOrigin.Current);
  823. int num2 = binaryReader.ReadInt32();
  824. binaryReader.BaseStream.Seek(-4L, SeekOrigin.Current);
  825. binaryBookmark = new GameMain.BinaryBookmark(binaryReader);
  826. binaryBookmark.bookmark_value = (long)num2;
  827. }
  828. GameMain.BinaryBookmark binaryBookmark2;
  829. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_02"))
  830. {
  831. binaryBookmark2 = new GameMain.BinaryBookmark(binaryReader);
  832. }
  833. else
  834. {
  835. if (num >= 1280)
  836. {
  837. NDebug.MessageBox("傅きセーブ", "元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  838. UnityEngine.Debug.LogWarning("[GameMain.SerializeKasizukiOnly]\u3000元セーブデータのしおり取得に失敗しました。古いセーブデータかもしれません。");
  839. binaryReader.Close();
  840. return false;
  841. }
  842. long offset2 = (long)("bookmark_kk_02".Length + 1);
  843. binaryReader.BaseStream.Seek(offset2, SeekOrigin.Current);
  844. int num3 = binaryReader.ReadInt32();
  845. binaryReader.BaseStream.Seek(-4L, SeekOrigin.Current);
  846. binaryBookmark2 = new GameMain.BinaryBookmark(binaryReader);
  847. binaryBookmark2.bookmark_value = (long)num3;
  848. }
  849. binaryWriter.Write("bookmark_kk_01");
  850. GameMain.BinaryBookmark binaryBookmark3 = new GameMain.BinaryBookmark(binaryWriter);
  851. binaryWriter.Write("bookmark_kk_02");
  852. GameMain.BinaryBookmark binaryBookmark4 = new GameMain.BinaryBookmark(binaryWriter);
  853. binaryReader.BaseStream.Seek(binaryBookmark.bookmark_write_position, SeekOrigin.Begin);
  854. binaryWriter.BaseStream.Seek(binaryBookmark3.bookmark_write_position, SeekOrigin.Begin);
  855. long num4 = (long)(8 + ("bookmark_kk_02".Length + 1) + 8);
  856. binaryReader.BaseStream.Seek(num4, SeekOrigin.Current);
  857. binaryWriter.BaseStream.Seek(num4, SeekOrigin.Current);
  858. binaryWriter.Write(binaryReader.ReadBytes((int)binaryBookmark.bookmark_value + 8 - (int)num4));
  859. binaryBookmark3.WriteBinaryLength(binaryWriter);
  860. this.KasizukiMgr.Serialize(binaryWriter);
  861. binaryBookmark4.WriteBinaryLength(binaryWriter);
  862. long num5 = binaryBookmark2.bookmark_value + binaryBookmark2.bookmark_write_position + 8L;
  863. binaryReader.BaseStream.Seek(num5, SeekOrigin.Begin);
  864. binaryWriter.Write(binaryReader.ReadBytes((int)binaryReader.BaseStream.Length - (int)num5));
  865. binaryReader.Close();
  866. File.WriteAllBytes(path, memoryStream.ToArray());
  867. }
  868. }
  869. return true;
  870. }
  871. private bool TryBinaryReadString(Stream stream, Func<string, bool> func)
  872. {
  873. BinaryReader binaryReader = new BinaryReader(stream);
  874. long position = binaryReader.BaseStream.Position;
  875. string arg = binaryReader.ReadString();
  876. bool flag = func(arg);
  877. if (!flag)
  878. {
  879. binaryReader.BaseStream.Seek(position, SeekOrigin.Begin);
  880. }
  881. return flag;
  882. }
  883. public bool Deserialize(int f_nSaveNo, bool scriptExec = true)
  884. {
  885. this.CMSystem.m_GenericTmpFlag.Clear();
  886. this.m_TutorialPanel.Reset();
  887. GameObject gameObject = GameObject.Find("SystemUI Root/TrophyAchieveEffect");
  888. if (gameObject != null)
  889. {
  890. TrophyAchieveEffect component = gameObject.GetComponent<TrophyAchieveEffect>();
  891. if (component != null)
  892. {
  893. component.EffectStackClear();
  894. }
  895. }
  896. string text = this.MakeSavePathFileName(f_nSaveNo);
  897. NDebug.Assert(File.Exists(text), "ファイルを開けません。" + text);
  898. FileStream fileStream = new FileStream(text, FileMode.Open);
  899. if (fileStream == null)
  900. {
  901. return false;
  902. }
  903. byte[] buffer = new byte[fileStream.Length];
  904. fileStream.Read(buffer, 0, (int)fileStream.Length);
  905. fileStream.Close();
  906. fileStream.Dispose();
  907. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  908. string text2 = binaryReader.ReadString();
  909. if (!(text2 == "COM3D2_SAVE"))
  910. {
  911. NDebug.MessageBox("エラー", "セーブデータファイルのヘッダーが不正です\n" + text2);
  912. binaryReader.Close();
  913. return false;
  914. }
  915. int num = binaryReader.ReadInt32();
  916. GameMain.SerializeHeader serializeHeader = this.DeserializeReadHeader(binaryReader, num);
  917. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_01"))
  918. {
  919. GameMain.BinaryBookmark binaryBookmark = new GameMain.BinaryBookmark(binaryReader);
  920. }
  921. else if (num < 1280)
  922. {
  923. long offset = (long)("bookmark_kk_01".Length + 1 + 8 - 4);
  924. binaryReader.BaseStream.Seek(offset, SeekOrigin.Current);
  925. }
  926. if (this.TryBinaryReadString(binaryReader.BaseStream, (string str) => str == "bookmark_kk_02"))
  927. {
  928. GameMain.BinaryBookmark binaryBookmark2 = new GameMain.BinaryBookmark(binaryReader);
  929. }
  930. else if (num < 1280)
  931. {
  932. long offset2 = (long)("bookmark_kk_02".Length + 1 + 8);
  933. binaryReader.BaseStream.Seek(offset2, SeekOrigin.Current);
  934. }
  935. bool flag = false;
  936. if (215 < num)
  937. {
  938. flag = binaryReader.ReadBoolean();
  939. if (flag)
  940. {
  941. bool flag2 = false;
  942. if (!GameUty.IsEnabledCompatibilityMode)
  943. {
  944. UnityEngine.Debug.LogError("カスタムメイド3D2のメイドがいますが、カスタムメイド3D2の互換設定が正しくありません");
  945. NDebug.MessageBox("エラー", "カスタムメイド3D2のメイドがいますが、カスタムメイド3D2の互換設定が正しくありません");
  946. flag2 = true;
  947. }
  948. if (!flag2 && !PluginData.IsEnabled("Legacy"))
  949. {
  950. UnityEngine.Debug.LogError("カスタムメイド3D2のメイドがいますが、互換アップデートパッチがインストールされていません");
  951. NDebug.MessageBox("エラー", "カスタムメイド3D2のメイドがいますが、互換アップデートパッチがインストールされていません");
  952. flag2 = true;
  953. }
  954. if (flag2)
  955. {
  956. binaryReader.Close();
  957. return false;
  958. }
  959. }
  960. List<string> list = new List<string>();
  961. int num2 = binaryReader.ReadInt32();
  962. for (int i = 0; i < num2; i++)
  963. {
  964. list.Add(binaryReader.ReadString());
  965. }
  966. List<string> list2 = new List<string>();
  967. foreach (string item in list)
  968. {
  969. if (!GameUty.ExistCsvPathList.Contains(item))
  970. {
  971. list2.Add(item);
  972. }
  973. }
  974. if (list2.Count > 0)
  975. {
  976. string text3 = Product.gameTitle + "に以下のプラグインが存在しません。\n不具合が出る可能性があります。\n";
  977. num2 = 1;
  978. foreach (string str3 in list2)
  979. {
  980. text3 += str3;
  981. if (num2 % 5 == 0)
  982. {
  983. text3 += "\n";
  984. }
  985. else
  986. {
  987. text3 += ",";
  988. }
  989. num2++;
  990. }
  991. UnityEngine.Debug.LogError(text3);
  992. NDebug.MessageBox("エラー", text3);
  993. }
  994. List<string> list3 = new List<string>();
  995. num2 = binaryReader.ReadInt32();
  996. for (int j = 0; j < num2; j++)
  997. {
  998. list3.Add(binaryReader.ReadString());
  999. }
  1000. if (flag)
  1001. {
  1002. list2 = new List<string>();
  1003. foreach (string item2 in list3)
  1004. {
  1005. if (!GameUty.ExistCsvPathListOld.Contains(item2))
  1006. {
  1007. list2.Add(item2);
  1008. }
  1009. }
  1010. if (list2.Count > 0)
  1011. {
  1012. string text4 = "カスタムメイド3D2に以下のプラグインが存在しません。\n不具合が出る可能性があります。\n";
  1013. num2 = 1;
  1014. foreach (string str2 in list2)
  1015. {
  1016. text4 += str2;
  1017. if (num2 % 5 == 0)
  1018. {
  1019. text4 += "\n";
  1020. }
  1021. else
  1022. {
  1023. text4 += ",";
  1024. }
  1025. num2++;
  1026. }
  1027. UnityEngine.Debug.LogError(text4);
  1028. NDebug.MessageBox("エラー", text4);
  1029. }
  1030. }
  1031. }
  1032. try
  1033. {
  1034. this.m_CharacterMgr.Deserialize(binaryReader);
  1035. this.script_mgr_.Deserialize(binaryReader);
  1036. DeskManager.DeserializeSingleSaveData(binaryReader, num);
  1037. if (num >= 206)
  1038. {
  1039. this.m_ScenarioSelectMgr.Deserialize(binaryReader);
  1040. }
  1041. this.m_FacilityMgr.Deserialize(binaryReader);
  1042. this.m_LifeModeMgr.Deserialize(binaryReader);
  1043. GameModeManager.Deserialize(binaryReader);
  1044. this.m_KasizukiMgr.Deserialize(f_nSaveNo, binaryReader);
  1045. CasinoDataMgr.Instance.Deserialize(binaryReader, num);
  1046. VsDanceDataMgr.Instance.Deserialize(binaryReader, num);
  1047. SaveData.Deserialize(binaryReader, num);
  1048. int num3 = 0;
  1049. if (num >= 1330)
  1050. {
  1051. num3 = binaryReader.ReadInt32();
  1052. }
  1053. if (num3 >= 1001)
  1054. {
  1055. PrivateModeMgr.Instance.Deserialize(binaryReader, num);
  1056. }
  1057. binaryReader.Close();
  1058. binaryReader = null;
  1059. }
  1060. catch (Exception ex)
  1061. {
  1062. UnityEngine.Debug.LogError(ex.Message + "\n\n" + ex.StackTrace);
  1063. NDebug.MessageBox("エラー", ex.Message + "\n\n" + ex.StackTrace);
  1064. binaryReader.Close();
  1065. return false;
  1066. }
  1067. if (scriptExec)
  1068. {
  1069. this.ScriptMgr.adv_kag.Exec();
  1070. }
  1071. return true;
  1072. }
  1073. private GameMain.SerializeHeader DeserializeReadHeader(BinaryReader brRead, int gameVersion)
  1074. {
  1075. GameMain.SerializeHeader serializeHeader = new GameMain.SerializeHeader();
  1076. serializeHeader.strSaveTime = brRead.ReadString();
  1077. serializeHeader.nGameDay = brRead.ReadInt32();
  1078. serializeHeader.strPlayerName = brRead.ReadString();
  1079. serializeHeader.nMaidNum = brRead.ReadInt32();
  1080. serializeHeader.strComment = brRead.ReadString();
  1081. long position = brRead.BaseStream.Position;
  1082. byte b = brRead.ReadByte();
  1083. brRead.BaseStream.Seek(position, SeekOrigin.Begin);
  1084. if (b != 14)
  1085. {
  1086. serializeHeader.productTypeID = brRead.ReadInt32();
  1087. }
  1088. else
  1089. {
  1090. serializeHeader.productTypeID = 0;
  1091. }
  1092. return serializeHeader;
  1093. }
  1094. public GameMain.SerializeHeader GetSaveDataHeader(int f_nSaveNo)
  1095. {
  1096. string path = this.MakeSavePathFileName(f_nSaveNo);
  1097. if (File.Exists(path))
  1098. {
  1099. GameMain.SerializeHeader serializeHeader;
  1100. using (FileStream fileStream = new FileStream(path, FileMode.Open))
  1101. {
  1102. if (fileStream == null)
  1103. {
  1104. return null;
  1105. }
  1106. BinaryReader binaryReader = new BinaryReader(fileStream);
  1107. string a = binaryReader.ReadString();
  1108. if (a == "COM3D2_CBL_SAVE")
  1109. {
  1110. return null;
  1111. }
  1112. NDebug.Assert(a == "COM3D2_SAVE", "セーブデータファイルのヘッダーが不正です。_SAVE 2");
  1113. int num = binaryReader.ReadInt32();
  1114. serializeHeader = this.DeserializeReadHeader(binaryReader, num);
  1115. serializeHeader.nVer = num;
  1116. serializeHeader.lHeaderSize = binaryReader.BaseStream.Position;
  1117. }
  1118. return serializeHeader;
  1119. }
  1120. return null;
  1121. }
  1122. public bool IsSaveDataNew(int f_nSaveNo)
  1123. {
  1124. return (long)f_nSaveNo == this.m_lNewSaveDataNo;
  1125. }
  1126. public long NewSaveDataNo()
  1127. {
  1128. return this.m_lNewSaveDataNo;
  1129. }
  1130. public void UpdateSaveDataDay()
  1131. {
  1132. string str = UTY.gameProjectPath + "\\";
  1133. string path = str + "SaveData";
  1134. int num = -1;
  1135. if (Directory.Exists(path))
  1136. {
  1137. string[] files = Directory.GetFiles(path, "*.save");
  1138. long num2 = -1L;
  1139. foreach (string f_strFileName in files)
  1140. {
  1141. int saveFileNameToSaveNo = this.GetSaveFileNameToSaveNo(f_strFileName);
  1142. if (saveFileNameToSaveNo != -1)
  1143. {
  1144. GameMain.SerializeHeader saveDataHeader = this.GetSaveDataHeader(saveFileNameToSaveNo);
  1145. if (saveDataHeader != null)
  1146. {
  1147. long num3 = 0L;
  1148. if (long.TryParse(saveDataHeader.strSaveTime, out num3))
  1149. {
  1150. if (num2 < num3)
  1151. {
  1152. num2 = num3;
  1153. num = saveFileNameToSaveNo;
  1154. }
  1155. }
  1156. }
  1157. }
  1158. }
  1159. }
  1160. this.m_lNewSaveDataNo = (long)num;
  1161. }
  1162. public override void OnFinalize()
  1163. {
  1164. UnityEngine.Debug.Log("GameMain::OnFinalize Start");
  1165. base.BroadcastMessage("OnPreFinalize", SendMessageOptions.DontRequireReceiver);
  1166. UnityEngine.Object.DestroyImmediate(this.CharacterMgr);
  1167. UnityEngine.Object.DestroyImmediate(this.SoundMgr);
  1168. this.anm_parse_.Dispose();
  1169. this.script_mgr_fast_.SelfDispose();
  1170. this.script_mgr_.Dispose();
  1171. if (this.MenuDataBase != null)
  1172. {
  1173. this.MenuDataBase.Dispose();
  1174. this.MenuDataBase = null;
  1175. }
  1176. this.EnumDataMPN.Dispose();
  1177. this.EnumDataPartsColor.Dispose();
  1178. GameUty.Finish();
  1179. UTY.FreeDll();
  1180. UnityEngine.Debug.Log("GameMain::OnFinalize Finish");
  1181. }
  1182. public string GetNowSceneName()
  1183. {
  1184. return this.m_strBeforeSceneName;
  1185. }
  1186. public List<string> GetAddSceneName()
  1187. {
  1188. return this.m_listStackScene;
  1189. }
  1190. public void LoadScene(string f_strSceneName)
  1191. {
  1192. this.m_listStackScene.Clear();
  1193. SceneManager.LoadScene(f_strSceneName, LoadSceneMode.Single);
  1194. this.m_strBeforeSceneName = f_strSceneName;
  1195. UnityEngine.Debug.Log("GameMain::LoadScene " + f_strSceneName);
  1196. }
  1197. public void AddScene(string f_strSceneName)
  1198. {
  1199. if (this.m_listStackScene.Contains(f_strSceneName))
  1200. {
  1201. NDebug.Assert("AddScene 既に同名のシーンがロードされています。" + f_strSceneName, false);
  1202. return;
  1203. }
  1204. SceneManager.LoadScene(f_strSceneName, LoadSceneMode.Additive);
  1205. this.m_listStackScene.Add(f_strSceneName);
  1206. base.StartCoroutine(this.CoAddScene(SceneManager.GetSceneByName(f_strSceneName)));
  1207. }
  1208. private IEnumerator CoAddScene(Scene f_scene)
  1209. {
  1210. while (!f_scene.isLoaded)
  1211. {
  1212. yield return null;
  1213. }
  1214. base.BroadcastMessage("OnLevelWasLoaded", f_scene.buildIndex, SendMessageOptions.DontRequireReceiver);
  1215. yield break;
  1216. }
  1217. public void SceneActivate(string f_strSceneName)
  1218. {
  1219. Scene sceneByName = SceneManager.GetSceneByName(f_strSceneName);
  1220. NDebug.Assert(true, f_strSceneName + " シーンはありません。");
  1221. NDebug.Assert(sceneByName.isLoaded, "未だ " + f_strSceneName + " はロードされていません。Start()以降で利用可能です。");
  1222. bool flag = SceneManager.SetActiveScene(sceneByName);
  1223. NDebug.Assert(flag, "シーンをアクティブ化できませんでした。");
  1224. }
  1225. public void UnloadScene(string f_strSceneName)
  1226. {
  1227. if (!this.m_listStackScene.Contains(f_strSceneName))
  1228. {
  1229. UnityEngine.Debug.LogWarning("追加シーンではないシーンを破棄しようとしました。" + f_strSceneName);
  1230. }
  1231. SceneManager.UnloadScene(f_strSceneName);
  1232. this.m_listStackScene.Remove(f_strSceneName);
  1233. string name;
  1234. if (this.m_listStackScene.Count<string>() == 0)
  1235. {
  1236. name = this.m_strBeforeSceneName;
  1237. }
  1238. else
  1239. {
  1240. name = this.m_listStackScene.Last<string>();
  1241. }
  1242. base.BroadcastMessage("OnLevelWasLoaded", SceneManager.GetSceneByName(name).buildIndex, SendMessageOptions.DontRequireReceiver);
  1243. UnityEngine.Debug.Log("シーンを破棄しました。" + f_strSceneName);
  1244. }
  1245. public void UnloadPopScene()
  1246. {
  1247. if (this.m_listStackScene.Count<string>() == 0)
  1248. {
  1249. return;
  1250. }
  1251. string f_strSceneName = this.m_listStackScene.Last<string>();
  1252. this.UnloadScene(f_strSceneName);
  1253. }
  1254. public void OnLevelWasLoaded(int level)
  1255. {
  1256. UnityEngine.Debug.Log("シーン切り替え完了 Level=" + level);
  1257. if (GameMain.Instance != null)
  1258. {
  1259. GameMain.Instance.SysShortcut.gameObject.SetActive(true);
  1260. }
  1261. }
  1262. private void Update()
  1263. {
  1264. if (GameMain.Instance.VRMode)
  1265. {
  1266. NInput.SelfUpdateVR();
  1267. }
  1268. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  1269. {
  1270. if (Input.GetKeyUp(KeyCode.Escape))
  1271. {
  1272. Cursor.visible = true;
  1273. Cursor.lockState = CursorLockMode.None;
  1274. }
  1275. if (NInput.GetMouseButtonUp(0) && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height)
  1276. {
  1277. Cursor.visible = false;
  1278. Cursor.lockState = CursorLockMode.Locked;
  1279. }
  1280. }
  1281. GameMain.m_TickCount = (int)(Time.realtimeSinceStartup * 1000f);
  1282. this.script_mgr_.Update();
  1283. }
  1284. public void ToApplicationQuit(bool f_bForceQuit = false)
  1285. {
  1286. if (f_bForceQuit)
  1287. {
  1288. Application.Quit();
  1289. }
  1290. else
  1291. {
  1292. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/終了しますか?", null, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.OnToEnd), new SystemDialog.OnClick(this.OnCancel));
  1293. }
  1294. }
  1295. public void OnToEnd()
  1296. {
  1297. GameMain.Instance.SysDlg.Close();
  1298. Application.Quit();
  1299. }
  1300. public void OnCancel()
  1301. {
  1302. GameMain.Instance.SysDlg.Close();
  1303. }
  1304. protected override void OnApplicationQuit()
  1305. {
  1306. if (GameMain.Instance.VRMode)
  1307. {
  1308. this.BgMgr.OnSaveDD();
  1309. }
  1310. this.CMSystem.SaveSystem();
  1311. this.CMSystem.SaveIni();
  1312. this.m_bQuitting = true;
  1313. base.OnApplicationQuit();
  1314. UnityEngine.Debug.Log("GameMain::OnApplicationQuit");
  1315. Product.OnApplicationQuit();
  1316. }
  1317. private const int SaveDataVersion = 1001;
  1318. private static GameMain m_objInstance;
  1319. [SerializeField]
  1320. private bool m_boDebugCharaLoad = true;
  1321. private CMSystem m_System;
  1322. private ScriptManager script_mgr_;
  1323. private ScriptManagerFast script_mgr_fast_;
  1324. private static int m_TickCount;
  1325. [SerializeField]
  1326. private CameraMain m_camMainCamera;
  1327. private CameraMain m_camBackupMainCamera;
  1328. [SerializeField]
  1329. private Camera m_camThumCamera;
  1330. [SerializeField]
  1331. private LightMain m_camMainLight;
  1332. private AnmParse anm_parse_;
  1333. private SoundMgr m_SoundMgr;
  1334. private CharacterMgr m_CharacterMgr;
  1335. private BgMgr m_BgMgr;
  1336. private FacilityManager m_FacilityMgr;
  1337. private KasizukiManager m_KasizukiMgr;
  1338. private ScenarioSelectMgr m_ScenarioSelectMgr = new ScenarioSelectMgr();
  1339. private EmpireLifeModeManager m_LifeModeMgr;
  1340. private SystemDialog m_SysDlg;
  1341. private LoadIcon m_LoadIcon;
  1342. private SystemShortcut m_SysShortcut;
  1343. private FpsCounter m_FpsCounter;
  1344. private List<KeyValuePair<Material, string>> m_listMozaMat = new List<KeyValuePair<Material, string>>();
  1345. private MessageWindowMgr m_MsgWnd;
  1346. private TutorialPanel m_TutorialPanel;
  1347. private bool m_bQuitting;
  1348. private long m_lNewSaveDataNo = -1L;
  1349. [SerializeField]
  1350. [Header("VRモード")]
  1351. private bool m_bVRMode;
  1352. private bool m_bVRDummyMode;
  1353. private bool m_bIsVRDeviceReady;
  1354. private GameMain.VRFamilyType m_eVRFamily;
  1355. private GameMain.VRDeviceType m_eVRDeviceType;
  1356. private OvrMgr m_OvrMgr;
  1357. private OVRLipSync m_LipSyncMgr;
  1358. private Webs m_Webs;
  1359. private AsyncOperation m_aoLoadScene;
  1360. private string m_strBeforeSceneName;
  1361. private List<string> m_listStackScene = new List<string>();
  1362. public enum VRFamilyType
  1363. {
  1364. NON,
  1365. Oculus,
  1366. HTC,
  1367. FOVE
  1368. }
  1369. public enum VRDeviceType
  1370. {
  1371. NON,
  1372. VIVE,
  1373. RIFT,
  1374. RIFT_TOUCH,
  1375. FOVE
  1376. }
  1377. public class SerializeHeader
  1378. {
  1379. public string strSaveTime;
  1380. public int nGameDay;
  1381. public string strPlayerName;
  1382. public int nMaidNum;
  1383. public string strComment;
  1384. public int productTypeID;
  1385. public int nVer;
  1386. public long lHeaderSize;
  1387. }
  1388. private struct BinaryBookmark
  1389. {
  1390. public BinaryBookmark(BinaryWriter bwWrite)
  1391. {
  1392. this.bookmark_write_position = bwWrite.BaseStream.Position;
  1393. bwWrite.Write(-1L);
  1394. this.bookmark_value = -1L;
  1395. }
  1396. public BinaryBookmark(BinaryReader brRead)
  1397. {
  1398. this.bookmark_write_position = brRead.BaseStream.Position;
  1399. this.bookmark_value = brRead.ReadInt64();
  1400. }
  1401. public void WriteBinaryLength(BinaryWriter bwWrite)
  1402. {
  1403. long position = bwWrite.BaseStream.Position;
  1404. long value = position - this.bookmark_write_position - 8L;
  1405. bwWrite.Seek((int)this.bookmark_write_position, SeekOrigin.Begin);
  1406. bwWrite.Write(value);
  1407. bwWrite.Seek((int)position, SeekOrigin.Begin);
  1408. this.bookmark_value = value;
  1409. }
  1410. public readonly long bookmark_write_position;
  1411. public long bookmark_value;
  1412. }
  1413. }