using System.Collections.Generic; using System.Linq; namespace ET { public partial class SkillUpConfigCategory { public Dictionary> AllUnlockedSkillsOfLevel = new Dictionary>(); private int[] CheckToGetUnLockSkillList(int[] levelUnlockParameter) { if (levelUnlockParameter.Length == 1 && levelUnlockParameter[0] == 0) { return null; } return levelUnlockParameter; } public override void AfterEndInit() { foreach (var skillUpConfig in this.GetAll()) { List unLockSkillList = new List(); unLockSkillList.Add(skillUpConfig.Value.Level1UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level2UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level3UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level4UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level5UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level6UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level7UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level8UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level9UnlockParameter); unLockSkillList.Add(skillUpConfig.Value.Level10UnlockParameter); Dictionary unlockSkillDict = new Dictionary(); for (int i = 0; i < 10; i++) { var list = CheckToGetUnLockSkillList(unLockSkillList[i]); int[] preList = null; if (unlockSkillDict.ContainsKey(i)) { preList = unlockSkillDict[i]; } int[] merge; if (list != null) { if (preList != null) { merge = new int [list.Length + preList.Length]; preList.CopyTo(merge, 0); list.CopyTo(merge, preList.Length); } else { merge = new int[list.Length]; list.CopyTo(merge, 0); } unlockSkillDict.Add(i + 1, merge); } else { if (preList != null) { merge = new int[preList.Length]; preList.CopyTo(merge, 0); unlockSkillDict.Add(i + 1, merge); } } } AllUnlockedSkillsOfLevel.Add(skillUpConfig.Key, unlockSkillDict); } } /// /// 获得技能在某个解锁等级下解锁的所有子技能 /// /// 技能解锁的Id /// 解锁等级(从1级开始) /// public int[] GetUnLockedSkillsOfLevel(int skillId, int level) { if (!this.AllUnlockedSkillsOfLevel.ContainsKey(skillId)) { return null; } var dict = this.AllUnlockedSkillsOfLevel[skillId]; if (!dict.ContainsKey(level)) { return null; } return dict[level]; } } }