GameMain.cs 38 KB

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