CsvImporter.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CsvImporter : MonoBehaviour
  5. {
  6. private void Start()
  7. {
  8. }
  9. public int GetCsvDataMs(string fileName)
  10. {
  11. if (!GameUty.FileSystem.IsExistentFile(fileName))
  12. {
  13. NDebug.Assert("表がありません。" + fileName, false);
  14. }
  15. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
  16. {
  17. using (CsvParser csvParser = new CsvParser())
  18. {
  19. bool condition = csvParser.Open(afileBase);
  20. NDebug.Assert(condition, fileName + "\nopen failed.");
  21. int i = 0;
  22. List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
  23. for (i = 1; i < csvParser.max_cell_y; i++)
  24. {
  25. if (csvParser.IsCellToExistData(0, i))
  26. {
  27. string cellAsString = csvParser.GetCellAsString(0, i);
  28. Debug.Log("cell = " + cellAsString);
  29. return int.Parse(cellAsString);
  30. }
  31. }
  32. }
  33. }
  34. return -1;
  35. }
  36. public void GetCsvData(string fileName)
  37. {
  38. if (!GameUty.FileSystem.IsExistentFile(fileName))
  39. {
  40. NDebug.Assert("表がありません。" + fileName, false);
  41. }
  42. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
  43. {
  44. using (CsvParser csvParser = new CsvParser())
  45. {
  46. bool condition = csvParser.Open(afileBase);
  47. NDebug.Assert(condition, fileName + "\nopen failed.");
  48. int i = 0;
  49. List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
  50. for (i = 1; i < csvParser.max_cell_y; i++)
  51. {
  52. if (csvParser.IsCellToExistData(0, i))
  53. {
  54. int j = 0;
  55. int num = 0;
  56. for (j = 0; j < csvParser.max_cell_x; j++)
  57. {
  58. if (csvParser.IsCellToExistData(j, i))
  59. {
  60. switch (j)
  61. {
  62. case 1:
  63. {
  64. string cellAsString = csvParser.GetCellAsString(j, i);
  65. if (cellAsString == null)
  66. {
  67. goto IL_1B1;
  68. }
  69. if (CsvImporter.<>f__switch$map5 == null)
  70. {
  71. CsvImporter.<>f__switch$map5 = new Dictionary<string, int>(7)
  72. {
  73. {
  74. "スリーセブン",
  75. 0
  76. },
  77. {
  78. "BAR",
  79. 1
  80. },
  81. {
  82. "ピエロ",
  83. 2
  84. },
  85. {
  86. "ベル",
  87. 3
  88. },
  89. {
  90. "メダル",
  91. 4
  92. },
  93. {
  94. "ぶどう",
  95. 5
  96. },
  97. {
  98. "チェリー",
  99. 6
  100. }
  101. };
  102. }
  103. int num2;
  104. if (!CsvImporter.<>f__switch$map5.TryGetValue(cellAsString, out num2))
  105. {
  106. goto IL_1B1;
  107. }
  108. switch (num2)
  109. {
  110. case 0:
  111. num = 0;
  112. break;
  113. case 1:
  114. num = 1;
  115. break;
  116. case 2:
  117. num = 2;
  118. break;
  119. case 3:
  120. num = 3;
  121. break;
  122. case 4:
  123. num = 4;
  124. break;
  125. case 5:
  126. num = 5;
  127. break;
  128. case 6:
  129. num = 6;
  130. break;
  131. case 7:
  132. goto IL_1B1;
  133. default:
  134. goto IL_1B1;
  135. }
  136. break;
  137. IL_1B1:
  138. num = -1;
  139. break;
  140. }
  141. case 2:
  142. if (num != -1)
  143. {
  144. this.payDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
  145. }
  146. break;
  147. case 3:
  148. if (num != -1)
  149. {
  150. this.normalDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
  151. this.normalMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
  152. }
  153. break;
  154. case 4:
  155. if (num != -1)
  156. {
  157. this.chanceDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
  158. this.chanceMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
  159. }
  160. break;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. }
  169. public int GetCsvDataParse(int id)
  170. {
  171. if (id == 0)
  172. {
  173. return this.normalMaxProb;
  174. }
  175. if (id != 1)
  176. {
  177. return -1;
  178. }
  179. return this.chanceMaxProb;
  180. }
  181. public int[] GetCsvDataParseList(int id)
  182. {
  183. if (id == 0)
  184. {
  185. return this.payDividend;
  186. }
  187. if (id == 1)
  188. {
  189. return this.normalDividend;
  190. }
  191. if (id != 2)
  192. {
  193. return null;
  194. }
  195. return this.chanceDividend;
  196. }
  197. public int[] normalDividend = new int[8];
  198. public int[] chanceDividend = new int[8];
  199. public int[] payDividend = new int[8];
  200. public int normalMaxProb;
  201. public int chanceMaxProb;
  202. }