GameMain.cs 41 KB

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