using CommonAI.Zone; using CommonAI.Zone.Instance; using CommonAI.Zone.ZoneEditor; using CommonLang; using CommonLang.IO; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using XmdsCommon.EditorData; using XmdsCommon.Plugin; using XmdsCommonServer.XLS; using XmdsCommonServer.XLS.Data; namespace XmdsCommonServer.Plugin { /// /// FileName: XmdsDataMgr.cs /// Author: Alex.Yu /// Corporation:... /// Description: Xmds配置数据管理类. /// DateTime: 2015/7/7 18:35:41 /// public class XmdsDataMgr { private static XmdsDataMgr mInstance = null; private XLSMonsterDataLoader mMonsterDataLoader = null; public XLSMonsterDynamicLoader mMonsterDynamicLoader = null; private XLSSkillCfgLoader mXLSSkillCfgLoader = null; private XLSNPCDataLoader mXLSNPCDataLoader = null; private XLSRandomMonsterSkillLoader mXLSRandomMonsterskillLoader = null; private XLSBSConfigLoader mXLSBSConfigLoader = null; //buff配置表 private XLSBuffConfigLoader mXLSBuffConfigLoader = null; //随机名字 private XLSRandomNameLoader mXLSRandomNameLoader = null; private XLSZhanYaoDataLoader mXLSZhanYaoDataLoader = null; //场景,山大王对应配置 private XLSMountainKingConfigLoader mMountainKingConfigLoader = null; private XmdsDataMgr() { mInstance = this; } public static XmdsDataMgr GetInstance() { if ( mInstance == null ) { new XmdsDataMgr(); } return mInstance; } #region 怪物能力配置. /// /// 加载怪物配置数据. /// /// public void LoadMonsterData(string path) { Stopwatch sw = Stopwatch.StartNew(); mMonsterDataLoader = new XLSMonsterDataLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadMonsterData usetime {0}", sw.ElapsedMilliseconds); } public void LoadMonsterDynamicData(string path) { Stopwatch sw = Stopwatch.StartNew(); mMonsterDynamicLoader = new XLSMonsterDynamicLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadMonsterDynamicData usetime {0}", sw.ElapsedMilliseconds); } public void LoadMountainKingData(string path) { Stopwatch sw = Stopwatch.StartNew(); mMountainKingConfigLoader = new XLSMountainKingConfigLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadMountainKingData usetime {0}", sw.ElapsedMilliseconds); } /// /// 获取怪物能力. /// /// /// /// /// /// public MonsterData GetMonsterData(string sceneType, int tempID, Random random, bool needFormat = true) { MonsterData ret = null; if ( mMonsterDataLoader != null ) { ret = mMonsterDataLoader.GetMonsterAbility(sceneType, tempID, random,needFormat); } return ret; } public MonsterProp GetSingleMonsterProp(int level,int type) { MonsterProp ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetSingleMonsterProp(level,type); } return ret; } public MonsterProp GetMultipleMonsterProp(int level, int type) { MonsterProp ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetMultipleMonsterProp(level, type); } return ret; } public OrigData GetOrigData(int level) { OrigData ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetOrigData(level); } return ret; } public TowerMonsterRatio GetTowerMonsterRatio(int floor) { TowerMonsterRatio ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetTowerMonsterRatio(floor); } return ret; } public TowerMonsterRatio GetAbyssMonsterRatio(int floor) { TowerMonsterRatio ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetAbyssMonsterRatio(floor); } return ret; } public GuildBossRatio GetGuildBossRatio(int bossLv) { GuildBossRatio ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetGuildBossRatio(bossLv); } return ret; } public UserDefineConfig GetUserDefineConfig(int type) { UserDefineConfig ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetUserDefineConfig(type); } return ret; } public DungeonMonsterRatio GetDungeonMonsterRatio(int type) { DungeonMonsterRatio ret = null; if (mMonsterDynamicLoader != null) { ret = mMonsterDynamicLoader.GetDungeonMonsterRatio(type); } return ret; } public MonsterData GetSummonMonsterData(string sceneType, int tempID, int lv, Random random) { MonsterData ret = null; if (mMonsterDataLoader != null) { ret = mMonsterDataLoader.GetSummonMonsterAbility(sceneType, tempID, lv, random); } return ret; } #endregion #region 技能数据配置. public void LoadSkillCfgData(string path) { Stopwatch sw = Stopwatch.StartNew(); mXLSSkillCfgLoader = new XLSSkillCfgLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadSkillCfgData usetime {0}", sw.ElapsedMilliseconds); } public void LoadBuffCfgData(string path) { Stopwatch sw = Stopwatch.StartNew(); mXLSBuffConfigLoader = new XLSBuffConfigLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadBuffCfgData usetime {0}", sw.ElapsedMilliseconds); } public void LoadRandomNameData(string path) { Stopwatch sw = Stopwatch.StartNew(); mXLSRandomNameLoader = new XLSRandomNameLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadBuffCfgData usetime {0}", sw.ElapsedMilliseconds); } public XmdsSkillData GetXmdsSkillData(int skillid) { XmdsSkillData ret = null; if ( mXLSSkillCfgLoader != null ) { ret = mXLSSkillCfgLoader.GetSkillData(skillid); } return ret; } public BuffConfig GetBuffConfigData(int triggerID) { if (mXLSBuffConfigLoader != null) { return mXLSBuffConfigLoader.GetBuffData(triggerID); } return null; } public HashMap GetBuffConfigDatas() { if (mXLSBuffConfigLoader != null) { return mXLSBuffConfigLoader.GetAllDatas(); } return null; } #endregion #region NPC数据配置. public void LoadNPCData(string path) { Stopwatch sw = Stopwatch.StartNew(); mXLSNPCDataLoader = new XLSNPCDataLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadNPCData usetime {0}", sw.ElapsedMilliseconds); } public NPCData GetNPCData(int templateID, int lv) { NPCData ret = null; if ( mXLSNPCDataLoader != null ) { ret = mXLSNPCDataLoader.GetNPCAbility(templateID, lv); } return ret; } public void LoadZhanYaoData(string path) { Stopwatch sw = Stopwatch.StartNew(); mXLSZhanYaoDataLoader = new XLSZhanYaoDataLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadNPCData usetime {0}", sw.ElapsedMilliseconds); } public bool IsZhanYaoCrit(InstanceUnit unit, int bossLevel, int level, int curHitNums, ref int outStateExt) { ZhanYaoData data = mXLSZhanYaoDataLoader.GetZhanYaoData(level); if(data == null || bossLevel > data.Zhanyao_Data1) { return false; } outStateExt = data.Zhanyao_CHD; if (data.Zhanyao_maxtime >= 0 && curHitNums >= data.Zhanyao_maxtime) { return true; } else if (unit.RandomN.Next(10000) < data.Zhanyao_CHC) { return true; } return false; } public void LoadMonsterSkillInfo(String path) { Stopwatch sw = Stopwatch.StartNew(); mXLSRandomMonsterskillLoader = new XLSRandomMonsterSkillLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadNPCData usetime {0}", sw.ElapsedMilliseconds); } public void LoadBSConfig(String path) { Stopwatch sw = Stopwatch.StartNew(); mXLSBSConfigLoader = new XLSBSConfigLoader(path); sw.Stop(); XmdsVirtual.FormatLog("LoadBSConfig usetime {0}", sw.ElapsedMilliseconds); } public MonsterSkills GetMonsterSkillInfo(int monsterId) { MonsterSkills ret = null; if (mXLSRandomMonsterskillLoader != null) { ret = mXLSRandomMonsterskillLoader.GetMonsterSkillInfo(monsterId); } return ret; } public MonsterSkills GetMonsterSkillInfo() { return mXLSRandomMonsterskillLoader.GetMonsterSkillInfo(); } //获得boss随机主动技能数 public int GetBossComActiveNum() { return this.mXLSSkillCfgLoader.GetBossComActiveNum(); } //获得boss被动技能数 public int GetBossComPassiveNum() { return this.mXLSSkillCfgLoader.GetBossComPassiveNum(); } //随机获得一个boss主动技能 public XmdsSkillData GetBossRandomActiveSkill(Random random) { return this.mXLSSkillCfgLoader.GetBossRandomActiveSkill(random); } //随机获得一个boss被动技能 public XmdsSkillData GetBossRandomPassiveSkill(Random random, XmdsSkillData[] hasList) { return this.mXLSSkillCfgLoader.GetBossRandomPassiveSkill(random, hasList); } //多人深渊秘境,怪物数值加成 public AbyssMutilAddition GetAbyssMutilAddition() { return this.mXLSBSConfigLoader.GetMutilAbyssAddition(); } public string GetRanomName() { return this.mXLSRandomNameLoader.GetRanomName(); } /** 获取一个地图的王 */ public int GetMapKingID(int mapID) { return this.mMountainKingConfigLoader == null ? 0 : this.mMountainKingConfigLoader.GetMapKing(mapID); } /** 获得山大王列表 */ public HashSet GetMountainKings() { return this.mMountainKingConfigLoader.GetMountainKings(); } #endregion } }