GameMain.cs 39 KB

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