TouchDataBase.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. namespace PrivateMaidMode
  7. {
  8. public static class TouchDataBase
  9. {
  10. public static int Count
  11. {
  12. get
  13. {
  14. TouchDataBase.CreateData();
  15. return TouchDataBase.commonIdManager.idMap.Count;
  16. }
  17. }
  18. public static bool Contains(int id)
  19. {
  20. TouchDataBase.CreateData();
  21. return TouchDataBase.commonIdManager.idMap.ContainsKey(id);
  22. }
  23. public static TouchDataBase.Data GetData(int id)
  24. {
  25. TouchDataBase.CreateData();
  26. NDebug.Assert(TouchDataBase.basicDatas.ContainsKey(id), "プライベートメイドお触りモード\nID[" + id + "]のデータは存在しません");
  27. return TouchDataBase.basicDatas[id];
  28. }
  29. public static bool IsEnabled(int id)
  30. {
  31. TouchDataBase.CreateData();
  32. return TouchDataBase.commonIdManager.enabledIdList.Contains(id);
  33. }
  34. public static List<TouchDataBase.Data> GetAllDatas(bool onlyEnabled)
  35. {
  36. TouchDataBase.CreateData();
  37. List<TouchDataBase.Data> list = new List<TouchDataBase.Data>();
  38. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in TouchDataBase.commonIdManager.idMap)
  39. {
  40. if (!onlyEnabled || TouchDataBase.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  41. {
  42. list.Add(TouchDataBase.basicDatas[keyValuePair.Key]);
  43. }
  44. }
  45. return list;
  46. }
  47. public static void CreateData()
  48. {
  49. if (TouchDataBase.commonIdManager != null)
  50. {
  51. return;
  52. }
  53. TouchDataBase.commonIdManager = new CsvCommonIdManager("private_maidmode_touch", "プライベートメイドお触りモード", CsvCommonIdManager.Type.IdOnly, null);
  54. TouchDataBase.basicDatas = new Dictionary<int, TouchDataBase.Data>();
  55. string[] array = new string[]
  56. {
  57. "list"
  58. };
  59. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  60. for (int i = 0; i < array2.Length; i++)
  61. {
  62. string text = "private_maidmode_touch_" + array[i] + ".nei";
  63. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  64. CsvParser csvParser = new CsvParser();
  65. bool condition = csvParser.Open(afileBase);
  66. NDebug.Assert(condition, text + "\nopen failed.");
  67. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  68. }
  69. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in TouchDataBase.commonIdManager.idMap)
  70. {
  71. TouchDataBase.basicDatas.Add(keyValuePair.Key, new TouchDataBase.Data(keyValuePair.Key, array2[0].Value));
  72. }
  73. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  74. {
  75. keyValuePair2.Value.Dispose();
  76. keyValuePair2.Key.Dispose();
  77. }
  78. }
  79. private const string csvTopCommonName = "private_maidmode_touch";
  80. private const string typeNameForErrorLog = "プライベートメイドお触りモード";
  81. private static CsvCommonIdManager commonIdManager;
  82. private static Dictionary<int, TouchDataBase.Data> basicDatas;
  83. public enum TouchPoint
  84. {
  85. Head,
  86. Bust,
  87. Back,
  88. Hip,
  89. SecretPart,
  90. Hand,
  91. Leg
  92. }
  93. public class PointData
  94. {
  95. public PointData(TouchDataBase.TouchPoint point, int addExcitement, int addMood)
  96. {
  97. this.point = point;
  98. this.addExcitement = addExcitement;
  99. this.addMood = addMood;
  100. switch (point)
  101. {
  102. case TouchDataBase.TouchPoint.Head:
  103. this.scriptLabelName = "*頭";
  104. break;
  105. case TouchDataBase.TouchPoint.Bust:
  106. this.scriptLabelName = "*胸";
  107. break;
  108. case TouchDataBase.TouchPoint.Back:
  109. this.scriptLabelName = "*背中";
  110. break;
  111. case TouchDataBase.TouchPoint.Hip:
  112. this.scriptLabelName = "*尻";
  113. break;
  114. case TouchDataBase.TouchPoint.SecretPart:
  115. this.scriptLabelName = "*秘部";
  116. break;
  117. case TouchDataBase.TouchPoint.Hand:
  118. this.scriptLabelName = "*手";
  119. break;
  120. case TouchDataBase.TouchPoint.Leg:
  121. this.scriptLabelName = "*足";
  122. break;
  123. }
  124. if (string.IsNullOrEmpty(this.scriptLabelName))
  125. {
  126. Debug.LogError("部位の情報が不正です");
  127. }
  128. }
  129. public readonly TouchDataBase.TouchPoint point;
  130. public readonly int addExcitement;
  131. public readonly int addMood;
  132. public readonly string scriptLabelName;
  133. }
  134. public class Data
  135. {
  136. public Data(int id, CsvParser basicCsv)
  137. {
  138. for (int i = 1; i < basicCsv.max_cell_y; i++)
  139. {
  140. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  141. {
  142. int num = 1;
  143. this.id = id;
  144. this.phaseType = basicCsv.GetCellAsInteger(num++, i);
  145. this.ftFile = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ks");
  146. this.rcRegisterFile = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ks");
  147. this.rcRegisterLabel = basicCsv.GetCellAsString(num++, i);
  148. this.touchScriptFile = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ks");
  149. this.successFile = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ks");
  150. this.successLabel = basicCsv.GetCellAsString(num++, i);
  151. this.failureFile = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ks");
  152. this.failureLabel = basicCsv.GetCellAsString(num++, i);
  153. Dictionary<TouchDataBase.TouchPoint, TouchDataBase.PointData> dictionary = new Dictionary<TouchDataBase.TouchPoint, TouchDataBase.PointData>();
  154. for (int j = 0; j < Enum.GetNames(typeof(TouchDataBase.TouchPoint)).Length; j++)
  155. {
  156. bool flag = basicCsv.GetCellAsString(num++, i) == "〇";
  157. int cellAsInteger = basicCsv.GetCellAsInteger(num++, i);
  158. int cellAsInteger2 = basicCsv.GetCellAsInteger(num++, i);
  159. if (flag)
  160. {
  161. dictionary.Add((TouchDataBase.TouchPoint)j, new TouchDataBase.PointData((TouchDataBase.TouchPoint)j, cellAsInteger, cellAsInteger2));
  162. }
  163. }
  164. this.touchPointData = new ReadOnlyDictionary<TouchDataBase.TouchPoint, TouchDataBase.PointData>(dictionary);
  165. break;
  166. }
  167. }
  168. }
  169. public bool EnabledPoint(TouchDataBase.TouchPoint point)
  170. {
  171. return this.touchPointData.ContainsKey(point);
  172. }
  173. public TouchDataBase.PointData GetPointData(TouchDataBase.TouchPoint point)
  174. {
  175. return (!this.touchPointData.ContainsKey(point)) ? null : this.touchPointData[point];
  176. }
  177. public List<TouchDataBase.PointData> GetAllPointData()
  178. {
  179. return new List<TouchDataBase.PointData>(this.touchPointData.GetValueArray());
  180. }
  181. public readonly int id;
  182. public readonly int phaseType;
  183. public readonly string ftFile;
  184. public readonly string rcRegisterFile;
  185. public readonly string rcRegisterLabel;
  186. public readonly string successFile;
  187. public readonly string successLabel;
  188. public readonly string failureFile;
  189. public readonly string failureLabel;
  190. public readonly string touchScriptFile;
  191. private readonly ReadOnlyDictionary<TouchDataBase.TouchPoint, TouchDataBase.PointData> touchPointData;
  192. }
  193. }
  194. }