public static int GetModeTypeNum(int type) { string _type = ""; if (type == 1) { _type = "ishopType_General"; } else if (type == 2) { _type = "ishopType_Special"; } else if (type == 3) { _type = "ishopType_Funcion"; } else if (type == 4) { _type = "ishopType_Cheap"; } int num = 0; foreach (var mode in m_ItemModeList) { if (CFormat.PureString(mode.type) == CFormat.PureString(_type) && CFormat.PureString(mode.item_id) != "") { num++; } } return(num); }
public static bool ItemSendNext(string code, int level, string item) { List <ShopData_Str> shopDataList = new List <ShopData_Str>(); if (level >= 0 && level < 4) { shopDataList = m_ShopDataList[level]; } else { return(false); } foreach (var shop in shopDataList) { if (CFormat.PureString(shop.code) == CFormat.PureString(code)) { for (int i = 0; i < shop.list.Count; i++) { if (CFormat.ToSimplified(shop.list[i]) == item && i < shop.list.Count - 1) { string tmp; tmp = shop.list[i + 1]; shop.list[i + 1] = shop.list[i]; shop.list[i] = tmp; return(true); } } } } m_ShopDataList[level] = shopDataList; return(false); }
public static bool DelItemModeInfo(string code) { foreach (var mode in m_ItemModeList) { if (CFormat.PureString(mode.code) == CFormat.PureString(code)) { m_ItemModeList.Remove(mode); ReSort(); return(true); } } return(false); }
public string NameSimpToTrad(string name) { string ret = ""; foreach (var item in m_PlayerDefList) { if (CFormat.ToSimplified(CFormat.PureString(name)) == CFormat.ToSimplified(CFormat.PureString(item.name))) { return(item.name); } } return(ret); }
public string GetPalyerName(string id) { string name = ""; foreach (var player in m_PlayerNameList) { if (CFormat.ToSimplified(CFormat.PureString(id)) == CFormat.ToSimplified(CFormat.PureString(player.id))) { return(player.name); } } return(name); }
public static bool AddTailItemModeInfo(string code, Item_Mode_Str newMode) { foreach (var mode in m_ItemModeList) { if (CFormat.PureString(mode.code) == CFormat.PureString(code)) { int index = m_ItemModeList.IndexOf(mode); m_ItemModeList.Insert(index, newMode); ReSort(); return(true); } } return(false); }
public string GetItemHelp(string id) { string name = ""; foreach (var item in m_ItemHelpList) { if (CFormat.ToSimplified(CFormat.PureString(id)) == CFormat.ToSimplified(CFormat.PureString(item.id))) { return(item.name); } } return(name); }
public string GetIdByCode(string code) { string id = ""; foreach (var item in m_ItemDefList) { if (CFormat.ToSimplified(CFormat.PureString(code)) == CFormat.ToSimplified(CFormat.PureString("item_" + item.name))) { return(item.id); } } return(id); }
public string GetIdByCode(string code) { string id = ""; foreach (var player in m_PlayerDefList) { if (CFormat.ToSimplified(CFormat.PureString(code)) == CFormat.ToSimplified(CFormat.PureString("role_" + player.name))) { return(player.id); } } return(id); }
private static bool ReSort() { List <Item_Mode_Str> m_ItemModeListNew = new List <Item_Mode_Str>(); Item_Mode_Str newMode = new Item_Mode_Str(); int code1 = 100; int code2 = 200; int code3 = 300; int code4 = 400; foreach (var mode in m_ItemModeList) { if (CFormat.PureString(mode.item_id) == "") { continue; } newMode = mode; if (newMode.type == "ishopType_General") { code1++; newMode.code = code1.ToString(); } else if (newMode.type == "ishopType_Special") { code2++; newMode.code = code2.ToString(); } else if (newMode.type == "ishopType_Funcion") { code3++; newMode.code = code3.ToString(); } else if (newMode.type == "ishopType_Cheap") { code4++; newMode.code = code4.ToString(); } m_ItemModeListNew.Add(newMode); } m_ItemModeList.Clear(); m_ItemModeList = m_ItemModeListNew; max_code1 = code1; max_code2 = code2; max_code3 = code3; max_code4 = code4; return(true); }
public static bool ShopDataExit(string shop_name, int level) { if (level >= 0 && level < 4) { foreach (var shop in m_ShopDataList[level]) { if (CFormat.PureString(shop_name) == shop.ShopName) { return(true); } } } return(false); }
public static bool LoadStageDefInfo() { //文件存在 if (!File.Exists("data\\STAGE.H")) { return(false); } //读取 m_StageDefList.Clear(); FileStream fs = new FileStream("data\\STAGE.H", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("#define")) { StageDef_Str stageDef; string tmp = strLine.Split(new string[] { "city_" }, StringSplitOptions.RemoveEmptyEntries)[1]; string name = tmp.Split(' ')[0].Split('\t')[0]; string id = tmp.Replace(" ", "").Replace("\\t", "").Replace(name, ""); id = CFormat.PureString(id); //去掉前面的0 id = CFormat.RemoveXZeroStr(id); stageDef.id = CFormat.PureString(id); stageDef.name = CFormat.PureString(name); m_StageDefList.Add(stageDef); } strLine = null; strLine = reader.ReadLine(); } reader.Close(); fs.Close(); return(true); }
public bool LoadPlayerDefList() { //文件存在 if (!File.Exists(m_Forder + "\\PLAYERS.H")) { return(false); } //读取 m_PlayerDefList.Clear(); FileStream fs = new FileStream(m_Forder + "\\PLAYERS.H", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("#define")) { PlayerDef_Str playerDef; string tmp = strLine.Split(new string[] { "role_" }, StringSplitOptions.RemoveEmptyEntries)[1]; string name = tmp.Split(' ')[0].Split('\t')[0]; string id = tmp.Replace(" ", "").Replace("\\t", "").Replace(name, ""); playerDef.id = CFormat.PureString(id); playerDef.name = CFormat.PureString(name); m_lastDefId = int.Parse(playerDef.id); m_PlayerDefList.Add(playerDef); } strLine = null; strLine = reader.ReadLine(); } m_playerCount = m_PlayerDefList.Count; reader.Close(); fs.Close(); return(true); }
public static bool LoadShopNameList() { //文件存在 if (!File.Exists("data\\SHOP_NAME.TXT")) { return(false); } //读取 m_ShopNameList.Clear(); FileStream fs = new FileStream("data\\SHOP_NAME.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("item = ") && strLine.Substring(0, CFormat.StringLength("item = ")) == "item = ") { ShopName_Str shopName; string tmp = strLine.Split(new string[] { "item = " }, StringSplitOptions.RemoveEmptyEntries)[0]; string id = tmp.Split(',')[0]; string name = tmp.Split(',')[1]; shopName.id = CFormat.PureString(id); shopName.name = CFormat.PureString(name); m_ShopNameList.Add(shopName); } strLine = null; strLine = reader.ReadLine(); } reader.Close(); fs.Close(); return(true); }
public static bool LoadDropListInfo() { //文件存在 if (!File.Exists("data\\DROPITEM.TXT")) { return(false); } //读取 m_DropList.Clear(); FileStream fs = new FileStream("data\\DROPITEM.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; strLine = strLine.Replace("Item_", "item_");//乱七八糟的Item定义 if (strLine.Contains("drop = ") && strLine.Substring(0, CFormat.StringLength("drop = ")) == "drop = ") { Drop_Str drop; drop.list = new List <Drop_Single_Str>(); string tmp = strLine.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]; var dropList = CFormat.PureString(tmp).Split(','); string id = dropList[0]; drop.id = id; string name = ""; string num = ""; for (int i = 1; i < dropList.Length; i++) { if (dropList[i] != "" && dropList[i] != null) { if (i % 2 == 1) { //name name = dropList[i]; } else { //num num = dropList[i]; Drop_Single_Str single = new Drop_Single_Str(); single.name = name; single.num = num; drop.list.Add(single); } } } m_DropList.Add(drop); } strLine = null; strLine = reader.ReadLine(); } reader.Close(); fs.Close(); return(true); }
public bool LoadArmyInfo() { //文件存在 if (!File.Exists(m_Forder + "\\ARMY.TXT")) { return(false); } //读取 m_ArmyList.Clear(); FileStream fs = new FileStream(m_Forder + "\\ARMY.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; Army_Str army = new Army_Str();; army.code = ""; army.name = ""; army.reborn_delay = ""; army.reborn_range = ""; army.disappear_time = ""; army.list = new List <string>(); army.map = new List <Map_Str>(); bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("[army]") && strLine.Substring(0, CFormat.StringLength("[army]")) == "[army]") { if (get) { //add army m_ArmyList.Add(army); } get = true; army = new Army_Str();; army.code = ""; army.name = ""; army.reborn_delay = ""; army.reborn_range = ""; army.disappear_time = ""; army.list = new List <string>(); army.map = new List <Map_Str>(); } else if (strLine.Contains("code = ") && strLine.Substring(0, CFormat.StringLength("code = ")) == "code = ") { army.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("name = ") && strLine.Substring(0, CFormat.StringLength("name = ")) == "name = ") { army.name = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("reborn_delay = ") && strLine.Substring(0, CFormat.StringLength("reborn_delay = ")) == "reborn_delay = ") { army.reborn_delay = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("reborn_range = ") && strLine.Substring(0, CFormat.StringLength("reborn_range = ")) == "reborn_range = ") { army.reborn_range = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("disappear_time = ") && strLine.Substring(0, CFormat.StringLength("disappear_time = ")) == "disappear_time = ") { army.disappear_time = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("list = ") && strLine.Substring(0, CFormat.StringLength("list = ")) == "list = ") { var lst = CFormat.PureString(strLine.Split('=')[1]).Split(','); foreach (var item in lst) { army.list.Add(item); } } else if (strLine.Contains("map = ") && strLine.Substring(0, CFormat.StringLength("map = ")) == "map = ") { var map = CFormat.PureString(strLine.Split('=')[1]).Split(','); Map_Str _map; _map.id = map[0]; _map.x = map[1]; _map.y = map[2]; army.map.Add(_map); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_ArmyList.Add(army); reader.Close(); fs.Close(); return(true); }
public static bool LoadShopDataList(int level) { string file = ""; if (level == 0) { file = "data\\SHOPDATA.TXT"; } else if (level == 1) { file = "data\\SHOPDATA2.TXT"; } else if (level == 2) { file = "data\\SHOPDATA3.TXT"; } else if (level == 3) { file = "data\\SHOPDATA4.TXT"; } else { return(false); } //文件存在 if (!File.Exists(file)) { return(false); } //读取 m_ShopDataList[level].Clear(); FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; ShopData_Str shopData; shopData.code = ""; shopData.ShopName = ""; shopData.more = new List <string>(); shopData.ShopType = ""; shopData.list = new List <string>(); bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; strLine = strLine.Replace("Item_", "item_");//乱七八糟的Item定义 if (strLine.Contains("[shop]")) { if (get) { //add army m_ShopDataList[level].Add(shopData); } get = true; shopData.code = ""; shopData.ShopName = ""; shopData.more = new List <string>(); shopData.ShopType = ""; shopData.list = new List <string>(); } else if (strLine.Contains("code")) { shopData.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("ShopName")) { shopData.ShopName = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("ShopType")) { shopData.ShopType = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("Item")) { var lst = CFormat.PureString(strLine.Split('=')[1]).Split(','); foreach (var item in lst) { if (item != "") { shopData.list.Add(item); } } } else if (strLine.Contains("=")) { shopData.more.Add(strLine); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_ShopDataList[level].Add(shopData); reader.Close(); fs.Close(); return(true); }
public static bool LoadItemModeInfo() { //文件存在 if (!File.Exists("data\\ITEMMODESHOP.TXT")) { return(false); } //读取 m_ItemModeList.Clear(); FileStream fs = new FileStream("data\\ITEMMODESHOP.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; Item_Mode_Str mode = new Item_Mode_Str(); mode.code = ""; mode.type = ""; mode.item_id = ""; mode.item_number = ""; mode.cost = ""; mode.item_attr = ""; bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; strLine = strLine.Replace("Item_", "item_");//乱七八糟的Item定义 if (strLine.Contains("[item_shop]") && strLine.Substring(0, CFormat.StringLength("[item_shop]")) == "[item_shop]") { if (get) { //add army m_ItemModeList.Add(mode); } get = true; mode = new Item_Mode_Str(); mode.code = ""; mode.type = ""; mode.item_id = ""; mode.item_number = ""; mode.cost = ""; mode.item_attr = ""; } else if (strLine.Contains("code = ") && strLine.Substring(0, CFormat.StringLength("code = ")) == "code = ") { mode.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("type = ") && strLine.Substring(0, CFormat.StringLength("type = ")) == "type = ") { mode.type = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("item_id = ") && strLine.Substring(0, CFormat.StringLength("item_id = ")) == "item_id = ") { mode.item_id = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("item_number = ") && strLine.Substring(0, CFormat.StringLength("item_number = ")) == "item_number = ") { mode.item_number = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("cost = ") && strLine.Substring(0, CFormat.StringLength("cost = ")) == "cost = ") { mode.cost = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("item_attr = ") && strLine.Substring(0, CFormat.StringLength("item_attr = ")) == "item_attr = ") { mode.item_attr = CFormat.PureString(strLine.Split('=')[1]); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_ItemModeList.Add(mode); ReSort(); reader.Close(); fs.Close(); return(true); }
public bool LoadPlayerList() { //文件存在 if (!File.Exists(m_Forder + "\\PLAYERS.TXT")) { return(false); } //读取 m_PlayerList.Clear(); FileStream fs = new FileStream(m_Forder + "\\PLAYERS.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; Player_Str player; player.code = ""; player.name = ""; player.appear_ratio = ""; player.drop = ""; player.drop_enable = true; player.drop_mission = ""; player.more = new List <string>(); bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("[character]") && strLine.Substring(0, CFormat.StringLength("[character]")) == "[character]") { if (get) { //add army m_PlayerList.Add(player); } get = true; player.code = ""; player.name = ""; player.drop = ""; player.drop_enable = true; player.drop_mission = ""; player.appear_ratio = ""; player.more = new List <string>(); } else if (strLine.Contains("code = ") && strLine.Substring(0, CFormat.StringLength("code = ")) == "code = ") { player.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("name = ") && strLine.Substring(0, CFormat.StringLength("name = ")) == "name = ") { player.name = CFormat.PureString(strLine.Split('=')[1]); m_lastNameId = int.Parse(player.name); } else if (strLine.Contains("appear_ratio = ") && strLine.Substring(0, CFormat.StringLength("appear_ratio = ")) == "appear_ratio = ") { player.appear_ratio = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("drop = ") && strLine.Substring(0, CFormat.StringLength("drop = ")) == "drop = ") { player.drop = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("drop_mission = ") && strLine.Substring(0, CFormat.StringLength("drop_mission = ")) == "drop_mission = ") { player.drop_mission = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("=")) { player.more.Add(strLine); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_PlayerList.Add(player); reader.Close(); fs.Close(); return(true); }
public bool LoadItemList() { //文件存在 if (!File.Exists(m_Forder + "\\ITEM.TXT")) { return(false); } //读取 m_ItemList.Clear(); FileStream fs = new FileStream(m_Forder + "\\ITEM.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; Item_Str item; item.code = ""; item.name = ""; item.cost = ""; item.sell = ""; item.help_string = ""; item.type = ""; item.use_magic_id = ""; item.more = new List <string>(); bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; strLine = strLine.Replace("Item_", "item_");//乱七八糟的Item定义 if (strLine.Contains("[item]") && strLine.Contains("[item]")) { if (get) { //add army m_ItemList.Add(item); if (item.use_magic_id != "" && item.type.Contains("itemTypeLetto")) { m_ItemLettoList.Add(item); } } get = true; item.code = ""; item.name = ""; item.cost = ""; item.sell = ""; item.help_string = ""; item.type = ""; item.use_magic_id = ""; item.more = new List <string>(); } else if (strLine.Contains("code = ") && strLine.Substring(0, CFormat.StringLength("code =")) == "code =") { item.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("type = ") && strLine.Substring(0, CFormat.StringLength("type =")) == "type =") { item.type = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("use_magic_id = ") && strLine.Substring(0, CFormat.StringLength("use_magic_id =")) == "use_magic_id =") { item.use_magic_id = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("name = ") && strLine.Substring(0, CFormat.StringLength("name =")) == "name =") { item.name = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("cost = ") && strLine.Substring(0, CFormat.StringLength("cost =")) == "cost =") { item.cost = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("sell = ") && strLine.Substring(0, CFormat.StringLength("sell =")) == "sell =") { item.sell = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("help_string = ") && strLine.Substring(0, CFormat.StringLength("help_string =")) == "help_string =") { item.help_string = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("=")) { item.more.Add(strLine); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_ItemList.Add(item); reader.Close(); fs.Close(); return(true); }