KasizukiManager.cs 43 KB

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