KasizukiManager.cs 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.IO;
  6. using System.Runtime.CompilerServices;
  7. using FacilityFlag;
  8. using MaidStatus;
  9. using PlayerStatus;
  10. using UnityEngine;
  11. namespace Kasizuki
  12. {
  13. public class KasizukiManager : MonoBehaviour
  14. {
  15. public int NowOriginSaveDataNumber
  16. {
  17. get
  18. {
  19. return this.m_NowOriginSaveDataNumber;
  20. }
  21. set
  22. {
  23. this.m_NowOriginSaveDataNumber = value;
  24. }
  25. }
  26. public int NowSaveDataIndex
  27. {
  28. get
  29. {
  30. return this.m_NowKasizukiSaveDataIndex;
  31. }
  32. }
  33. public int LatestSaveDataNumber
  34. {
  35. get
  36. {
  37. return this.m_LatestSaveDataNumber;
  38. }
  39. }
  40. public DataArray<string, string> systemData
  41. {
  42. get
  43. {
  44. return this.m_SystemData;
  45. }
  46. }
  47. public Dictionary<string, DataArray<string, string>> maidDataArray
  48. {
  49. get
  50. {
  51. return this.m_MaidDataArray;
  52. }
  53. }
  54. private void Awake()
  55. {
  56. }
  57. public void Init()
  58. {
  59. this.ResetData();
  60. if (this.m_SaveDataArray != null)
  61. {
  62. this.m_SaveDataArray.Clear();
  63. this.m_SaveDataArray = null;
  64. }
  65. this.m_SaveDataArray = new Dictionary<int, KasizukiManager.SaveData>();
  66. }
  67. public void UnInit()
  68. {
  69. if (this.m_NowHaveItemDic != null)
  70. {
  71. this.m_NowHaveItemDic.Clear();
  72. this.m_NowHaveItemDic = null;
  73. }
  74. this.m_SystemData = null;
  75. if (this.m_MaidDataArray != null)
  76. {
  77. this.m_MaidDataArray.Clear();
  78. this.m_MaidDataArray = null;
  79. }
  80. }
  81. private void ResetData()
  82. {
  83. if (this.m_NowHaveItemDic != null)
  84. {
  85. this.m_NowHaveItemDic.Clear();
  86. }
  87. else
  88. {
  89. this.m_NowHaveItemDic = new DataArray<int, bool>();
  90. }
  91. if (this.m_SystemData != null)
  92. {
  93. this.m_SystemData.Clear();
  94. }
  95. else
  96. {
  97. this.m_SystemData = new DataArray<string, string>();
  98. }
  99. if (this.m_MaidDataArray != null)
  100. {
  101. this.m_MaidDataArray.Clear();
  102. }
  103. else
  104. {
  105. this.m_MaidDataArray = new Dictionary<string, DataArray<string, string>>();
  106. }
  107. this.SetNowManType(ManDataType.主人公);
  108. }
  109. public void CreateNewData()
  110. {
  111. this.ResetData();
  112. }
  113. public bool IsMeetConditions(string comparisonFlagName, string comparisonOperator, string comparisonValue, bool isEnableWarning = true)
  114. {
  115. if (string.IsNullOrEmpty(comparisonOperator))
  116. {
  117. NDebug.Assert("KasizukiManager.IsMeetConditions(string[])\n比較演算子が空文字でした", false);
  118. Debug.LogError("KasizukiManager.IsMeetConditions(string[])\n比較演算子が空文字でした");
  119. }
  120. if (string.IsNullOrEmpty(comparisonFlagName))
  121. {
  122. NDebug.Assert("KasizukiManager.IsMeetConditions(string[])\n比較するフラグ名が空文字でした", false);
  123. Debug.LogError("KasizukiManager.IsMeetConditions(string[])\n比較するフラグ名が空文字でした");
  124. }
  125. if (string.IsNullOrEmpty(comparisonValue))
  126. {
  127. NDebug.Assert("KasizukiManager.IsMeetConditions(string[])\n比較する値が空文字でした", false);
  128. Debug.LogError("KasizukiManager.IsMeetConditions(string[])\n比較する値が空文字でした");
  129. }
  130. string text;
  131. if (!this.TryGetSystemData<string>(comparisonFlagName, out text))
  132. {
  133. if (isEnableWarning)
  134. {
  135. NDebug.Warning(string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]は存在しませんでした。", comparisonFlagName));
  136. Debug.LogWarning(string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]は存在しませんでした。", comparisonFlagName));
  137. }
  138. return false;
  139. }
  140. if (comparisonOperator != null)
  141. {
  142. if (comparisonOperator == "<")
  143. {
  144. int num;
  145. NDebug.Assert(int.TryParse(text, out num), string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]の値は数値に変換できません", comparisonFlagName));
  146. int num2;
  147. NDebug.Assert(int.TryParse(comparisonValue, out num2), string.Format("KasizukiManager.IsMeetConditions(string[])\n文字列[{0}]は数値に変換できません", comparisonValue));
  148. return num < num2;
  149. }
  150. if (comparisonOperator == ">")
  151. {
  152. int num;
  153. NDebug.Assert(int.TryParse(text, out num), string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]の値は数値に変換できません", comparisonFlagName));
  154. int num2;
  155. NDebug.Assert(int.TryParse(comparisonValue, out num2), string.Format("KasizukiManager.IsMeetConditions(string[])\n文字列[{0}]は数値に変換できません", comparisonValue));
  156. return num > num2;
  157. }
  158. if (comparisonOperator == "<=")
  159. {
  160. int num;
  161. NDebug.Assert(int.TryParse(text, out num), string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]の値は数値に変換できません", comparisonFlagName));
  162. int num2;
  163. NDebug.Assert(int.TryParse(comparisonValue, out num2), string.Format("KasizukiManager.IsMeetConditions(string[])\n文字列[{0}]は数値に変換できません", comparisonValue));
  164. return num <= num2;
  165. }
  166. if (comparisonOperator == ">=")
  167. {
  168. int num;
  169. NDebug.Assert(int.TryParse(text, out num), string.Format("KasizukiManager.IsMeetConditions(string[])\nフラグ[{0}]の値は数値に変換できません", comparisonFlagName));
  170. int num2;
  171. NDebug.Assert(int.TryParse(comparisonValue, out num2), string.Format("KasizukiManager.IsMeetConditions(string[])\n文字列[{0}]は数値に変換できません", comparisonValue));
  172. return num >= num2;
  173. }
  174. if (comparisonOperator == "=")
  175. {
  176. return text.CompareTo(comparisonValue) == 0;
  177. }
  178. if (comparisonOperator == "!")
  179. {
  180. return text.CompareTo(comparisonValue) != 0;
  181. }
  182. }
  183. NDebug.Assert(string.Format("KasizukiManager.IsMeetConditions(string[])\n比較演算子に不正な文字列が指定されました\n受け取った比較演算子:{0}", comparisonOperator), false);
  184. return false;
  185. }
  186. public bool IsMeetConditions(string[] str)
  187. {
  188. if (str.Length != 3)
  189. {
  190. NDebug.Assert("KasizukiManager.IsMeetConditions(string[])\n引数の数が正しくありません。", false);
  191. Debug.LogErrorFormat("KasizukiManager.IsMeetConditions(string[])\n渡された引数の数:{0}", new object[]
  192. {
  193. str.Length
  194. });
  195. return false;
  196. }
  197. return this.IsMeetConditions(str[0], str[1], str[2], true);
  198. }
  199. private void UpdateData<T>(DataArray<string, string> dataArray, string valueName, T value, bool enableWarningEmptyData = true)
  200. {
  201. if (dataArray == null)
  202. {
  203. NDebug.Assert("データ配列にnullが指定されました", false);
  204. return;
  205. }
  206. string value2 = value.ToString();
  207. if (!dataArray.Contains(valueName))
  208. {
  209. if (enableWarningEmptyData)
  210. {
  211. NDebug.Warning(string.Format("データ配列には「{0}」が登録されていません。", valueName));
  212. return;
  213. }
  214. dataArray.Add(valueName, value2, false);
  215. }
  216. else
  217. {
  218. dataArray.Add(valueName, value2, true);
  219. }
  220. }
  221. private T GetData<T>(DataArray<string, string> dataArray, string valueName, bool enableWarningEmptyData = true)
  222. {
  223. if (dataArray == null)
  224. {
  225. NDebug.Assert("データ配列にnullが指定されました", false);
  226. return default(T);
  227. }
  228. string text = dataArray.Get(valueName, false);
  229. if (text == null)
  230. {
  231. if (enableWarningEmptyData)
  232. {
  233. Debug.LogWarning(string.Format("データ配列には「{0}」が登録されていません。", valueName));
  234. }
  235. return default(T);
  236. }
  237. Type typeFromHandle = typeof(T);
  238. TypeConverter converter = TypeDescriptor.GetConverter(typeFromHandle);
  239. T result = default(T);
  240. try
  241. {
  242. if (converter != null)
  243. {
  244. result = (T)((object)converter.ConvertFromString(text));
  245. }
  246. }
  247. catch (Exception ex)
  248. {
  249. string message = string.Concat(new string[]
  250. {
  251. "データの変換に失敗しました\n値: ",
  252. text,
  253. "\nを ",
  254. typeFromHandle.Name,
  255. " への変換に失敗しました。"
  256. });
  257. NDebug.Warning(message);
  258. Debug.LogWarning(message);
  259. }
  260. return result;
  261. }
  262. private bool TryGetData<T>(DataArray<string, string> dataArray, string valueName, out T value)
  263. {
  264. value = default(T);
  265. if (dataArray == null)
  266. {
  267. NDebug.Assert("データ配列にnullが指定されました", false);
  268. Debug.LogError("データ配列にnullが指定されました");
  269. return false;
  270. }
  271. string text = dataArray.Get(valueName, false);
  272. if (text == null)
  273. {
  274. return false;
  275. }
  276. Type typeFromHandle = typeof(T);
  277. TypeConverter converter = TypeDescriptor.GetConverter(typeFromHandle);
  278. try
  279. {
  280. if (converter != null)
  281. {
  282. value = (T)((object)converter.ConvertFromString(text));
  283. }
  284. }
  285. catch (Exception ex)
  286. {
  287. string message = string.Concat(new string[]
  288. {
  289. "データの変換に失敗しました\n値: ",
  290. text,
  291. "\nを ",
  292. typeFromHandle.Name,
  293. " への変換に失敗しました。"
  294. });
  295. NDebug.Warning(message);
  296. Debug.LogWarning(message);
  297. }
  298. return true;
  299. }
  300. private bool RemoveData(DataArray<string, string> dataArray, string valueName, bool enableWarningEmptyData = true)
  301. {
  302. if (dataArray == null)
  303. {
  304. NDebug.Assert("データ配列にnullが指定されました", false);
  305. return false;
  306. }
  307. bool flag = dataArray.Remove(valueName, enableWarningEmptyData);
  308. if (!flag && enableWarningEmptyData)
  309. {
  310. NDebug.Warning(string.Format("データ配列には「{0}」が登録されていません。", valueName));
  311. }
  312. return flag;
  313. }
  314. public void SetSystemData<T>(string valueName, T value, bool isEnableDebugLog = false)
  315. {
  316. this.UpdateData<T>(this.m_SystemData, valueName, value, false);
  317. if (isEnableDebugLog)
  318. {
  319. Debug.LogFormat("傅きモードのシステムの情報を更新しました。\nデータ名:{0}\u3000\u3000値:{1}", new object[]
  320. {
  321. valueName,
  322. value.ToString()
  323. });
  324. }
  325. }
  326. public void SetSystemData<T>(SystemDataType dataType, T value, bool isEnableDebugLog = false)
  327. {
  328. string name = Enum.GetName(typeof(SystemDataType), dataType);
  329. if (string.IsNullOrEmpty(name))
  330. {
  331. NDebug.Assert("データ型に不正な値が入りました", false);
  332. Debug.LogError("データ型に不正な値が入りました");
  333. }
  334. this.SetSystemData<T>(name, value, isEnableDebugLog);
  335. }
  336. public T GetSystemData<T>(string valueName)
  337. {
  338. return this.GetData<T>(this.m_SystemData, valueName, false);
  339. }
  340. public T GetSystemData<T>(SystemDataType dataType)
  341. {
  342. string name = Enum.GetName(typeof(SystemDataType), dataType);
  343. if (string.IsNullOrEmpty(name))
  344. {
  345. NDebug.Assert("データ型に不正な値が入りました", false);
  346. Debug.LogError("データ型に不正な値が入りました");
  347. }
  348. return this.GetSystemData<T>(name);
  349. }
  350. public bool TryGetSystemData<T>(string valueName, out T value)
  351. {
  352. return this.TryGetData<T>(this.m_SystemData, valueName, out value);
  353. }
  354. public bool TryGetSystemData<T>(SystemDataType dataType, out T value)
  355. {
  356. string name = Enum.GetName(typeof(SystemDataType), dataType);
  357. if (string.IsNullOrEmpty(name))
  358. {
  359. NDebug.Assert("データ型に不正な値が入りました", false);
  360. Debug.LogError("データ型に不正な値が入りました");
  361. }
  362. return this.TryGetSystemData<T>(name, out value);
  363. }
  364. public Maid GetMan()
  365. {
  366. return GameMain.Instance.CharacterMgr.GetMan(0);
  367. }
  368. public int GetNowManType()
  369. {
  370. return this.GetSystemData<int>(SystemDataType.男種類);
  371. }
  372. public void SetNowManType(int manTypeID)
  373. {
  374. if (GameMain.Instance.CharacterMgr.status.lockNTRPlay)
  375. {
  376. manTypeID = 10;
  377. }
  378. ManData.Data data = ManData.GetData(manTypeID);
  379. if (ManData.IsEnabled(manTypeID))
  380. {
  381. this.SetSystemData<int>(SystemDataType.男種類, manTypeID, false);
  382. }
  383. else
  384. {
  385. NDebug.Assert("男の種類に正しくない値が入りました", false);
  386. }
  387. }
  388. public void SetNowManType(ManDataType manType)
  389. {
  390. this.SetNowManType((int)manType);
  391. }
  392. public void SetManModel(Maid target, ManDataType type)
  393. {
  394. if (type == ManDataType.主人公)
  395. {
  396. this.UpdateManModelToPlayerData(target);
  397. }
  398. else
  399. {
  400. ManData.Data data = ManData.GetData((int)type);
  401. CharacterMgr.NpcData npcData = CharacterMgr.npcDatas[data.modelResourceName];
  402. npcData.Apply(target, false);
  403. GameMain.Instance.CharacterMgr.status.playerName = npcData.firstName;
  404. }
  405. }
  406. public void UpdateManModel(Maid target, Action callback)
  407. {
  408. target.Visible = true;
  409. target.AllProcProp();
  410. target.body0.SetChinkoVisible(false);
  411. target.CrossFade("man_porse01.anm", false, true, false, 0f, 1f);
  412. base.StartCoroutine(this.CoroutineWaitPropSeq(target, callback));
  413. }
  414. private void UpdateManModelToPlayerData(Maid target)
  415. {
  416. if (this.m_CachedOriginPlayerDataDic == null)
  417. {
  418. Debug.LogWarning("プレイヤーの情報は未だキャッシュされていない");
  419. return;
  420. }
  421. Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
  422. PlayerStatus.Status status = GameMain.Instance.CharacterMgr.status;
  423. target.status.lastName = this.m_CachedOriginPlayerName;
  424. status.playerName = this.m_CachedOriginPlayerName;
  425. for (int i = 0; i < 114; i++)
  426. {
  427. MPN mpn = (MPN)i;
  428. if (mpn != MPN.null_mpn)
  429. {
  430. target.SetProp(mpn, this.m_CachedOriginPlayerDataDic[mpn].strFileName, this.m_CachedOriginPlayerDataDic[mpn].nFileNameRID, false, false);
  431. target.SetProp(mpn, this.m_CachedOriginPlayerDataDic[mpn].value, false);
  432. }
  433. }
  434. target.ManColor = this.m_CachedOriginPlayerColor;
  435. target.ManColorUpdate();
  436. }
  437. public void CacheOriginPlayerData()
  438. {
  439. this.m_CachedOriginPlayerDataDic = new Dictionary<MPN, MaidProp>();
  440. Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
  441. for (int i = 0; i < 114; i++)
  442. {
  443. MPN mpn = (MPN)i;
  444. MaidProp maidProp = new MaidProp();
  445. MaidProp prop = man.GetProp(mpn);
  446. maidProp.strFileName = prop.strFileName;
  447. maidProp.nFileNameRID = prop.nFileNameRID;
  448. maidProp.value = prop.value;
  449. this.m_CachedOriginPlayerDataDic.Add(mpn, maidProp);
  450. }
  451. this.m_CachedOriginPlayerName = GameMain.Instance.CharacterMgr.status.playerName;
  452. this.m_CachedOriginPlayerColor = man.ManColor;
  453. }
  454. public void ClearCacheOriginPlayerData()
  455. {
  456. if (this.m_CachedOriginPlayerDataDic != null)
  457. {
  458. this.m_CachedOriginPlayerDataDic.Clear();
  459. this.m_CachedOriginPlayerDataDic = null;
  460. }
  461. this.m_CachedOriginPlayerName = string.Empty;
  462. }
  463. private IEnumerator CoroutineWaitPropSeq(Maid target, Action callback)
  464. {
  465. while (target.IsBusy)
  466. {
  467. yield return null;
  468. }
  469. if (callback != null)
  470. {
  471. callback();
  472. }
  473. yield break;
  474. }
  475. private DataArray<string, string> GetMaidDataArray(Maid maid)
  476. {
  477. if (maid == null)
  478. {
  479. NDebug.Assert("メイドにnullが指定されました", false);
  480. return null;
  481. }
  482. string guid = maid.status.guid;
  483. DataArray<string, string> result = null;
  484. if (this.m_MaidDataArray.ContainsKey(guid))
  485. {
  486. result = this.m_MaidDataArray[guid];
  487. }
  488. return result;
  489. }
  490. private DataArray<string, string> CreateMaidDataArray(Maid maid)
  491. {
  492. if (maid == null)
  493. {
  494. NDebug.Assert("メイドにnullが指定されました", false);
  495. return null;
  496. }
  497. string guid = maid.status.guid;
  498. if (this.m_MaidDataArray.ContainsKey(guid))
  499. {
  500. Debug.LogFormat("メイド「{0}」のデータ配列は既に作成されています。", new object[]
  501. {
  502. maid.status.fullNameJpStyle
  503. });
  504. return this.m_MaidDataArray[guid];
  505. }
  506. DataArray<string, string> dataArray = new DataArray<string, string>();
  507. this.m_MaidDataArray.Add(guid, dataArray);
  508. return dataArray;
  509. }
  510. public void SetMaidData<T>(Maid maid, string valueName, T value, bool enableWarning = false)
  511. {
  512. DataArray<string, string> dataArray = this.GetMaidDataArray(maid);
  513. if (dataArray == null)
  514. {
  515. dataArray = this.CreateMaidDataArray(maid);
  516. }
  517. if (valueName == Enum.GetName(typeof(MaidDataType), MaidDataType.好感度\uFF3F本編))
  518. {
  519. if (enableWarning)
  520. {
  521. NDebug.Warning(string.Format("本編用メイドデータ「{0}」を書き換えようとしました", valueName));
  522. Debug.LogWarning(string.Format("本編用メイドデータ「{0}」を書き換えようとしました", valueName));
  523. }
  524. return;
  525. }
  526. this.UpdateData<T>(dataArray, valueName, value, enableWarning);
  527. }
  528. public void SetMaidData<T>(Maid maid, MaidDataType dataType, T value, bool enableWarning = false)
  529. {
  530. string name = Enum.GetName(typeof(MaidDataType), dataType);
  531. if (string.IsNullOrEmpty(name))
  532. {
  533. NDebug.Assert("データ型に不正な値が入りました", false);
  534. Debug.LogError("データ型に不正な値が入りました");
  535. }
  536. this.SetMaidData<T>(maid, name, value, enableWarning);
  537. }
  538. public T GetMaidData<T>(Maid maid, string valueName, bool enableWarning = true)
  539. {
  540. if (valueName == Enum.GetName(typeof(MaidDataType), MaidDataType.好感度\uFF3F本編))
  541. {
  542. try
  543. {
  544. T result = default(T);
  545. string text = maid.status.likability.ToString();
  546. TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
  547. if (converter != null)
  548. {
  549. result = (T)((object)converter.ConvertFromString(text));
  550. }
  551. return result;
  552. }
  553. catch (Exception ex)
  554. {
  555. NDebug.Assert(ex.ToString(), false);
  556. Debug.LogError(ex);
  557. }
  558. }
  559. DataArray<string, string> maidDataArray = this.GetMaidDataArray(maid);
  560. if (maidDataArray == null)
  561. {
  562. Debug.LogFormat("メイド「{0}」の傅きモード用データ配列は未作成でした", new object[]
  563. {
  564. maid.status.fullNameJpStyle
  565. });
  566. return default(T);
  567. }
  568. return this.GetData<T>(maidDataArray, valueName, enableWarning);
  569. }
  570. public T GetMaidData<T>(Maid maid, MaidDataType dataType, bool enableWarning = true)
  571. {
  572. string name = Enum.GetName(typeof(MaidDataType), dataType);
  573. if (string.IsNullOrEmpty(name))
  574. {
  575. NDebug.Assert("データ型に不正な値が入りました", false);
  576. Debug.LogError("データ型に不正な値が入りました");
  577. }
  578. return this.GetMaidData<T>(maid, name, enableWarning);
  579. }
  580. public int GetMaidLikability(Maid maid, ManDataType dataType)
  581. {
  582. if (dataType == ManDataType.主人公)
  583. {
  584. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F本編, false);
  585. }
  586. if (dataType == ManDataType.傅き男1)
  587. {
  588. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男1, false);
  589. }
  590. if (dataType == ManDataType.傅き男2)
  591. {
  592. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男2, false);
  593. }
  594. if (dataType == ManDataType.傅き男3)
  595. {
  596. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男3, false);
  597. }
  598. if (dataType == ManDataType.傅き男4)
  599. {
  600. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男4, false);
  601. }
  602. if (dataType == ManDataType.傅き男5)
  603. {
  604. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男5, false);
  605. }
  606. if (dataType == ManDataType.傅き男6)
  607. {
  608. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男6, false);
  609. }
  610. if (dataType == ManDataType.傅き男7)
  611. {
  612. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男7, false);
  613. }
  614. if (dataType == ManDataType.傅き男8)
  615. {
  616. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男8, false);
  617. }
  618. if (dataType == ManDataType.傅き男9)
  619. {
  620. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男9, false);
  621. }
  622. if (dataType == ManDataType.傅き男10)
  623. {
  624. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男10, false);
  625. }
  626. if (dataType == ManDataType.傅き男11)
  627. {
  628. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男11, false);
  629. }
  630. if (dataType == ManDataType.傅き男12)
  631. {
  632. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男12, false);
  633. }
  634. if (dataType == ManDataType.傅き男13)
  635. {
  636. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男13, false);
  637. }
  638. if (dataType == ManDataType.傅き男14)
  639. {
  640. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男14, false);
  641. }
  642. if (dataType == ManDataType.傅き男15)
  643. {
  644. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男15, false);
  645. }
  646. if (dataType == ManDataType.傅き男16)
  647. {
  648. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男16, false);
  649. }
  650. if (dataType == ManDataType.傅き男17)
  651. {
  652. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男17, false);
  653. }
  654. if (dataType == ManDataType.傅き男18)
  655. {
  656. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男18, false);
  657. }
  658. if (dataType != ManDataType.傅き男19)
  659. {
  660. NDebug.Assert("[KasizukiManager.GetMaidLikability] 男種類に不正な値が入りました", false);
  661. Debug.LogErrorFormat("[KasizukiManager.GetMaidLikability] 男種類に不正な値が入りました\n男種類.{0}", new object[]
  662. {
  663. dataType.ToString()
  664. });
  665. return -1;
  666. }
  667. return this.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男19, false);
  668. }
  669. public bool TryGetMaidData<T>(Maid maid, string valueName, out T value)
  670. {
  671. value = default(T);
  672. DataArray<string, string> maidDataArray = this.GetMaidDataArray(maid);
  673. return maidDataArray != null && this.TryGetData<T>(maidDataArray, valueName, out value);
  674. }
  675. public bool TryGetMaidData<T>(Maid maid, MaidDataType dataType, out T value)
  676. {
  677. string name = Enum.GetName(typeof(MaidDataType), dataType);
  678. if (string.IsNullOrEmpty(name))
  679. {
  680. NDebug.Assert("データ型に不正な値が入りました", false);
  681. Debug.LogError("データ型に不正な値が入りました");
  682. }
  683. return this.TryGetMaidData<T>(maid, name, out value);
  684. }
  685. public bool RemoveMaidData(Maid maid, string valueName, bool enableWarning = false)
  686. {
  687. DataArray<string, string> maidDataArray = this.GetMaidDataArray(maid);
  688. if (maidDataArray == null)
  689. {
  690. Debug.LogFormat("メイド「{0}」に関する傅きモードのデータ配列は未作成でした\nデータ名:{1}", new object[]
  691. {
  692. maid.status.fullNameJpStyle,
  693. valueName
  694. });
  695. return false;
  696. }
  697. return this.RemoveData(maidDataArray, valueName, enableWarning);
  698. }
  699. public bool RemoveMaidData(Maid maid, MaidDataType dataType, bool enableWarning = false)
  700. {
  701. string name = Enum.GetName(typeof(MaidDataType), dataType);
  702. if (string.IsNullOrEmpty(name))
  703. {
  704. NDebug.Assert("データ型に不正な値が入りました", false);
  705. Debug.LogError("データ型に不正な値が入りました");
  706. }
  707. return this.RemoveMaidData(maid, name, enableWarning);
  708. }
  709. public static List<Maid> GetEnableMaidList()
  710. {
  711. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  712. List<Maid> list = new List<Maid>();
  713. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  714. {
  715. Maid stockMaid = characterMgr.GetStockMaid(i);
  716. if (stockMaid.status.heroineType != HeroineType.Transfer)
  717. {
  718. if (stockMaid.status.heroineType != HeroineType.Sub)
  719. {
  720. list.Add(stockMaid);
  721. }
  722. }
  723. }
  724. return list;
  725. }
  726. public void UpdateLatestSaveDataNumber()
  727. {
  728. int count = this.m_SaveDataArray.Count;
  729. List<KasizukiManager.SaveData> list = new List<KasizukiManager.SaveData>(this.m_SaveDataArray.Values);
  730. int latestSaveDataNumber = -1;
  731. long num = -1L;
  732. for (int i = 0; i < count; i++)
  733. {
  734. KasizukiManager.SaveData saveData = list[i];
  735. if (saveData != null && saveData.header != null)
  736. {
  737. long num2 = 0L;
  738. if (long.TryParse(saveData.header.strRealTime, out num2))
  739. {
  740. if (num < num2)
  741. {
  742. num = num2;
  743. latestSaveDataNumber = saveData.header.saveDataNumber;
  744. }
  745. }
  746. }
  747. }
  748. this.m_LatestSaveDataNumber = latestSaveDataNumber;
  749. }
  750. public void SerializeLocal(int saveDataIndex)
  751. {
  752. this.m_NowKasizukiSaveDataIndex = saveDataIndex;
  753. KasizukiManager.SaveData saveData;
  754. if (this.m_SaveDataArray.ContainsKey(saveDataIndex))
  755. {
  756. saveData = this.m_SaveDataArray[saveDataIndex];
  757. }
  758. else
  759. {
  760. saveData = new KasizukiManager.SaveData();
  761. this.m_SaveDataArray.Add(saveDataIndex, saveData);
  762. }
  763. saveData.header.saveDataNumber = saveDataIndex;
  764. saveData.header.saveDataVersion = 5;
  765. saveData.header.UpdateNowTime();
  766. saveData.header.lastManType = this.GetNowManType();
  767. saveData.header.playCount = this.GetSystemData<int>(SystemDataType.プレイ回数);
  768. this.SerializeSaveData(saveData);
  769. this.UpdateLatestSaveDataNumber();
  770. }
  771. public void DeserializeLocal(int saveDataIndex)
  772. {
  773. this.m_NowKasizukiSaveDataIndex = saveDataIndex;
  774. if (!this.m_SaveDataArray.ContainsKey(saveDataIndex))
  775. {
  776. Debug.LogWarning(string.Format("傅きモードのセーブデータ[{0}]番は存在しません", saveDataIndex));
  777. return;
  778. }
  779. KasizukiManager.SaveData saveData = this.m_SaveDataArray[saveDataIndex];
  780. this.ResetData();
  781. this.DeserializeSaveData(saveData);
  782. }
  783. public void DeleteSaveDataLocal(int saveDataIndex)
  784. {
  785. if (!this.m_SaveDataArray.ContainsKey(saveDataIndex))
  786. {
  787. return;
  788. }
  789. this.m_SaveDataArray.Remove(saveDataIndex);
  790. this.UpdateLatestSaveDataNumber();
  791. }
  792. public KasizukiManager.SaveDataHeader GetSaveDataHeader(int saveDataIndex)
  793. {
  794. KasizukiManager.SaveDataHeader result;
  795. this.TryGetSaveDataHeader(saveDataIndex, out result);
  796. return result;
  797. }
  798. public bool TryGetSaveDataHeader(int saveDataIndex, out KasizukiManager.SaveDataHeader header)
  799. {
  800. header = null;
  801. if (this.m_SaveDataArray.ContainsKey(saveDataIndex))
  802. {
  803. header = this.m_SaveDataArray[saveDataIndex].header;
  804. return true;
  805. }
  806. return false;
  807. }
  808. public bool IsExistSaveData(int saveDataIndex)
  809. {
  810. return this.m_SaveDataArray.ContainsKey(saveDataIndex);
  811. }
  812. public void Serialize(BinaryWriter bw)
  813. {
  814. bw.Write("COM3D2_KASIZUKI");
  815. bw.Write(1440);
  816. this.SerializeOriginHeader(bw);
  817. foreach (KeyValuePair<int, KasizukiManager.SaveData> keyValuePair in this.m_SaveDataArray)
  818. {
  819. int key = keyValuePair.Key;
  820. KasizukiManager.SaveData value = keyValuePair.Value;
  821. value.Serialize(bw.BaseStream);
  822. }
  823. this.UpdateLatestSaveDataNumber();
  824. KasizukiManager.FixMaidThumbnails();
  825. }
  826. public void Deserialize(int originSaveDataNumber, BinaryReader br)
  827. {
  828. this.NowOriginSaveDataNumber = originSaveDataNumber;
  829. KasizukiManager.DeleteTmpMaidThumnails();
  830. long position = br.BaseStream.Position;
  831. if (br.BaseStream.Length <= position + 1L)
  832. {
  833. Debug.LogWarning(string.Format("これ以上バッファが無いので、処理を終了します\n現在位置:{0}\n長さ:{1}", position, br.BaseStream.Length));
  834. return;
  835. }
  836. string text = br.ReadString();
  837. if (text != "COM3D2_KASIZUKI")
  838. {
  839. NDebug.Warning(string.Format("傅きモードのヘッダー取得に失敗しました\n取得した文字:{0}\n読み込み位置を戻します", text));
  840. Debug.LogWarning(string.Format("傅きモードのヘッダー取得に失敗しました\n取得した文字:{0}\n読み込み位置を戻します", text));
  841. br.BaseStream.Seek(position, SeekOrigin.Begin);
  842. return;
  843. }
  844. int num = br.ReadInt32();
  845. int num2;
  846. this.DeserializeOriginHeader(br, out num2);
  847. this.m_SaveDataArray.Clear();
  848. for (int i = 0; i < num2; i++)
  849. {
  850. KasizukiManager.SaveData saveData = new KasizukiManager.SaveData();
  851. if (!saveData.Deserialize(br.BaseStream))
  852. {
  853. break;
  854. }
  855. if (!this.m_SaveDataArray.ContainsKey(saveData.header.saveDataNumber))
  856. {
  857. this.m_SaveDataArray.Add(saveData.header.saveDataNumber, saveData);
  858. }
  859. else
  860. {
  861. this.m_SaveDataArray[saveData.header.saveDataNumber] = saveData;
  862. }
  863. }
  864. this.UpdateLatestSaveDataNumber();
  865. Debug.Log("プレイヤーの元情報をキャッシュします");
  866. this.CacheOriginPlayerData();
  867. }
  868. private void SerializeOriginHeader(BinaryWriter bw)
  869. {
  870. int count = this.m_SaveDataArray.Count;
  871. byte[] buffer = Util.CreatePrefix(count);
  872. bw.Write(buffer);
  873. }
  874. private void DeserializeOriginHeader(BinaryReader br, out int saveDataCount)
  875. {
  876. int prefix = Util.GetPrefix(br.BaseStream, br.BaseStream.Position, true);
  877. saveDataCount = prefix;
  878. }
  879. private void SerializeSaveData(KasizukiManager.SaveData saveData)
  880. {
  881. using (MemoryStream memoryStream = new MemoryStream())
  882. {
  883. using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
  884. {
  885. DataArray<string, string> systemData = this.m_SystemData;
  886. BinaryWriter brWrite = binaryWriter;
  887. if (KasizukiManager.<>f__mg$cache0 == null)
  888. {
  889. KasizukiManager.<>f__mg$cache0 = new Converter<string, byte[]>(Util.GetBytes);
  890. }
  891. Converter<string, byte[]> converter_key = KasizukiManager.<>f__mg$cache0;
  892. if (KasizukiManager.<>f__mg$cache1 == null)
  893. {
  894. KasizukiManager.<>f__mg$cache1 = new Converter<string, byte[]>(Util.GetBytes);
  895. }
  896. systemData.Serialize(brWrite, converter_key, KasizukiManager.<>f__mg$cache1);
  897. int count = this.m_MaidDataArray.Count;
  898. binaryWriter.Write(count);
  899. foreach (KeyValuePair<string, DataArray<string, string>> keyValuePair in this.m_MaidDataArray)
  900. {
  901. binaryWriter.Write(keyValuePair.Key);
  902. DataArray<string, string> value = keyValuePair.Value;
  903. BinaryWriter brWrite2 = binaryWriter;
  904. if (KasizukiManager.<>f__mg$cache2 == null)
  905. {
  906. KasizukiManager.<>f__mg$cache2 = new Converter<string, byte[]>(Util.GetBytes);
  907. }
  908. Converter<string, byte[]> converter_key2 = KasizukiManager.<>f__mg$cache2;
  909. if (KasizukiManager.<>f__mg$cache3 == null)
  910. {
  911. KasizukiManager.<>f__mg$cache3 = new Converter<string, byte[]>(Util.GetBytes);
  912. }
  913. value.Serialize(brWrite2, converter_key2, KasizukiManager.<>f__mg$cache3);
  914. }
  915. }
  916. saveData.buffer = memoryStream.ToArray();
  917. }
  918. }
  919. private void DeserializeSaveData(KasizukiManager.SaveData saveData)
  920. {
  921. using (MemoryStream memoryStream = new MemoryStream(saveData.buffer))
  922. {
  923. using (BinaryReader binaryReader = new BinaryReader(memoryStream))
  924. {
  925. DataArray<string, string> systemData = this.m_SystemData;
  926. BinaryReader brRead = binaryReader;
  927. if (KasizukiManager.<>f__mg$cache4 == null)
  928. {
  929. KasizukiManager.<>f__mg$cache4 = new Func<BinaryReader, string>(Util.ToString);
  930. }
  931. Func<BinaryReader, string> func_read_key = KasizukiManager.<>f__mg$cache4;
  932. if (KasizukiManager.<>f__mg$cache5 == null)
  933. {
  934. KasizukiManager.<>f__mg$cache5 = new Func<BinaryReader, string>(Util.ToString);
  935. }
  936. systemData.Deserialize(brRead, func_read_key, KasizukiManager.<>f__mg$cache5);
  937. this.SetNowManType(saveData.header.lastManType);
  938. int num = binaryReader.ReadInt32();
  939. for (int i = 0; i < num; i++)
  940. {
  941. string text = binaryReader.ReadString();
  942. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(text);
  943. if (stockMaid == null)
  944. {
  945. Debug.LogFormat("GUID「{0}」のメイドは存在しなかったので、このメイドの情報は読み飛ばします", new object[]
  946. {
  947. text
  948. });
  949. DataArray<string, string> dataArray = new DataArray<string, string>();
  950. DataArray<string, string> dataArray2 = dataArray;
  951. BinaryReader brRead2 = binaryReader;
  952. if (KasizukiManager.<>f__mg$cache6 == null)
  953. {
  954. KasizukiManager.<>f__mg$cache6 = new Func<BinaryReader, string>(Util.ToString);
  955. }
  956. Func<BinaryReader, string> func_read_key2 = KasizukiManager.<>f__mg$cache6;
  957. if (KasizukiManager.<>f__mg$cache7 == null)
  958. {
  959. KasizukiManager.<>f__mg$cache7 = new Func<BinaryReader, string>(Util.ToString);
  960. }
  961. dataArray2.Deserialize(brRead2, func_read_key2, KasizukiManager.<>f__mg$cache7);
  962. }
  963. else
  964. {
  965. DataArray<string, string> dataArray3 = this.CreateMaidDataArray(stockMaid);
  966. DataArray<string, string> dataArray4 = dataArray3;
  967. BinaryReader brRead3 = binaryReader;
  968. if (KasizukiManager.<>f__mg$cache8 == null)
  969. {
  970. KasizukiManager.<>f__mg$cache8 = new Func<BinaryReader, string>(Util.ToString);
  971. }
  972. Func<BinaryReader, string> func_read_key3 = KasizukiManager.<>f__mg$cache8;
  973. if (KasizukiManager.<>f__mg$cache9 == null)
  974. {
  975. KasizukiManager.<>f__mg$cache9 = new Func<BinaryReader, string>(Util.ToString);
  976. }
  977. dataArray4.Deserialize(brRead3, func_read_key3, KasizukiManager.<>f__mg$cache9);
  978. }
  979. }
  980. }
  981. }
  982. }
  983. public static Texture2D GetMaidThumbnail(Maid maid)
  984. {
  985. Texture2D result = null;
  986. string text = UTY.gameProjectPath + "\\Thumb\\";
  987. if (!Directory.Exists(text))
  988. {
  989. Directory.CreateDirectory(text);
  990. }
  991. string guid = maid.status.guid;
  992. string text2 = text + "_tmp_kasizuki_" + guid + ".png";
  993. if (File.Exists(text2))
  994. {
  995. result = UTY.LoadTexture(text2);
  996. }
  997. else
  998. {
  999. text2 = text + "kasizuki_" + guid + ".png";
  1000. if (File.Exists(text2))
  1001. {
  1002. result = UTY.LoadTexture(text2);
  1003. }
  1004. }
  1005. return result;
  1006. }
  1007. public static bool IsExistMaidThumbnail(Maid maid)
  1008. {
  1009. string text = UTY.gameProjectPath + "\\Thumb\\";
  1010. if (!Directory.Exists(text))
  1011. {
  1012. return false;
  1013. }
  1014. string guid = maid.status.guid;
  1015. string path = text + "_tmp_kasizuki_" + guid + ".png";
  1016. if (File.Exists(path))
  1017. {
  1018. return true;
  1019. }
  1020. path = text + "kasizuki_" + guid + ".png";
  1021. return File.Exists(path);
  1022. }
  1023. private static void FixMaidThumbnails()
  1024. {
  1025. string text = UTY.gameProjectPath + "\\Thumb\\";
  1026. if (!Directory.Exists(text))
  1027. {
  1028. return;
  1029. }
  1030. string[] files = Directory.GetFiles(text, "*", SearchOption.TopDirectoryOnly);
  1031. for (int i = 0; i < files.Length; i++)
  1032. {
  1033. string text2 = string.Empty;
  1034. try
  1035. {
  1036. text2 = files[i].Substring(text.Length, files[i].Length - text.Length);
  1037. }
  1038. catch
  1039. {
  1040. }
  1041. if (string.IsNullOrEmpty(text2))
  1042. {
  1043. files[i] = string.Empty;
  1044. }
  1045. else if (0 > text2.IndexOf(".png") || 0 > text2.IndexOf("_tmp_kasizuki_"))
  1046. {
  1047. files[i] = string.Empty;
  1048. }
  1049. }
  1050. for (int j = 0; j < files.Length; j++)
  1051. {
  1052. if (!string.IsNullOrEmpty(files[j]))
  1053. {
  1054. try
  1055. {
  1056. int length = "_tmp_kasizuki_".Length;
  1057. string text3 = files[j].Substring(text.Length, files[j].Length - text.Length);
  1058. string str = "kasizuki_" + text3.Substring(length, text3.Length - length - ".png".Length) + ".png";
  1059. if (File.Exists(text + str))
  1060. {
  1061. File.Delete(text + str);
  1062. }
  1063. File.Move(files[j], text + str);
  1064. }
  1065. catch
  1066. {
  1067. }
  1068. }
  1069. }
  1070. }
  1071. private static void DeleteTmpMaidThumnails()
  1072. {
  1073. string text = UTY.gameProjectPath + "\\Thumb\\";
  1074. if (!Directory.Exists(text))
  1075. {
  1076. return;
  1077. }
  1078. string[] files = Directory.GetFiles(text, "*", SearchOption.TopDirectoryOnly);
  1079. for (int i = 0; i < files.Length; i++)
  1080. {
  1081. string text2 = string.Empty;
  1082. try
  1083. {
  1084. text2 = files[i].Substring(text.Length, files[i].Length - text.Length);
  1085. }
  1086. catch
  1087. {
  1088. }
  1089. if (string.IsNullOrEmpty(text2))
  1090. {
  1091. files[i] = string.Empty;
  1092. }
  1093. else if (0 > text2.IndexOf(".png") || 0 > text2.IndexOf("_tmp_kasizuki_"))
  1094. {
  1095. files[i] = string.Empty;
  1096. }
  1097. }
  1098. for (int j = 0; j < files.Length; j++)
  1099. {
  1100. if (!string.IsNullOrEmpty(files[j]))
  1101. {
  1102. try
  1103. {
  1104. File.Delete(files[j]);
  1105. }
  1106. catch
  1107. {
  1108. }
  1109. }
  1110. }
  1111. }
  1112. public void TJSFuncGetKasizukiSystemFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1113. {
  1114. NDebug.Assert(result != null, "error GetKasizukiSystemFlag");
  1115. NDebug.Assert(1 == tjs_param.Length, "GetKasizukiSystemFlag args count error.");
  1116. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1117. result.SetString(kasizukiMgr.GetSystemData<string>(tjs_param[0].AsString()));
  1118. }
  1119. public void TJSFuncSetKasizukiSystemFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1120. {
  1121. NDebug.Assert(2 == tjs_param.Length, "SetKasizukiSystemFlag args count error.");
  1122. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1123. kasizukiMgr.SetSystemData<string>(tjs_param[0].AsString(), tjs_param[1].AsString(), false);
  1124. }
  1125. public void TJSFuncAddKasizukiSystemFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1126. {
  1127. NDebug.Assert(2 == tjs_param.Length, "AddKasizukiSystemFlag args count error.");
  1128. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1129. string valueName = tjs_param[0].AsString();
  1130. int num = kasizukiMgr.GetSystemData<int>(valueName);
  1131. num += tjs_param[1].AsInteger();
  1132. kasizukiMgr.SetSystemData<int>(valueName, num, false);
  1133. }
  1134. public void TJSFuncSetKasizukiPassFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1135. {
  1136. NDebug.Assert(1 == tjs_param.Length, "SetKasizukiPassFlag args count error.");
  1137. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1138. int id = tjs_param[0].AsInteger();
  1139. PlayData.Data data = PlayData.GetData(id);
  1140. data.IsPassed = true;
  1141. }
  1142. public void TJSFuncSetKasizukiMaidFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1143. {
  1144. NDebug.Assert(3 == tjs_param.Length, "SetKasizukiMaidFlag args count error.");
  1145. int num = tjs_param[0].AsInteger();
  1146. string valueName = tjs_param[1].AsString();
  1147. int value = tjs_param[2].AsInteger();
  1148. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num);
  1149. NDebug.Assert(maid != null, "[SetKasizukiMaidFlag]\nメイド" + num + "番が見つかりません");
  1150. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1151. kasizukiMgr.SetMaidData<int>(maid, valueName, value, false);
  1152. }
  1153. public void TJSFuncGetKasizukiMaidFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1154. {
  1155. NDebug.Assert(result != null, "error GetKasizukiMaidFlag");
  1156. NDebug.Assert(2 == tjs_param.Length, "GetKasizukiMaidFlag args count error.");
  1157. int num = tjs_param[0].AsInteger();
  1158. string valueName = tjs_param[1].AsString();
  1159. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num);
  1160. NDebug.Assert(maid != null, "[GetKasizukiMaidFlag]\nメイド" + num + "番が見つかりません");
  1161. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  1162. int maidData = kasizukiMgr.GetMaidData<int>(maid, valueName, false);
  1163. result.SetInteger(maidData);
  1164. }
  1165. public void TJSFuncIsKasizukiCorrectSenarioFlag(TJSVariantRef[] tjs_param, TJSVariantRef result)
  1166. {
  1167. NDebug.Assert(result != null, "error GetKasizukiMaidFlag");
  1168. NDebug.Assert(2 == tjs_param.Length, "GetKasizukiMaidFlag args count error.");
  1169. int num = tjs_param[0].AsInteger();
  1170. int id = tjs_param[1].AsInteger();
  1171. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(num);
  1172. NDebug.Assert(maid != null, "[GetKasizukiMaidFlag]\nメイド" + num + "番が見つかりません");
  1173. ManDataType nowManType = (ManDataType)this.GetNowManType();
  1174. bool @bool = PlayData.GetData(id).IsCorrectMaid(maid, nowManType);
  1175. result.SetBool(@bool);
  1176. }
  1177. public static string CreateMaidTmpThumbName(Maid maid)
  1178. {
  1179. NDebug.AssertNull(maid != null);
  1180. return "_tmp_kasizuki_" + maid.status.guid + ".png";
  1181. }
  1182. public const int MAN_ACTIVATE_SLOT = 0;
  1183. private const string STR_SERIALIZE_HEADER = "COM3D2_KASIZUKI";
  1184. private const int SERIALIZE_VERSION = 5;
  1185. private int m_NowOriginSaveDataNumber;
  1186. private int m_NowKasizukiSaveDataIndex = 1;
  1187. private DataArray<int, bool> m_NowHaveItemDic;
  1188. private DataArray<string, string> m_SystemData;
  1189. private Dictionary<string, DataArray<string, string>> m_MaidDataArray;
  1190. private Dictionary<int, KasizukiManager.SaveData> m_SaveDataArray;
  1191. private int m_LatestSaveDataNumber = -1;
  1192. private Dictionary<MPN, MaidProp> m_CachedOriginPlayerDataDic;
  1193. private string m_CachedOriginPlayerName;
  1194. private Color m_CachedOriginPlayerColor;
  1195. public const string STR_TMP_THUMB_NAME = "_tmp_kasizuki_";
  1196. public const string STR_THUMB_NAME = "kasizuki_";
  1197. [CompilerGenerated]
  1198. private static Converter<string, byte[]> <>f__mg$cache0;
  1199. [CompilerGenerated]
  1200. private static Converter<string, byte[]> <>f__mg$cache1;
  1201. [CompilerGenerated]
  1202. private static Converter<string, byte[]> <>f__mg$cache2;
  1203. [CompilerGenerated]
  1204. private static Converter<string, byte[]> <>f__mg$cache3;
  1205. [CompilerGenerated]
  1206. private static Func<BinaryReader, string> <>f__mg$cache4;
  1207. [CompilerGenerated]
  1208. private static Func<BinaryReader, string> <>f__mg$cache5;
  1209. [CompilerGenerated]
  1210. private static Func<BinaryReader, string> <>f__mg$cache6;
  1211. [CompilerGenerated]
  1212. private static Func<BinaryReader, string> <>f__mg$cache7;
  1213. [CompilerGenerated]
  1214. private static Func<BinaryReader, string> <>f__mg$cache8;
  1215. [CompilerGenerated]
  1216. private static Func<BinaryReader, string> <>f__mg$cache9;
  1217. public class SaveDataHeader
  1218. {
  1219. public SaveDataHeader()
  1220. {
  1221. this.strRealTime = DateTime.Now.ToString("yyyyMMddHHmmss");
  1222. this.saveDataNumber = -1;
  1223. this.saveDataVersion = -1;
  1224. this.lastManType = 10;
  1225. this.playCount = 0;
  1226. this.strComment = string.Empty;
  1227. }
  1228. public void Serialize(BinaryWriter bw)
  1229. {
  1230. bw.Write(this.saveDataNumber);
  1231. bw.Write(this.saveDataVersion);
  1232. bw.Write(this.strRealTime);
  1233. bw.Write(this.lastManType);
  1234. bw.Write(this.playCount);
  1235. bw.Write(this.strComment);
  1236. }
  1237. public void Deserialize(BinaryReader br)
  1238. {
  1239. this.saveDataNumber = br.ReadInt32();
  1240. this.saveDataVersion = br.ReadInt32();
  1241. this.strRealTime = br.ReadString();
  1242. this.lastManType = br.ReadInt32();
  1243. if (this.saveDataVersion >= 5)
  1244. {
  1245. this.playCount = br.ReadInt32();
  1246. }
  1247. this.strComment = br.ReadString();
  1248. }
  1249. public void UpdateNowTime()
  1250. {
  1251. this.strRealTime = DateTime.Now.ToString("yyyyMMddHHmmss");
  1252. }
  1253. public DateTime GetDateTime()
  1254. {
  1255. return DateTime.ParseExact(this.strRealTime, "yyyyMMddHHmmss", null);
  1256. }
  1257. public string strRealTime;
  1258. public int saveDataNumber;
  1259. public int saveDataVersion;
  1260. public int lastManType;
  1261. public int playCount;
  1262. public string strComment;
  1263. }
  1264. public class SaveData
  1265. {
  1266. public SaveData()
  1267. {
  1268. this.header = new KasizukiManager.SaveDataHeader();
  1269. }
  1270. public void Serialize(Stream stream)
  1271. {
  1272. BinaryWriter binaryWriter = new BinaryWriter(stream);
  1273. this.header.Serialize(binaryWriter);
  1274. byte[] array = Util.CreatePrefix(this.buffer.Length);
  1275. binaryWriter.Write(array);
  1276. binaryWriter.Write(this.buffer);
  1277. binaryWriter.Flush();
  1278. }
  1279. public bool Deserialize(Stream stream)
  1280. {
  1281. if (stream.Position + 1L >= stream.Length)
  1282. {
  1283. return false;
  1284. }
  1285. BinaryReader binaryReader = new BinaryReader(stream);
  1286. this.header.Deserialize(binaryReader);
  1287. int prefix = Util.GetPrefix(binaryReader.BaseStream, binaryReader.BaseStream.Position, true);
  1288. this.buffer = new byte[prefix];
  1289. binaryReader.Read(this.buffer, 0, this.buffer.Length);
  1290. return true;
  1291. }
  1292. public KasizukiManager.SaveDataHeader header;
  1293. public byte[] buffer;
  1294. }
  1295. }
  1296. }