Example #1
0
 public TextSys()
 {
     _Dic = (
         from row in DataBaseSys.GetTable(Config.TextTableName)
         select new { key = (string)row["key"], text = (string)row["text"] })
            .ToDictionary(x => x.key, x => x.text);
 }
Example #2
0
        public TextSys()
        {
            var dic = (
                from row in DataBaseSys.GetTable("text")
                select new { key = (string)row["key"], text = (string)row["text"] })
                      .ToDictionary(x => x.key, x => x.text);

            SetStrValues(dic);
        }
Example #3
0
        /// <summary>
        /// 用于初始化对象
        /// </summary>
        /// <returns>需要加入核心生命周期的继承了IBaseSys的对象</returns>
        public static IBaseSys[] Init()
        {
            // 在这里进行初始化
            RandomRewardGenerator.ResolveDic(DataBaseSys.GetTable("database/normal/reward"));
            CtrlKeys.Init();

            return(new IBaseSys[]
            {
                // 添加新的系统
                new LuaSys(),
                new CampSys(),
            });
        }
Example #4
0
        public static bool CreateSaveDir(string saveName)
        {
            var savePath = Paths.DocumentPath.PCombine(saveName);

            if (Directory.Exists(savePath))
            {
                return(false);
            }

            var dirs = (
                from row in DataBaseSys.GetTable("directory_struct")
                where row["id"] == "save"
                select row).ToArray();

            var stack = new Stack <string>();

            stack.Push("");

            var result = new List <string>();

            const string name      = "name";
            const string extension = "extension";
            const string parent    = "parent";

            while (stack.Count != 0)
            {
                var node = stack.Pop();

                foreach (var item in dirs.Where(x => x[parent] == Path.GetFileName(node)))
                {
                    stack.Push(node + Path.DirectorySeparatorChar + item[name] + item[extension]);
                }
                result.Add(node);
            }


            foreach (var item in result)
            {
                if (Path.GetExtension(item) == "")
                {
                    Directory.CreateDirectory(savePath + item);
                }
                else
                {
                    File.Create(savePath + item).Close();
                }
            }

            return(true);
        }
Example #5
0
        private static void QueryDicFromTable(Dictionary <int, ItemInfo> dic, string tablePath)
        {
            var pros = typeof(ItemInfo)
                       .GetProperties()
                       .Where(x => DataBaseSys.AvailableDataType.Contains(x.PropertyType))
                       .ToArray();

            const string idStr       = "Id";
            ItemInfo     defaultInfo = null;
            var          stringType  = typeof(string);

            foreach (var row in DataBaseSys.GetTable(tablePath))
            {
                var info = new ItemInfo();
                foreach (var field in pros)
                {
                    var data = row[field.Name].Data;

                    if (defaultInfo != null && (data == null || field == stringType && (data as string).IsNullOrEmpty()))
                    {
                        field.SetValue(info, field.GetValue(defaultInfo));
                        continue;
                    }

                    field.SetValue(info, data);
                }

                //HandleSpecialData
                info.Id = new ItemId(row[idStr]);

                if (defaultInfo == null)
                {
                    defaultInfo = info;
                }
                else
                {
                    dic.Add(info.Id, info);
                }
            }
        }