CasinoDataMgr.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using UnityEngine;
  6. public class CasinoDataMgr
  7. {
  8. public static CasinoDataMgr Instance
  9. {
  10. get
  11. {
  12. return CasinoDataMgr.m_Instance;
  13. }
  14. }
  15. public Facility CurrentCasino
  16. {
  17. get
  18. {
  19. return this.m_SelectCasino;
  20. }
  21. }
  22. public Maid DealerMaid
  23. {
  24. get
  25. {
  26. return (!this.m_SelectCasino || !this.m_FacilityDealerPair.ContainsKey(this.m_SelectCasino)) ? null : this.m_FacilityDealerPair[this.m_SelectCasino].Maid;
  27. }
  28. }
  29. public int CasinoID
  30. {
  31. get
  32. {
  33. return FacilityDataTable.GetFacilityTypeID("カジノ");
  34. }
  35. }
  36. public int UpwardCasinoID
  37. {
  38. get
  39. {
  40. return FacilityDataTable.GetFacilityTypeID("高級カジノ");
  41. }
  42. }
  43. private void WriteDealerData(BinaryWriter bw, bool is_upward)
  44. {
  45. Facility casinoFacility = this.GetCasinoFacility(is_upward);
  46. bool flag = casinoFacility != null;
  47. string value = (!is_upward) ? "Low" : "High";
  48. bw.Write(value);
  49. if (flag)
  50. {
  51. if (!this.m_FacilityDealerPair.ContainsKey(casinoFacility))
  52. {
  53. this.m_FacilityDealerPair.Add(casinoFacility, new DealerMaid());
  54. }
  55. this.m_FacilityDealerPair[casinoFacility].Serialize(bw);
  56. }
  57. }
  58. private void ReadDealerData(BinaryReader br, bool is_upward)
  59. {
  60. string text = br.ReadString();
  61. bool condition = (!is_upward) ? (text == "Low") : (text == "High");
  62. string message = string.Format((!is_upward) ? "下位施設の情報を読み込もうとしましたが、文字「{0}」が検出されました" : "上位", text[0]);
  63. NDebug.Assert(condition, message);
  64. Facility casinoFacility = this.GetCasinoFacility(is_upward);
  65. bool flag = casinoFacility != null;
  66. if (flag)
  67. {
  68. this.m_FacilityDealerPair.Add(casinoFacility, new DealerMaid());
  69. this.m_FacilityDealerPair[casinoFacility].Deserialize(br);
  70. }
  71. }
  72. public Facility GetCasinoFacility(bool is_upward = false)
  73. {
  74. Facility result = null;
  75. Facility[] array;
  76. bool flag = (!is_upward) ? GameMain.Instance.FacilityMgr.IsExistTypeFacility(this.CasinoID, out array) : GameMain.Instance.FacilityMgr.IsExistTypeFacility(this.UpwardCasinoID, out array);
  77. if (flag)
  78. {
  79. result = array[0];
  80. }
  81. return result;
  82. }
  83. public void InitDealerMaid()
  84. {
  85. this.m_FacilityDealerPair[this.m_SelectCasino].Init();
  86. }
  87. public void SetDealerMaid(Maid maid)
  88. {
  89. this.m_FacilityDealerPair[this.m_SelectCasino].SetDealerMaid(maid);
  90. }
  91. public void Serialize(BinaryWriter bw)
  92. {
  93. bw.Write("COM3D2_CASINO");
  94. bw.Write("Ver:" + 1.1f);
  95. this.WriteDealerData(bw, false);
  96. this.WriteDealerData(bw, true);
  97. bw.Write("COM3D2_CASINOSHOP_ID");
  98. foreach (CasinoShopItem casinoShopItem in this.m_CasinoShopData.Values)
  99. {
  100. bw.Write(casinoShopItem.ID.ToString());
  101. }
  102. bw.Write("COM3D2_CASINOSHOP_ID_END");
  103. foreach (CasinoShopItem casinoShopItem2 in this.m_CasinoShopData.Values)
  104. {
  105. casinoShopItem2.Serialize(bw);
  106. }
  107. }
  108. public void Deserialize(BinaryReader br, int save_version)
  109. {
  110. this.m_FacilityDealerPair.Clear();
  111. foreach (CasinoShopItem casinoShopItem in this.m_CasinoShopData.Values)
  112. {
  113. casinoShopItem.Recet();
  114. }
  115. if (save_version < 210)
  116. {
  117. return;
  118. }
  119. string text = br.ReadString();
  120. float num = float.Parse(br.ReadString().Split(new char[]
  121. {
  122. ':'
  123. })[1]);
  124. this.ReadDealerData(br, false);
  125. this.ReadDealerData(br, true);
  126. if (num >= 1.1f)
  127. {
  128. List<int> list = new List<int>();
  129. string text2 = br.ReadString();
  130. string text3 = br.ReadString();
  131. while (text3 != "COM3D2_CASINOSHOP_ID_END")
  132. {
  133. list.Add(int.Parse(text3));
  134. text3 = br.ReadString();
  135. }
  136. foreach (int key in list)
  137. {
  138. if (this.m_CasinoShopData.ContainsKey(key))
  139. {
  140. this.m_CasinoShopData[key].Deserialize(br);
  141. }
  142. else
  143. {
  144. CasinoShopItem casinoShopItem2 = new CasinoShopItem();
  145. casinoShopItem2.Deserialize(br);
  146. }
  147. }
  148. }
  149. else
  150. {
  151. foreach (CasinoShopItem casinoShopItem3 in this.m_CasinoShopData.Values)
  152. {
  153. casinoShopItem3.Deserialize(br);
  154. }
  155. }
  156. }
  157. public void CasinoSelect(bool is_upward)
  158. {
  159. this.m_SelectCasino = this.GetCasinoFacility(is_upward);
  160. if (this.m_SelectCasino == null)
  161. {
  162. Debug.LogError("該当するカジノ施設が見つかりませんでした");
  163. }
  164. else if (!this.m_FacilityDealerPair.ContainsKey(this.m_SelectCasino))
  165. {
  166. this.m_FacilityDealerPair.Add(this.m_SelectCasino, new DealerMaid());
  167. }
  168. }
  169. public void InitShopData()
  170. {
  171. if (this.m_CasinoShopData.Count > 0)
  172. {
  173. return;
  174. }
  175. HashSet<int> enabled_id_list = new HashSet<int>();
  176. Action<string> action = delegate(string file_name)
  177. {
  178. file_name += ".nei";
  179. if (!GameUty.FileSystem.IsExistentFile(file_name))
  180. {
  181. return;
  182. }
  183. using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen(file_name))
  184. {
  185. using (CsvParser csvParser2 = new CsvParser())
  186. {
  187. bool condition2 = csvParser2.Open(afileBase2);
  188. NDebug.Assert(condition2, file_name + "\nopen failed.");
  189. for (int k = 1; k < csvParser2.max_cell_y; k++)
  190. {
  191. if (csvParser2.IsCellToExistData(0, k))
  192. {
  193. int cellAsInteger2 = csvParser2.GetCellAsInteger(0, k);
  194. if (!enabled_id_list.Contains(cellAsInteger2))
  195. {
  196. enabled_id_list.Add(cellAsInteger2);
  197. }
  198. }
  199. }
  200. }
  201. }
  202. };
  203. action("casinoshop_enable_id");
  204. for (int i = 0; i < GameUty.PathList.Count; i++)
  205. {
  206. action("casinoshop_enable_id_" + GameUty.PathList[i]);
  207. }
  208. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("casinoshop_data.nei"))
  209. {
  210. using (CsvParser csvParser = new CsvParser())
  211. {
  212. bool condition = csvParser.Open(afileBase);
  213. NDebug.Assert(condition, "casinoshop_data.nei]");
  214. for (int j = 1; j < csvParser.max_cell_y; j++)
  215. {
  216. if (csvParser.IsCellToExistData(0, j))
  217. {
  218. int cellAsInteger = csvParser.GetCellAsInteger(0, j);
  219. if (enabled_id_list.Contains(cellAsInteger))
  220. {
  221. if (!this.m_CasinoShopData.ContainsKey(cellAsInteger))
  222. {
  223. this.m_CasinoShopData.Add(cellAsInteger, new CasinoShopItem(csvParser, j));
  224. }
  225. CasinoShopItem casinoShopItem = this.m_CasinoShopData[cellAsInteger];
  226. if (!this.m_CategoryItemData.ContainsKey(casinoShopItem.MyCategory))
  227. {
  228. this.m_CategoryItemData.Add(casinoShopItem.MyCategory, new List<CasinoShopItem>());
  229. }
  230. if (!this.m_CategoryItemData[casinoShopItem.MyCategory].Contains(casinoShopItem))
  231. {
  232. this.m_CategoryItemData[casinoShopItem.MyCategory].Add(casinoShopItem);
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. public List<CasinoShopItem> GetShopItem()
  241. {
  242. return this.m_CasinoShopData.Values.ToList<CasinoShopItem>();
  243. }
  244. public List<CasinoShopItem> GetShopItem(CasinoShopItem.Category category)
  245. {
  246. return this.m_CategoryItemData[category];
  247. }
  248. public void AddTotalCoin(int add_value)
  249. {
  250. if (add_value < 0)
  251. {
  252. return;
  253. }
  254. GameMain.Instance.CharacterMgr.status.AddFlag("コイン入手総額", add_value);
  255. if (GameMain.Instance.CharacterMgr.status.GetFlag("コイン入手総額") >= 10000)
  256. {
  257. GameMain.Instance.CharacterMgr.status.AddHaveTrophy(1120);
  258. }
  259. }
  260. private const int m_CheckMiscVer = 210;
  261. private const string m_SaveHeader = "COM3D2_CASINO";
  262. private const float m_SaveVer = 1.1f;
  263. private const string m_FacilityName = "カジノ";
  264. private const string m_UpwardFacilityName = "高級カジノ";
  265. public const int GetTrophyCoin = 10000;
  266. private static CasinoDataMgr m_Instance = new CasinoDataMgr();
  267. private Dictionary<Facility, DealerMaid> m_FacilityDealerPair = new Dictionary<Facility, DealerMaid>();
  268. private Facility m_SelectCasino;
  269. public bool IsChangeCostume;
  270. private Dictionary<int, CasinoShopItem> m_CasinoShopData = new Dictionary<int, CasinoShopItem>();
  271. private Dictionary<CasinoShopItem.Category, List<CasinoShopItem>> m_CategoryItemData = new Dictionary<CasinoShopItem.Category, List<CasinoShopItem>>();
  272. }