Trophy.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using System;
  2. using System.Collections.Generic;
  3. using wf;
  4. public static class Trophy
  5. {
  6. public static int Count
  7. {
  8. get
  9. {
  10. Trophy.CreateData();
  11. return Trophy.commonIdManager.idMap.Count;
  12. }
  13. }
  14. public static bool Contains(string name)
  15. {
  16. return Trophy.commonIdManager.nameMap.ContainsKey(name);
  17. }
  18. public static bool Contains(int id)
  19. {
  20. return Trophy.commonIdManager.idMap.ContainsKey(id);
  21. }
  22. public static int uniqueNameToId(string name)
  23. {
  24. Trophy.CreateData();
  25. NDebug.Assert(Trophy.commonIdManager.nameMap.ContainsKey(name), "トロフィー\nユニーク名[" + name + "]をIDに変換できませんでした");
  26. return Trophy.commonIdManager.nameMap[name];
  27. }
  28. public static string IdToUniqueName(int id)
  29. {
  30. Trophy.CreateData();
  31. NDebug.Assert(Trophy.commonIdManager.idMap.ContainsKey(id), "トロフィー\nID[" + id + "]をユニーク名に変換できませんでした");
  32. return Trophy.commonIdManager.idMap[id].Key;
  33. }
  34. public static Trophy.Data GetData(int id)
  35. {
  36. Trophy.CreateData();
  37. NDebug.Assert(Trophy.basicDatas.ContainsKey(id), "トロフィー\nID[" + id + "]のデータは存在しません");
  38. return Trophy.basicDatas[id];
  39. }
  40. public static Trophy.Data GetData(string uniqueName)
  41. {
  42. return Trophy.GetData(Trophy.uniqueNameToId(uniqueName));
  43. }
  44. public static bool IsEnabled(string uniqueName)
  45. {
  46. Trophy.CreateData();
  47. return Trophy.commonIdManager.enabledIdList.Contains(Trophy.uniqueNameToId(uniqueName));
  48. }
  49. public static bool IsEnabled(int id)
  50. {
  51. Trophy.CreateData();
  52. return Trophy.commonIdManager.enabledIdList.Contains(id);
  53. }
  54. public static List<Trophy.Data> GetAllDatas(bool onlyEnabled)
  55. {
  56. Trophy.CreateData();
  57. List<Trophy.Data> list = new List<Trophy.Data>();
  58. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Trophy.commonIdManager.idMap)
  59. {
  60. if (!onlyEnabled || Trophy.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  61. {
  62. list.Add(Trophy.basicDatas[keyValuePair.Key]);
  63. }
  64. }
  65. return list;
  66. }
  67. public static void CreateData()
  68. {
  69. if (Trophy.commonIdManager != null)
  70. {
  71. return;
  72. }
  73. Trophy.commonIdManager = new CsvCommonIdManager("trophy", "トロフィー", CsvCommonIdManager.Type.IdOnly, null);
  74. Trophy.basicDatas = new Dictionary<int, Trophy.Data>();
  75. string[] array = new string[]
  76. {
  77. "list"
  78. };
  79. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  80. for (int i = 0; i < array2.Length; i++)
  81. {
  82. string text = "trophy_" + array[i] + ".nei";
  83. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  84. CsvParser csvParser = new CsvParser();
  85. bool condition = csvParser.Open(afileBase);
  86. NDebug.Assert(condition, text + "\nopen failed.");
  87. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  88. }
  89. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Trophy.commonIdManager.idMap)
  90. {
  91. int key = keyValuePair.Key;
  92. Trophy.Data value = new Trophy.Data(key, array2[0].Value);
  93. Trophy.basicDatas.Add(key, value);
  94. }
  95. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  96. {
  97. keyValuePair2.Value.Dispose();
  98. keyValuePair2.Key.Dispose();
  99. }
  100. }
  101. private const string csvTopCommonName = "trophy";
  102. private const string typeNameForErrorLog = "トロフィー";
  103. private static CsvCommonIdManager commonIdManager;
  104. private static Dictionary<int, Trophy.Data> basicDatas;
  105. public class Data
  106. {
  107. public Data(int uniqueId, CsvParser basicCsv)
  108. {
  109. for (int i = 1; i < basicCsv.max_cell_y; i++)
  110. {
  111. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == uniqueId)
  112. {
  113. int num = 1;
  114. this.id = uniqueId;
  115. this.rarity = basicCsv.GetCellAsInteger(num++, i);
  116. this.name = basicCsv.GetCellAsString(num++, i);
  117. this.maidPoint = basicCsv.GetCellAsInteger(num++, i);
  118. string cellAsString = basicCsv.GetCellAsString(num++, i);
  119. this.type = ((!(cellAsString == "ヒロイン")) ? ((!(cellAsString == "システム")) ? Trophy.Data.Type.Extra : Trophy.Data.Type.System) : Trophy.Data.Type.Heroine);
  120. this.widthType = (basicCsv.GetCellAsString(num++, i) == "〇");
  121. this.miniCardTextureFileName = basicCsv.GetCellAsString(num++, i);
  122. this.cardTextureFileName = basicCsv.GetCellAsString(num++, i);
  123. this.infoText = basicCsv.GetCellAsString(num++, i);
  124. this.bonusText = basicCsv.GetCellAsString(num++, i);
  125. if (!string.IsNullOrEmpty(this.bonusText))
  126. {
  127. this.infoText = this.infoText + "\n" + this.bonusText;
  128. }
  129. this.effectDrawItemName = basicCsv.GetCellAsString(num++, i);
  130. this.titleMask = (basicCsv.GetCellAsString(num++, i) == "〇");
  131. break;
  132. }
  133. }
  134. }
  135. public string trophySpriteName
  136. {
  137. get
  138. {
  139. if (this.rarity == 1)
  140. {
  141. return "cm3d2_trophy_trophymark_bronze";
  142. }
  143. if (this.rarity == 2)
  144. {
  145. return "cm3d2_trophy_trophymark_silver";
  146. }
  147. if (this.rarity == 3)
  148. {
  149. return "cm3d2_trophy_trophymark_gold";
  150. }
  151. return "cm3d2_trophy_trophymark_bronze";
  152. }
  153. }
  154. public string typeDrawText
  155. {
  156. get
  157. {
  158. return (this.type != Trophy.Data.Type.Heroine) ? ((this.type != Trophy.Data.Type.System) ? "エクストラ" : "システム") : "ヒロイン";
  159. }
  160. }
  161. public string nameTerm
  162. {
  163. get
  164. {
  165. return "SceneTrophy/" + this.id.ToString() + "/トロフィー名";
  166. }
  167. }
  168. public string infoTextTerm
  169. {
  170. get
  171. {
  172. return "SceneTrophy/" + this.id.ToString() + "/説明";
  173. }
  174. }
  175. public string miniCardTextureFileNameTerm
  176. {
  177. get
  178. {
  179. return "SceneTrophy/" + this.id.ToString() + "/スプライトミニ";
  180. }
  181. }
  182. public string cardTextureFileNameTerm
  183. {
  184. get
  185. {
  186. return "SceneTrophy/" + this.id.ToString() + "/スプライト";
  187. }
  188. }
  189. public readonly int id;
  190. public readonly Trophy.Data.Type type;
  191. public readonly bool widthType;
  192. public readonly string miniCardTextureFileName;
  193. public readonly string cardTextureFileName;
  194. public readonly int rarity;
  195. public readonly string name;
  196. public readonly int maidPoint;
  197. public readonly string infoText;
  198. public readonly string bonusText;
  199. public readonly string effectDrawItemName;
  200. public readonly bool titleMask;
  201. public readonly int[] lineupIdArray;
  202. public enum Type
  203. {
  204. Heroine,
  205. System,
  206. Extra
  207. }
  208. }
  209. }