Beispiel #1
0
        /// <summary>
        /// 从英雄数组中获取所有技能模型
        /// </summary>
        /// <returns></returns>
        public static SkillModel[] GetSkillByHeros(DtoHero[] heros)
        {
            // 创建技能模型的字典
            Dictionary <int, SkillModel> dict = new Dictionary <int, SkillModel>();
            // 普通攻击
            SkillModel model;

            SkillDict.TryGetValue(ServerConfig.SkillId, out model);
            dict.Add(ServerConfig.SkillId, model);
            // 遍历英雄技能
            foreach (DtoHero hero in heros)
            {
                foreach (DtoSkill skill in hero.Skills)
                {
                    if (skill == null)
                    {
                        continue;
                    }

                    SkillDict.TryGetValue(skill.Id, out model);
                    if (model == null || dict.ContainsKey(skill.Id))
                    {
                        continue;
                    }

                    dict.Add(skill.Id, model);
                }
            }
            // 将字典转为数组
            SkillModel[] array = new SkillModel[dict.Count];
            int          i     = 0;

            foreach (SkillModel item in dict.Values)
            {
                array[i++] = item;
            }
            return(array);
        }
Beispiel #2
0
        // 创建技能
        public static void CreateSkill(int id, string name, string desc, SkillLevelModel[] lvData)
        {
            SkillModel skill = new SkillModel(id, name, desc, lvData);

            SkillDict.Add(id, skill);
        }