Beispiel #1
0
        public static void ResolveDic(Table rewardTable)
        {
            const string itemGroupStr = "item_group";
            const string keyStr       = "key";
            const string weightStr    = "weight";

            _RewardDic = new Dictionary <string, RandomRewardGenerator>();
            var    tempList = new List <RewardUnit>();
            string curKey   = null;

            foreach (var row in rewardTable)
            {
                string key = row[keyStr];
                if (curKey != key)
                {
                    _RewardDic.Add(curKey, new RandomRewardGenerator(tempList));
                    curKey = key;
                    tempList.Clear();
                }

                if (!ItemGroup.TryParse(row[itemGroupStr], out var itemGroup))
                {
                    throw new Exception("数据转换失败");
                }
                tempList.Add(new RewardUnit(itemGroup, row[weightStr]));
            }
            if (curKey != null)
            {
                _RewardDic.Add(curKey, new RandomRewardGenerator(tempList));
            }
        }