PlayData.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using wf;
  6. namespace Kasizuki
  7. {
  8. public static class PlayData
  9. {
  10. private static int GetMaidStatus(this Maid maid, string name)
  11. {
  12. switch (name)
  13. {
  14. case "接待":
  15. return maid.status.reception;
  16. case "お世話":
  17. return maid.status.care;
  18. case "可憐":
  19. return maid.status.lovely;
  20. case "気品":
  21. return maid.status.elegance;
  22. case "魅惑":
  23. return maid.status.charm;
  24. case "料理":
  25. return maid.status.cooking;
  26. case "ボーカル":
  27. return maid.status.vocal;
  28. case "ダンス":
  29. return maid.status.dance;
  30. case "アピールポイント":
  31. return maid.status.appealPoint;
  32. case "淫欲":
  33. return maid.status.inyoku;
  34. case "M性":
  35. return maid.status.mvalue;
  36. case "変態":
  37. return maid.status.hentai;
  38. case "奉仕":
  39. return maid.status.housi;
  40. case "指導":
  41. return maid.status.teachRate;
  42. case "経験人数":
  43. return maid.status.sexPlayNumberOfPeople;
  44. case "人気ランク":
  45. return maid.status.popularRank;
  46. case "評価":
  47. return maid.status.evaluation;
  48. }
  49. NDebug.Assert(string.Format("メイドパラメータ名「{0}」は未定義です", name), false);
  50. return -1;
  51. }
  52. public static PlayData.Data GetOptimalConditionData(Maid maid, RoomData.Data roomData, ManDataType manType)
  53. {
  54. PlayData.Data result;
  55. try
  56. {
  57. NDebug.Assert(maid != null, "メイドにnullが指定されました");
  58. NDebug.Assert(roomData != null, "部屋情報にnullが指定されました");
  59. NDebug.Assert(Enum.IsDefined(typeof(ManDataType), manType), "男種類に不正な値が入りました");
  60. if (!roomData.enableManTypeDic[manType])
  61. {
  62. result = null;
  63. }
  64. else
  65. {
  66. List<PlayData.Data> playDatas = roomData.GetPlayDatas();
  67. List<PlayData.Data> list = new List<PlayData.Data>();
  68. foreach (PlayData.Data data in playDatas)
  69. {
  70. if (data.enableManTypeDic[manType])
  71. {
  72. if (data.IsCorrectMaid(maid, manType))
  73. {
  74. list.Add(data);
  75. }
  76. }
  77. }
  78. PlayData.Data data2 = null;
  79. for (int i = 0; i < list.Count; i++)
  80. {
  81. if (data2 == null)
  82. {
  83. data2 = list[i];
  84. }
  85. else if (data2.needLikability < list[i].needLikability)
  86. {
  87. data2 = list[i];
  88. }
  89. }
  90. NDebug.Warning(data2 != null, "条件を満たすプレイが一つもない");
  91. result = data2;
  92. }
  93. }
  94. catch (Exception ex)
  95. {
  96. NDebug.Assert(ex.ToString(), false);
  97. Debug.LogError(ex);
  98. result = null;
  99. }
  100. return result;
  101. }
  102. public static int Count
  103. {
  104. get
  105. {
  106. PlayData.CreateData();
  107. return PlayData.commonIdManager.idMap.Count;
  108. }
  109. }
  110. public static bool Contains(string name)
  111. {
  112. return PlayData.commonIdManager.nameMap.ContainsKey(name);
  113. }
  114. public static bool Contains(int id)
  115. {
  116. return PlayData.commonIdManager.idMap.ContainsKey(id);
  117. }
  118. public static int uniqueNameToId(string uniqueName)
  119. {
  120. PlayData.CreateData();
  121. NDebug.Assert(PlayData.commonIdManager.nameMap.ContainsKey(uniqueName), "傅き.プレイ情報\nユニーク名[" + uniqueName + "]をIDに変換できませんでした");
  122. return PlayData.commonIdManager.nameMap[uniqueName];
  123. }
  124. public static string IdToUniqueName(int id)
  125. {
  126. PlayData.CreateData();
  127. NDebug.Assert(PlayData.commonIdManager.idMap.ContainsKey(id), "傅き.プレイ情報\nID[" + id + "]をユニーク名に変換できませんでした");
  128. return PlayData.commonIdManager.idMap[id].Key;
  129. }
  130. public static PlayData.Data GetData(int id)
  131. {
  132. PlayData.CreateData();
  133. NDebug.Assert(PlayData.basicDatas.ContainsKey(id), "傅き.プレイ情報\nID[" + id + "]のデータは存在しません");
  134. return PlayData.basicDatas[id];
  135. }
  136. public static PlayData.Data GetData(string uniqueName)
  137. {
  138. return PlayData.GetData(PlayData.uniqueNameToId(uniqueName));
  139. }
  140. public static bool IsEnabled(string uniqueName)
  141. {
  142. PlayData.CreateData();
  143. return PlayData.commonIdManager.enabledIdList.Contains(PlayData.uniqueNameToId(uniqueName));
  144. }
  145. public static bool IsEnabled(int id)
  146. {
  147. PlayData.CreateData();
  148. return PlayData.commonIdManager.enabledIdList.Contains(id);
  149. }
  150. public static List<PlayData.Data> GetAllDatas(bool onlyEnabled)
  151. {
  152. PlayData.CreateData();
  153. List<PlayData.Data> list = new List<PlayData.Data>();
  154. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in PlayData.commonIdManager.idMap)
  155. {
  156. if (!onlyEnabled || PlayData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  157. {
  158. list.Add(PlayData.basicDatas[keyValuePair.Key]);
  159. }
  160. }
  161. return list;
  162. }
  163. public static List<PlayData.Data> GetDatas(Func<PlayData.Data, bool> customCheckFunction)
  164. {
  165. PlayData.CreateData();
  166. List<PlayData.Data> list = new List<PlayData.Data>();
  167. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in PlayData.commonIdManager.idMap)
  168. {
  169. PlayData.Data data = PlayData.basicDatas[keyValuePair.Key];
  170. if (customCheckFunction(data))
  171. {
  172. list.Add(data);
  173. }
  174. }
  175. return list;
  176. }
  177. public static void CreateData()
  178. {
  179. if (PlayData.commonIdManager != null)
  180. {
  181. return;
  182. }
  183. PlayData.commonIdManager = new CsvCommonIdManager("kasizuki_play", "傅き.プレイ情報", CsvCommonIdManager.Type.IdOnly, null);
  184. PlayData.basicDatas = new Dictionary<int, PlayData.Data>();
  185. string[] array = new string[]
  186. {
  187. "list"
  188. };
  189. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  190. for (int i = 0; i < array2.Length; i++)
  191. {
  192. string text = "kasizuki_play_" + array[i] + ".nei";
  193. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  194. CsvParser csvParser = new CsvParser();
  195. bool condition = csvParser.Open(afileBase);
  196. NDebug.Assert(condition, text + "\nopen failed.");
  197. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  198. }
  199. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in PlayData.commonIdManager.idMap)
  200. {
  201. int key = keyValuePair.Key;
  202. PlayData.Data value = new PlayData.Data(key, array2[0].Value);
  203. PlayData.basicDatas.Add(key, value);
  204. }
  205. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  206. {
  207. keyValuePair2.Value.Dispose();
  208. keyValuePair2.Key.Dispose();
  209. }
  210. }
  211. private const string csvTopCommonName = "kasizuki_play";
  212. private const string typeNameForErrorLog = "傅き.プレイ情報";
  213. private static CsvCommonIdManager commonIdManager;
  214. private static Dictionary<int, PlayData.Data> basicDatas;
  215. public class Data
  216. {
  217. public Data(int uniqueID, CsvParser csv)
  218. {
  219. for (int i = 1; i < csv.max_cell_y; i++)
  220. {
  221. if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
  222. {
  223. int cell_x = 1;
  224. this.ID = uniqueID;
  225. string cellAsString = csv.GetCellAsString(cell_x++, i);
  226. this.strScenarioFileName = csv.GetCellAsString(cell_x++, i);
  227. this.drawName = csv.GetCellAsString(cell_x++, i);
  228. this.strDescription = csv.GetCellAsString(cell_x++, i);
  229. List<string> list = new List<string>();
  230. for (int j = 0; j < 6; j++)
  231. {
  232. string cellAsString2 = csv.GetCellAsString(cell_x++, i);
  233. if (!string.IsNullOrEmpty(cellAsString2))
  234. {
  235. list.Add(cellAsString2);
  236. }
  237. }
  238. this.strConditionArray = list.ToArray();
  239. string cellAsString3 = csv.GetCellAsString(cell_x++, i);
  240. this.seikeikenEnableDic = new Dictionary<Seikeiken, bool>();
  241. Seikeiken[] array = new Seikeiken[]
  242. {
  243. Seikeiken.No_No,
  244. Seikeiken.Yes_No,
  245. Seikeiken.No_Yes,
  246. Seikeiken.Yes_Yes
  247. };
  248. for (int k = 0; k < array.Length; k++)
  249. {
  250. string cellAsString4 = csv.GetCellAsString(cell_x++, i);
  251. if (cellAsString4 == "〇" || cellAsString4 == "○")
  252. {
  253. this.seikeikenEnableDic.Add(array[k], true);
  254. }
  255. }
  256. string cellAsString5 = csv.GetCellAsString(cell_x++, i);
  257. this.needLikability = csv.GetCellAsInteger(cell_x++, i);
  258. this.workCountEnableDic = new Dictionary<string, bool>();
  259. SortedDictionary<int, string> dic = WorkCountReplace.GetDic();
  260. foreach (string key in dic.Values)
  261. {
  262. string cellAsString6 = csv.GetCellAsString(cell_x++, i);
  263. if (cellAsString6 == "〇" || cellAsString6 == "○")
  264. {
  265. this.workCountEnableDic.Add(key, true);
  266. }
  267. }
  268. this.relationEnableDic = new Dictionary<Relation, bool>();
  269. Relation[] array2 = new Relation[]
  270. {
  271. Relation.Contact,
  272. Relation.Trust,
  273. Relation.Lover
  274. };
  275. for (int l = 0; l < array2.Length; l++)
  276. {
  277. string cellAsString7 = csv.GetCellAsString(cell_x++, i);
  278. if (cellAsString7 == "〇" || cellAsString7 == "○")
  279. {
  280. this.relationEnableDic.Add(array2[l], true);
  281. }
  282. }
  283. this.SplitParameterBlock(cellAsString3, out this.strNeedParameterArray);
  284. this.strNeedSkillArray = (string.IsNullOrEmpty(cellAsString5) ? null : cellAsString5.Split(new char[]
  285. {
  286. ','
  287. }));
  288. this.roomID = RoomData.GetData(cellAsString).ID;
  289. string cellAsString8 = csv.GetCellAsString(cell_x++, i);
  290. string[] array3 = null;
  291. if (!string.IsNullOrEmpty(cellAsString8))
  292. {
  293. array3 = cellAsString8.Split(new char[]
  294. {
  295. ','
  296. });
  297. for (int m = 0; m < array3.Length; m++)
  298. {
  299. array3[m] = array3[m].Trim();
  300. }
  301. }
  302. this.strEnablePersonalArray = array3;
  303. Dictionary<ManDataType, bool> dictionary = new Dictionary<ManDataType, bool>();
  304. int count = ManData.Count;
  305. for (int n = 0; n < count; n++)
  306. {
  307. string cellAsString9 = csv.GetCellAsString(cell_x, 0);
  308. ManDataType manType = ManData.GetData(cellAsString9).manType;
  309. dictionary.Add(manType, csv.GetCellAsString(cell_x++, i) == "○");
  310. }
  311. this.enableManTypeDic = new ReadOnlyDictionary<ManDataType, bool>(dictionary);
  312. }
  313. }
  314. }
  315. public string drawNameTerm
  316. {
  317. get
  318. {
  319. return "SceneKasizukiMainMenu/プレイタイトル/" + this.ID.ToString();
  320. }
  321. }
  322. public string strDescriptionTerm
  323. {
  324. get
  325. {
  326. return "SceneKasizukiMainMenu/プレイ内容/" + this.ID.ToString();
  327. }
  328. }
  329. public string[] strConditionArrayTerms
  330. {
  331. get
  332. {
  333. string[] array = new string[this.strConditionArray.Length];
  334. for (int i = 0; i < this.strConditionArray.Length; i++)
  335. {
  336. array[i] = "SceneKasizukiMainMenu/プレイ条件/" + this.strConditionArray[i];
  337. }
  338. return array;
  339. }
  340. }
  341. public bool IsPassed
  342. {
  343. get
  344. {
  345. string text = Enum.GetName(typeof(SystemDataType), SystemDataType.プレイ実行\uFF3F);
  346. text += this.ID.ToString();
  347. bool flag;
  348. return GameMain.Instance.KasizukiMgr.TryGetSystemData<bool>(text, out flag) && flag;
  349. }
  350. set
  351. {
  352. string text = Enum.GetName(typeof(SystemDataType), SystemDataType.プレイ実行\uFF3F);
  353. text += this.ID.ToString();
  354. GameMain.Instance.KasizukiMgr.SetSystemData<bool>(text, value, false);
  355. }
  356. }
  357. public string GetScenarioFileNameReplace(Maid maid)
  358. {
  359. return ScriptManager.ReplacePersonal(maid, this.strScenarioFileName);
  360. }
  361. public bool IsCorrectMaid(Maid maid, ManDataType manType)
  362. {
  363. return this.IsCorrectLikability(maid, manType) && this.IsCorrectWorkCount(maid) && this.IsCorrectParameter(maid) && this.IsCorrectSkill(maid) && this.IsCorrectSeikeiken(maid) && this.IsCorrectRelation(maid) && this.IsCorrectPersonal(maid);
  364. }
  365. public bool IsCorrectParameter(Maid maid)
  366. {
  367. if (this.strNeedParameterArray == null)
  368. {
  369. return true;
  370. }
  371. bool flag = true;
  372. int num = 0;
  373. while (num < this.strNeedParameterArray.Length && flag)
  374. {
  375. try
  376. {
  377. string name = this.strNeedParameterArray[num++];
  378. string s = this.strNeedParameterArray[num++];
  379. int maidStatus = maid.GetMaidStatus(name);
  380. flag &= (maidStatus >= int.Parse(s));
  381. }
  382. catch (Exception ex)
  383. {
  384. NDebug.Assert(ex.ToString(), false);
  385. Debug.LogError(ex);
  386. }
  387. }
  388. return flag;
  389. }
  390. public bool IsCorrectSkill(Maid maid)
  391. {
  392. if (this.strNeedSkillArray == null)
  393. {
  394. return true;
  395. }
  396. bool flag = true;
  397. int num = 0;
  398. while (num < this.strNeedSkillArray.Length && flag)
  399. {
  400. try
  401. {
  402. flag &= maid.status.yotogiSkill.Contains(int.Parse(this.strNeedSkillArray[num]));
  403. }
  404. catch (Exception ex)
  405. {
  406. NDebug.Assert(ex.ToString(), false);
  407. Debug.LogError(ex);
  408. }
  409. num++;
  410. }
  411. return flag;
  412. }
  413. public bool IsCorrectLikability(Maid maid, ManDataType manType)
  414. {
  415. int maidLikability = GameMain.Instance.KasizukiMgr.GetMaidLikability(maid, manType);
  416. return this.needLikability <= maidLikability;
  417. }
  418. public bool IsCorrectWorkCount(Maid maid)
  419. {
  420. if (this.workCountEnableDic == null || this.workCountEnableDic.Count <= 0)
  421. {
  422. return true;
  423. }
  424. int maidData = GameMain.Instance.KasizukiMgr.GetMaidData<int>(maid, MaidDataType.仕事回数, true);
  425. string workCountName = WorkCountReplace.GetWorkCountName(maidData);
  426. return this.workCountEnableDic.ContainsKey(workCountName);
  427. }
  428. public bool IsCorrectSeikeiken(Maid maid)
  429. {
  430. Seikeiken seikeiken = maid.status.seikeiken;
  431. return this.seikeikenEnableDic.ContainsKey(seikeiken);
  432. }
  433. public bool IsCorrectRelation(Maid maid)
  434. {
  435. if (this.relationEnableDic == null || this.relationEnableDic.Count <= 0)
  436. {
  437. return true;
  438. }
  439. Relation relation = maid.status.relation;
  440. return this.relationEnableDic.ContainsKey(relation);
  441. }
  442. public bool IsCorrectPersonal(Maid maid)
  443. {
  444. if (this.strEnablePersonalArray == null || this.strEnablePersonalArray.Length <= 0)
  445. {
  446. return true;
  447. }
  448. for (int i = 0; i < this.strEnablePersonalArray.Length; i++)
  449. {
  450. if (maid.status.personal.uniqueName == this.strEnablePersonalArray[i])
  451. {
  452. return true;
  453. }
  454. }
  455. return false;
  456. }
  457. public List<Maid> GetFilteringPlayDataMaidArray(ManDataType manType)
  458. {
  459. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  460. List<Maid> list = new List<Maid>();
  461. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  462. {
  463. Maid stockMaid = characterMgr.GetStockMaid(i);
  464. if (!(stockMaid == null))
  465. {
  466. if (stockMaid.status.heroineType != HeroineType.Transfer)
  467. {
  468. if (stockMaid.status.heroineType != HeroineType.Sub)
  469. {
  470. if (this.IsCorrectMaid(stockMaid, manType))
  471. {
  472. list.Add(stockMaid);
  473. }
  474. }
  475. }
  476. }
  477. }
  478. return list;
  479. }
  480. private void SplitParameterBlock(string strParameterBlock, out string[] output)
  481. {
  482. if (string.IsNullOrEmpty(strParameterBlock))
  483. {
  484. output = null;
  485. return;
  486. }
  487. string[] array = strParameterBlock.Split(new char[]
  488. {
  489. ','
  490. });
  491. output = new string[array.Length * 2];
  492. for (int i = 0; i < array.Length; i++)
  493. {
  494. string[] array2 = array[i].Split(new char[]
  495. {
  496. '|'
  497. });
  498. NDebug.Assert(array2.Length == 2, string.Format("kasizukiDataTable.PlayData\n表データの「必要パラメータ条件式」の数が不正です\n{0}", array[i]));
  499. output[i * 2] = array2[0];
  500. output[i * 2 + 1] = array2[1];
  501. }
  502. }
  503. private const int CONDITION_COUNT = 6;
  504. public readonly int ID;
  505. public readonly int roomID;
  506. public readonly string strScenarioFileName;
  507. public readonly string drawName;
  508. public readonly string strDescription;
  509. public readonly string[] strConditionArray;
  510. public readonly Dictionary<Seikeiken, bool> seikeikenEnableDic;
  511. public readonly string[] strNeedParameterArray;
  512. public readonly string[] strNeedSkillArray;
  513. public readonly int needLikability;
  514. public readonly Dictionary<string, bool> workCountEnableDic;
  515. public readonly Dictionary<Relation, bool> relationEnableDic;
  516. public readonly string[] strEnablePersonalArray;
  517. public readonly ReadOnlyDictionary<ManDataType, bool> enableManTypeDic;
  518. }
  519. }
  520. }