GameMain.cs 41 KB

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