GameMain.cs 40 KB

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