示例#1
0
 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);
 }
示例#2
0
        public static bool MdfyItemModeInfo(string code, Item_Mode_Str newMode)
        {
            for (int i = 0; i < m_ItemModeList.Count; i++)
            {
                if (CFormat.ToSimplified(m_ItemModeList[i].code) == code)
                {
                    m_ItemModeList[i] = newMode;
                    ReSort();
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        public static bool GetItemModeInfo(string code, out Item_Mode_Str newMode)
        {
            foreach (var mode in m_ItemModeList)
            {
                if (CFormat.ToSimplified(mode.code) == code)
                {
                    newMode = mode;
                    return(true);
                }
            }
            newMode = new Item_Mode_Str();

            return(false);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }