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