123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class CsvImporter : MonoBehaviour
- {
- private void Start()
- {
- }
- public int GetCsvDataMs(string fileName)
- {
- if (!GameUty.FileSystem.IsExistentFile(fileName))
- {
- NDebug.Assert("表がありません。" + fileName, false);
- }
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, fileName + "\nopen failed.");
- int i = 0;
- List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
- for (i = 1; i < csvParser.max_cell_y; i++)
- {
- if (csvParser.IsCellToExistData(0, i))
- {
- string cellAsString = csvParser.GetCellAsString(0, i);
- Debug.Log("cell = " + cellAsString);
- return int.Parse(cellAsString);
- }
- }
- }
- }
- return -1;
- }
- public void GetCsvData(string fileName)
- {
- if (!GameUty.FileSystem.IsExistentFile(fileName))
- {
- NDebug.Assert("表がありません。" + fileName, false);
- }
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, fileName + "\nopen failed.");
- int i = 0;
- List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
- for (i = 1; i < csvParser.max_cell_y; i++)
- {
- if (csvParser.IsCellToExistData(0, i))
- {
- int j = 0;
- int num = 0;
- for (j = 0; j < csvParser.max_cell_x; j++)
- {
- if (csvParser.IsCellToExistData(j, i))
- {
- switch (j)
- {
- case 1:
- {
- string cellAsString = csvParser.GetCellAsString(j, i);
- if (cellAsString == null)
- {
- goto IL_1B1;
- }
- if (CsvImporter.<>f__switch$map5 == null)
- {
- CsvImporter.<>f__switch$map5 = new Dictionary<string, int>(7)
- {
- {
- "スリーセブン",
- 0
- },
- {
- "BAR",
- 1
- },
- {
- "ピエロ",
- 2
- },
- {
- "ベル",
- 3
- },
- {
- "メダル",
- 4
- },
- {
- "ぶどう",
- 5
- },
- {
- "チェリー",
- 6
- }
- };
- }
- int num2;
- if (!CsvImporter.<>f__switch$map5.TryGetValue(cellAsString, out num2))
- {
- goto IL_1B1;
- }
- switch (num2)
- {
- case 0:
- num = 0;
- break;
- case 1:
- num = 1;
- break;
- case 2:
- num = 2;
- break;
- case 3:
- num = 3;
- break;
- case 4:
- num = 4;
- break;
- case 5:
- num = 5;
- break;
- case 6:
- num = 6;
- break;
- case 7:
- goto IL_1B1;
- default:
- goto IL_1B1;
- }
- break;
- IL_1B1:
- num = -1;
- break;
- }
- case 2:
- if (num != -1)
- {
- this.payDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
- }
- break;
- case 3:
- if (num != -1)
- {
- this.normalDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
- this.normalMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
- }
- break;
- case 4:
- if (num != -1)
- {
- this.chanceDividend[num] = int.Parse(csvParser.GetCellAsString(j, i));
- this.chanceMaxProb += int.Parse(csvParser.GetCellAsString(j, i));
- }
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- public int GetCsvDataParse(int id)
- {
- if (id == 0)
- {
- return this.normalMaxProb;
- }
- if (id != 1)
- {
- return -1;
- }
- return this.chanceMaxProb;
- }
- public int[] GetCsvDataParseList(int id)
- {
- if (id == 0)
- {
- return this.payDividend;
- }
- if (id == 1)
- {
- return this.normalDividend;
- }
- if (id != 2)
- {
- return null;
- }
- return this.chanceDividend;
- }
- public int[] normalDividend = new int[8];
- public int[] chanceDividend = new int[8];
- public int[] payDividend = new int[8];
- public int normalMaxProb;
- public int chanceMaxProb;
- }
|