GameMain.cs 43 KB

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