using System; using System.Collections.Generic; using System.IO; using PlayerStatus; using UnityEngine; using wf; public class Shop { public static void CreateData() { if (0 < Shop.item_data_dic_.Count) { return; } Shop.sub_category_dressingbutton_enabled_ = new Dictionary(); using (AFileBase afileBase = GameUty.FileSystem.FileOpen("game_in_shop_category_list.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "game_in_shop_category_list.nei\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { string cellAsString = csvParser.GetCellAsString(0, i); string cellAsString2 = csvParser.GetCellAsString(1, i); if (!Shop.sub_category_dressingbutton_enabled_.ContainsKey(cellAsString2)) { Shop.sub_category_dressingbutton_enabled_.Add(cellAsString2, csvParser.GetCellAsString(2, i) == "〇"); } List list = null; for (int j = 0; j < Shop.category_name_list_.Count; j++) { if (Shop.category_name_list_[j].Key == cellAsString) { list = Shop.category_name_list_[j].Value; break; } } if (list == null) { list = new List(); Shop.category_name_list_.Add(new KeyValuePair>(cellAsString, list)); } bool flag = true; for (int k = 0; k < list.Count; k++) { if (list[k] == cellAsString2) { flag = false; break; } } if (flag) { list.Add(cellAsString2); } } } } } HashSet hashSet = new HashSet(); CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "game_in_shop_itemlist", ref hashSet); if (Product.type == Product.Type.EnPublic) { int[] array = new int[] { 10, 20, 30, 40, 5000 }; foreach (int item in array) { hashSet.Remove(item); } } using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen("game_in_shop_item_setting.nei")) { using (CsvParser csvParser2 = new CsvParser()) { bool condition2 = csvParser2.Open(afileBase2); NDebug.Assert(condition2, "game_in_shop_item_setting.nei\nopen failed."); for (int m = 1; m < csvParser2.max_cell_y; m++) { if (csvParser2.IsCellToExistData(0, m) && hashSet.Contains(csvParser2.GetCellAsInteger(0, m))) { Shop.ItemData itemData = new Shop.ItemData(csvParser2, m); Shop.item_data_dic_.Add(itemData.id, itemData); } } } } using (AFileBase afileBase3 = GameUty.FileSystem.FileOpen("game_in_shop_item_groups_setting.nei")) { using (CsvParser csvParser3 = new CsvParser()) { bool condition3 = csvParser3.Open(afileBase3); NDebug.Assert(condition3, "game_in_shop_item_groups_setting.nei\nopen failed."); for (int n = 1; n < csvParser3.max_cell_y; n++) { if (csvParser3.IsCellToExistData(0, n) && hashSet.Contains(csvParser3.GetCellAsInteger(0, n))) { Shop.ItemDataGroup itemDataGroup = new Shop.ItemDataGroup(csvParser3, n); Shop.item_data_dic_.Add(itemDataGroup.id, itemDataGroup); Shop.item_data_group_dic_.Add(itemDataGroup.id, itemDataGroup); } } } } if (GameUty.FileSystem.IsExistentFile("game_in_shop_event_item_setting.nei")) { using (AFileBase afileBase4 = GameUty.FileSystem.FileOpen("game_in_shop_event_item_setting.nei")) { using (CsvParser csvParser4 = new CsvParser()) { bool condition4 = csvParser4.Open(afileBase4); NDebug.Assert(condition4, "game_in_shop_event_item_setting.nei\nopen failed."); for (int num = 1; num < csvParser4.max_cell_y; num++) { if (csvParser4.IsCellToExistData(0, num) && hashSet.Contains(csvParser4.GetCellAsInteger(0, num))) { Shop.ItemDataEvent itemDataEvent = new Shop.ItemDataEvent(csvParser4, num); Shop.item_data_dic_.Add(itemDataEvent.id, itemDataEvent); } } } } } using (AFileBase afileBase5 = GameUty.FileSystem.FileOpen("game_in_shop_setcard_setting.nei")) { using (CsvParser csvParser5 = new CsvParser()) { bool condition5 = csvParser5.Open(afileBase5); NDebug.Assert(condition5, "game_in_shop_setcard_setting.nei\nopen failed."); for (int num2 = 1; num2 < csvParser5.max_cell_y; num2++) { if (csvParser5.IsCellToExistData(0, num2)) { int num3 = 0; string cellAsString3 = csvParser5.GetCellAsString(num3++, num2); string[] array3 = cellAsString3.Split(new char[] { ',' }); for (int num4 = 0; num4 < array3.Length; num4++) { array3[num4] = array3[num4].ToLower() + ".menu"; } HashSet hashSet2 = new HashSet(); while (num3 < csvParser5.max_cell_x) { if (!csvParser5.IsCellToExistData(num3, num2)) { break; } int num5 = int.Parse(csvParser5.GetCellAsString(num3, num2)); if (!Shop.item_data_dic_.ContainsKey(num5)) { Debug.LogWarning("ショップアイテムID[" + num5 + "]は存在しません"); hashSet2.Clear(); break; } hashSet2.Add(num5); num3++; } if (0 < hashSet2.Count) { Shop.set_card_list_.Add(new KeyValuePair>(array3, hashSet2)); } } } } } using (AFileBase afileBase6 = GameUty.FileSystem.FileOpen("game_in_shop_bg_setting.nei")) { using (CsvParser csvParser6 = new CsvParser()) { bool condition6 = csvParser6.Open(afileBase6); NDebug.Assert(condition6, "game_in_shop_bg_setting.nei\nopen failed."); for (int num6 = 1; num6 < csvParser6.max_cell_y; num6++) { if (csvParser6.IsCellToExistData(0, num6)) { Shop.BGData bgdata = new Shop.BGData(csvParser6, num6); NDebug.Assert(!Shop.bg_data_dic_.ContainsKey(bgdata.id), "ショップ背景設定id[" + bgdata.id + "]は重複しています"); Shop.bg_data_dic_.Add(bgdata.id, bgdata); } } } } } public static void CheckClubGradeShopLineup(int clubGrade) { if (Shop.club_grade_datas_ == null) { Shop.club_grade_datas_ = new List>(); using (AFileBase afileBase = GameUty.FileSystem.FileOpen("game_in_shop_clubgrade_setting.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "file open error[game_in_shop_clubgrade_setting.nei]"); int num = 0; for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { List list = new List(); int num2 = 1; string cellAsString = csvParser.GetCellAsString(num2++, i); if (!string.IsNullOrEmpty(cellAsString)) { string[] array = cellAsString.Split(new char[] { ',' }); for (int j = 0; j < array.Length; j++) { list.Add(int.Parse(array[j].Trim())); } } Shop.club_grade_datas_.Add(list); num++; } } } } } Status status = GameMain.Instance.CharacterMgr.status; for (int k = 0; k < clubGrade; k++) { for (int l = 0; l < Shop.club_grade_datas_[k].Count; l++) { int shopItemId = Shop.club_grade_datas_[k][l]; status.AddShopLineup(shopItemId); } } } public static void CheckBuildingShopLineup() { if (Shop.building_datas_ == null) { Shop.building_datas_ = new List, List>>(); using (AFileBase afileBase = GameUty.FileSystem.FileOpen("game_in_shop_building_setting.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "file open error[game_in_shop_building_setting.nei]"); int num = 0; for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { List list = new List(); int num2 = 0; string cellAsString = csvParser.GetCellAsString(num2++, i); if (!string.IsNullOrEmpty(cellAsString)) { string[] array = cellAsString.Split(new char[] { ',' }); for (int j = 0; j < array.Length; j++) { list.Add(int.Parse(array[j].Trim())); } } if (list.Count != 0) { List list2 = new List(); string cellAsString2 = csvParser.GetCellAsString(num2++, i); if (!string.IsNullOrEmpty(cellAsString2)) { string[] array2 = cellAsString2.Split(new char[] { ',' }); for (int k = 0; k < array2.Length; k++) { list2.Add(int.Parse(array2[k].Trim())); } } Shop.building_datas_.Add(new KeyValuePair, List>(list, list2)); num++; } } } } } } FacilityManager facilityMgr = GameMain.Instance.FacilityMgr; Status status = GameMain.Instance.CharacterMgr.status; foreach (KeyValuePair, List> keyValuePair in Shop.building_datas_) { List key = keyValuePair.Key; List value = keyValuePair.Value; bool flag = false; foreach (int facilityTypeID in key) { flag |= facilityMgr.IsFacilityBuildFlag(facilityTypeID); } if (flag) { foreach (int shopItemId in value) { status.AddShopLineup(shopItemId); } } } } public static void CheckGroupItemData() { Status status = GameMain.Instance.CharacterMgr.status; foreach (KeyValuePair keyValuePair in Shop.item_data_group_dic_) { if (!status.IsShopLineupItem(keyValuePair.Key)) { List need_id_list = keyValuePair.Value.need_id_list; bool flag = true; for (int i = 0; i < need_id_list.Count; i++) { if (!status.IsShopLineupItem(need_id_list[i])) { flag = false; break; } } if (flag) { status.AddShopLineup(keyValuePair.Key); } } } } public static void ResetEventItem(int item_id) { if (!Shop.item_data_dic_.ContainsKey(item_id) || Shop.item_data_dic_[item_id].type != Shop.ItemDataBase.Type.Event) { Debug.LogWarning("ショップアイテム[" + item_id + "]はイベントアイテムではありません"); return; } Shop.ItemDataEvent itemDataEvent = Shop.item_data_dic_[item_id] as Shop.ItemDataEvent; if (itemDataEvent.is_have_item) { itemDataEvent.Reset(); } } public static bool BuyEventItem(int item_id, bool free_buy) { if (!Shop.item_data_dic_.ContainsKey(item_id) || Shop.item_data_dic_[item_id].type != Shop.ItemDataBase.Type.Event) { Debug.LogWarning("ショップアイテム[" + item_id + "]はイベントアイテムではありません"); return false; } Shop.ItemDataEvent itemDataEvent = Shop.item_data_dic_[item_id] as Shop.ItemDataEvent; if (itemDataEvent.is_have_item || !itemDataEvent.is_enabled_buy_item) { return false; } if (!free_buy) { long num = GameMain.Instance.CharacterMgr.status.money - (long)itemDataEvent.price; if (num < 0L) { return false; } GameMain.Instance.CharacterMgr.status.money += (long)(itemDataEvent.price * -1); } itemDataEvent.ExecBuy(); return true; } public static Dictionary item_data_dic { get { return Shop.item_data_dic_; } } public static Dictionary item_data_group_dic { get { return Shop.item_data_group_dic_; } } public static List>> category_name_list { get { return Shop.category_name_list_; } } public static Dictionary sub_category_dressingbutton_enabled { get { return Shop.sub_category_dressingbutton_enabled_; } } public static List>> set_card_list { get { return Shop.set_card_list_; } } public static Dictionary bg_data_dic { get { return Shop.bg_data_dic_; } } private static Dictionary item_data_dic_ = new Dictionary(); private static Dictionary item_data_group_dic_ = new Dictionary(); private static List>> category_name_list_ = new List>>(); private static Dictionary sub_category_dressingbutton_enabled_ = new Dictionary(); private static List>> set_card_list_ = new List>>(); private static Dictionary bg_data_dic_ = new Dictionary(); private static List> club_grade_datas_; private static List, List>> building_datas_; public abstract class ItemDataBase { public ItemDataBase(CsvParser csv, int line_y, bool is_event_item_csv) { int num = 0; this.id = csv.GetCellAsInteger(num++, line_y); this.valid_bg_id_list = new HashSet(); string[] array = csv.GetCellAsString(num++, line_y).Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { this.valid_bg_id_list.Add(int.Parse(array[i])); } this.name = csv.GetCellAsString(num++, line_y); this.icon_file = csv.GetCellAsString(num++, line_y) + ".tex"; this.detail_text = csv.GetCellAsString(num++, line_y); this.detail_text = this.detail_text.Replace("《改行》", "\n"); if (!is_event_item_csv) { string cellAsString = csv.GetCellAsString(num++, line_y); if (!string.IsNullOrEmpty(cellAsString)) { this.SetMaskMode((TBody.MaskMode)Enum.Parse(typeof(TBody.MaskMode), cellAsString)); } else { this.SetMaskMode(TBody.MaskMode.None); } this.main_category = csv.GetCellAsString(num++, line_y); this.sub_category = csv.GetCellAsString(num++, line_y); } else { this.main_category = csv.GetCellAsString(num++, line_y); this.sub_category = csv.GetCellAsString(num++, line_y); } } public abstract int price { get; } public abstract string[] item_menu_array { get; } public abstract string[] trial_wear_item_menu_array { get; } public abstract bool is_have_item { get; } public abstract bool is_enabled_buy_item { get; } public abstract bool enabled_mask_mode { get; } public abstract TBody.MaskMode mask_mode { get; } public abstract Shop.ItemDataBase.Type type { get; } protected abstract void SetMaskMode(TBody.MaskMode setting_mask_mode); public readonly int id; public readonly HashSet valid_bg_id_list; public readonly string name; public readonly string main_category; public readonly string sub_category; public readonly string detail_text; public readonly string icon_file; public enum Type { Parts, Event } } public class ItemData : Shop.ItemDataBase { public ItemData(CsvParser csv, int line_y) : base(csv, line_y, false) { int i = 8; this.price_ = csv.GetCellAsInteger(i++, line_y); List list = new List(); while (i < csv.max_cell_x) { if (csv.IsCellToExistData(i, line_y)) { string cellAsString = csv.GetCellAsString(i, line_y); if (!string.IsNullOrEmpty(cellAsString)) { list.Add(cellAsString.ToLower() + ".menu"); } } i++; } this.item_menu_array_ = list.ToArray(); } public override int price { get { return this.price_; } } public override string[] item_menu_array { get { return this.item_menu_array_; } } public override string[] trial_wear_item_menu_array { get { return new string[] { this.item_menu_array_[0] }; } } public override bool is_have_item { get { Status status = GameMain.Instance.CharacterMgr.status; return status.IsShopLineupItem(this.id) && status.shopLineups.Get(this.id) == ShopItemStatus.Purchased; } } public override bool is_enabled_buy_item { get { return true; } } public override bool enabled_mask_mode { get { return true; } } public override Shop.ItemDataBase.Type type { get { return Shop.ItemDataBase.Type.Parts; } } public override TBody.MaskMode mask_mode { get { return this.mask_mode_; } } protected override void SetMaskMode(TBody.MaskMode setting_mask_mode) { this.mask_mode_ = setting_mask_mode; } protected readonly int price_; protected readonly string[] item_menu_array_; protected TBody.MaskMode mask_mode_; } public class ItemDataGroup : Shop.ItemDataBase { public ItemDataGroup(CsvParser csv, int line_y) : base(csv, line_y, false) { for (int i = 8; i < csv.max_cell_x; i++) { if (csv.IsCellToExistData(i, line_y)) { this.need_id_list_.Add(csv.GetCellAsInteger(i, line_y)); } } } public override int price { get { List notHaveItemData = this.GetNotHaveItemData(); int num = 0; for (int i = 0; i < notHaveItemData.Count; i++) { num += notHaveItemData[i].price; } return num; } } public override string[] item_menu_array { get { List notHaveItemData = this.GetNotHaveItemData(); List list = new List(); for (int i = 0; i < notHaveItemData.Count; i++) { string[] item_menu_array = notHaveItemData[i].item_menu_array; for (int j = 0; j < item_menu_array.Length; j++) { list.Add(item_menu_array[j]); } } return list.ToArray(); } } public override string[] trial_wear_item_menu_array { get { Status status = GameMain.Instance.CharacterMgr.status; List list = new List(); for (int i = 0; i < this.need_id_list_.Count; i++) { list.Add(Shop.item_data_dic[this.need_id_list_[i]]); } List list2 = new List(); for (int j = 0; j < list.Count; j++) { string[] trial_wear_item_menu_array = list[j].trial_wear_item_menu_array; for (int k = 0; k < trial_wear_item_menu_array.Length; k++) { list2.Add(trial_wear_item_menu_array[k]); } } return list2.ToArray(); } } public override bool is_have_item { get { Status status = GameMain.Instance.CharacterMgr.status; return status.IsShopLineupItem(this.id) && (status.shopLineups.Get(this.id) == ShopItemStatus.Purchased || this.GetNotHaveItemData().Count == 0); } } public override bool is_enabled_buy_item { get { return true; } } private List GetNotHaveItemData() { Status status = GameMain.Instance.CharacterMgr.status; List list = new List(); for (int i = 0; i < this.need_id_list_.Count; i++) { if (status.IsShopLineupItem(this.need_id_list_[i]) && status.shopLineups.Get(this.need_id_list_[i]) != ShopItemStatus.Purchased) { list.Add(Shop.item_data_dic[this.need_id_list_[i]]); } } return list; } public override bool enabled_mask_mode { get { return true; } } public override Shop.ItemDataBase.Type type { get { return Shop.ItemDataBase.Type.Parts; } } public override TBody.MaskMode mask_mode { get { return this.mask_mode_; } } public List need_id_list { get { return this.need_id_list_; } } protected override void SetMaskMode(TBody.MaskMode setting_mask_mode) { this.mask_mode_ = setting_mask_mode; } private List need_id_list_ = new List(); private TBody.MaskMode mask_mode_; } public class ItemDataEvent : Shop.ItemDataBase { public ItemDataEvent(CsvParser csv, int line_y) : base(csv, line_y, true) { int cell_x = 7; this.price_ = csv.GetCellAsInteger(cell_x++, line_y); this.target_flag_name_ = csv.GetCellAsString(cell_x++, line_y); string cellAsString = csv.GetCellAsString(cell_x++, line_y); if (!string.IsNullOrEmpty(cellAsString)) { string[] array = cellAsString.Split(new char[] { ',' }); foreach (string s in array) { int num = int.Parse(s); if (!this.overlap_check_id_list_.Contains(num) && this.id != num) { this.overlap_check_id_list_.Add(num); } } } while (csv.IsCellToExistData(cell_x, line_y)) { cellAsString = csv.GetCellAsString(cell_x++, line_y); this.free_text_list_.Add(cellAsString); } } public void ExecBuy() { GameMain.Instance.CharacterMgr.status.AddHaveItem(this.target_flag_name_); } public void Reset() { GameMain.Instance.CharacterMgr.status.RemoveHaveItem(this.target_flag_name_); } public override int price { get { return this.price_; } } public override string[] item_menu_array { get { return this.dummy_array_; } } public override string[] trial_wear_item_menu_array { get { return this.dummy_array_; } } public override bool is_have_item { get { return GameMain.Instance.CharacterMgr.status.IsHaveItem(this.target_flag_name_); } } public override bool is_enabled_buy_item { get { foreach (int key in this.overlap_check_id_list_) { if (Shop.item_data_dic.ContainsKey(key)) { if (Shop.item_data_dic[key].is_have_item) { return false; } } } return true; } } public override bool enabled_mask_mode { get { return false; } } public override TBody.MaskMode mask_mode { get { return TBody.MaskMode.None; } } protected override void SetMaskMode(TBody.MaskMode setting_mask_mode) { } public override Shop.ItemDataBase.Type type { get { return Shop.ItemDataBase.Type.Event; } } public string target_flag_name { get { return this.target_flag_name_; } } public List free_text { get { return this.free_text_list_; } } private int price_; private string target_flag_name_; private HashSet overlap_check_id_list_ = new HashSet(); private string[] dummy_array_ = new string[0]; private List free_text_list_ = new List(); } public class BGData { public BGData(CsvParser csv, int line_y) { int num = 0; this.id = csv.GetCellAsInteger(num++, line_y); this.bg_prefab_name = csv.GetCellAsString(num++, line_y); this.use_stage_data = null; string cellAsString = csv.GetCellAsString(num++, line_y); if (!string.IsNullOrEmpty(cellAsString) && YotogiStage.IsEnabled(cellAsString)) { this.use_stage_data = YotogiStage.GetData(cellAsString); } this.plya_bgm_name = csv.GetCellAsString(num++, line_y); if (string.IsNullOrEmpty(Path.GetExtension(this.plya_bgm_name))) { this.plya_bgm_name += ".ogg"; } } public void ChangeBg(Maid maid) { GameMain.Instance.BgMgr.ChangeBg(this.bg_prefab_name); YotogiSkillSelectWaitMotion.ApplyEnvSetting(maid, this.use_stage_data); } public void PlayBGM(float fade_time = 0.5f) { GameMain.Instance.SoundMgr.PlayBGM(this.plya_bgm_name, fade_time, true); } public readonly int id; public readonly YotogiStage.Data use_stage_data; public readonly string bg_prefab_name; public readonly string plya_bgm_name; } }