GameMain.cs 39 KB

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