using CommonAI.Zone; using CommonAI.Zone.Instance; using CommonAI.Zone.Formula; using CommonLang; using CommonLang.Concurrent; using CommonLang.IO; using CommonLang.Log; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; using CommonAI.ZoneClient; using XmdsCommonServer.Plugin.Units; using CommonAI.Zone.ZoneEditor; using System.Xml; using CommonLang.XCSV; using XmdsCommonServer.Plugin.Scene; using XmdsCommonServer.Plugin.Quest; using XmdsCommonServer.XLS.Data; using CommonAI.data; using CommonLang.Property; using CommonAI.Data; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; namespace XmdsCommonServer.Plugin { /// /// FileName: XmdsFormula.cs /// Author: Alex.Yu /// Corporation:... /// Description: /// DateTime: 2015/4/22 19:31:22 /// public class XmdsFormula : XmdsClientFormula { protected static Logger log = LoggerFactory.GetLogger("XmdsFormula"); public XmdsFormula() { } public override void BindLogger(Logger log) { XmdsVirtual.log = log; } public override void OnEditorSaving( CommonAI.Zone.ZoneEditor.EditorTemplatesData datas, DirectoryInfo data_root, List savedfiles, AtomicFloat progress_percent) { //File.WriteAllText(data_root + "\\sample_skills.csv", XmdsBattleSkill.GenSampleSkillConfig(), CUtils.UTF8); //progress_percent.GetAndSet(1f); //savedfiles.Add(new FileInfo(data_root.FullName + "\\skills.csv")); base.OnEditorSaving(datas, data_root, savedfiles, progress_percent); } public override void OnEditorPluginSaved(EditorTemplatesData datas, List xls2csv, List savedfiles, AtomicFloat progress_percent) { base.OnEditorPluginSaved(datas, xls2csv, savedfiles, progress_percent); } // public override void OnEditorPluginSaved(EditorTemplatesData datas, List xls2csv, DirectoryInfo xls_dir, List savedfiles, AtomicFloat progress_percent) // { // base.OnEditorPluginSaved(datas, xls2csv, xls_dir, savedfiles, progress_percent); // } public override void InitPluginsData(CommonAI.Zone.ZoneEditor.EditorTemplates data_root) { BindLogger(LoggerFactory.GetLogger("XmdsCommonWin32")); //数值配置初始化. new XmdsGameConfig(); //技能数值公式管理. //XmdsSkillDataMgr.Init(data_root.DataRoot); //加载怪物能力配置表. string sheetBasePath = data_root.DataRoot + "/data_config/"; XmdsDataMgr.GetInstance().LoadMonsterData(sheetBasePath + "Monster.xlsx"); XmdsDataMgr.GetInstance().LoadMonsterDynamicData(sheetBasePath + "MonsterDynamicProp.xlsx"); //技能配置. XmdsDataMgr.GetInstance().LoadSkillCfgData(sheetBasePath + "SkillData.xlsx"); //NPC配置. XmdsDataMgr.GetInstance().LoadNPCData(sheetBasePath + "NPCData.xlsx"); //斩妖暴击配置. XmdsDataMgr.GetInstance().LoadZhanYaoData(sheetBasePath + "BUFF.xlsx"); //随机怪物技能 XmdsDataMgr.GetInstance().LoadMonsterSkillInfo(sheetBasePath + "BattleServerConfig.xlsx"); //读取战斗服配置 XmdsDataMgr.GetInstance().LoadBSConfig(sheetBasePath + "BattleServerConfig.xlsx"); //buff配置数据 //技能配置. XmdsDataMgr.GetInstance().LoadBuffCfgData(sheetBasePath + "BuffData.xlsx"); //随机名字库 XmdsDataMgr.GetInstance().LoadRandomNameData(sheetBasePath + "RandomName.xlsx"); XmdsDataMgr.GetInstance().LoadMountainKingData(sheetBasePath + "MountainKingConfig.xlsx"); //反射初始化XmdsSkill并读取配置表数据. XmdsBattleSkill.Init(data_root.Templates); //反射初始化场景扩展. XmdsSceneFactory.Init(); //反射任务脚本 QuestScriptManager.Init(); base.InitPluginsData(data_root); this.InitRelationModule(); //初始化一些基本的伤害配置脚本 XmdsDamageCalculator.Init(); } //加载技能配置. //private void LoadSkillConfig(string path) //{ // string skillcfgpath = Resource.FormatPath(path); // string text = Resource.LoadAllText(skillcfgpath); // if ( text != null ) // { // XmdsBattleSkill.LoadSkillConfig(text); // } // else // { // throw new Exception("无法加载技能配置文件 :" + skillcfgpath); // } //} public override int OnHit(InstanceUnit attacker, AttackSource source, InstanceUnit targget) { XmdsVirtual src_prop = attacker.Virtual as XmdsVirtual; XmdsVirtual dst_prop = targget.Virtual as XmdsVirtual; return dst_prop.OnHit(src_prop as XmdsVirtual, source); } public override void OnUnitDead(InstanceUnit targget, InstanceUnit killer) { XmdsVirtual src_prop = targget.Virtual as XmdsVirtual; if(killer == null) { src_prop.OnUnitDead(null); } else { XmdsVirtual dst_prop = killer.Virtual as XmdsVirtual; src_prop.OnUnitDead(dst_prop); dst_prop.OnKillUnit(src_prop); } } public override void OnUnitRemoved(InstanceUnit unit) { XmdsVirtual prop = unit.Virtual as XmdsVirtual; prop.OnUnitRemoved(); } public override void OnTriggerStart(InstanceUnit unit, InstanceUnit.TriggerState trigger, InstanceUnit target) { XmdsVirtual src_prop = unit.Virtual as XmdsVirtual; XmdsVirtual dst_prop = target.Virtual as XmdsVirtual; (dst_prop).OnTriggerStart(trigger, dst_prop); } public override void OnUnitHandleNetMessage(InstanceUnit unit, ObjectAction action) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; (unit_prop).OnHandleNetMessage(action); } public override void OnBuffBegin(InstanceUnit unit, InstanceUnit.BuffState buff, InstanceUnit sender) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; XmdsVirtual sender_prop = sender.Virtual as XmdsVirtual; (unit_prop).OnBuffBegin(buff, sender_prop); } public override void OnBuffUpdate(InstanceUnit unit, InstanceUnit.BuffState buff, int time) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; (unit_prop).OnBuffUpdate(buff, time); } public override void OnBuffEnd(InstanceUnit unit, InstanceUnit.BuffState buff, string result, bool replace) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; (unit_prop).OnBuffEnd(buff, result, replace); } public override bool TryLaunchSkill(InstanceUnit unit, InstanceUnit.SkillState skill, ref InstanceUnit.LaunchSkillParam param) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; return (unit_prop).TryLaunchSkill(skill, ref param); } public override bool TriggerPetSkill(InstanceUnit unit, InstanceUnit.SkillState skill, ref InstanceUnit.LaunchSkillParam param) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; if((unit_prop).DispatchTriggerPetSkillEvent(ref skill, ref param)) { skill.StartCD(); } return true; } public override bool TryLaunchSpell(InstanceUnit launcher, LaunchSpell launch, ref SpellTemplate spell, out JSGCreateSpellData createData, ref float startX, ref float startY) { XmdsVirtual unit_prop = launcher.Virtual as XmdsVirtual; return (unit_prop).TryLaunchSpell(launch, ref spell, out createData, ref startX, ref startY); } public override bool TryAddBuff(InstanceUnit unit, InstanceUnit sender, ref BuffTemplate buff, out object tag) { XmdsVirtual owner_prop = unit.Virtual as XmdsVirtual; XmdsVirtual sender_prop = sender.Virtual as XmdsVirtual; return (sender_prop).TrySendBuff(ref buff, owner_prop, out tag); } public override void SendAddBuffEvent(InstanceUnit unit, InstanceUnit sender, BuffTemplate buff) { XmdsVirtual owner_prop = unit.Virtual as XmdsVirtual; XmdsVirtual sender_prop = sender.Virtual as XmdsVirtual; sender_prop.SendAddBuffEvent(owner_prop, buff); } public override bool TrySummonUnit(InstanceUnit owner, SummonUnit summon, ref UnitInfo summonUnit, ref string name) { return true; } public override void OnUpdateTriggerSkill(InstanceUnit unit, int intervalMS, bool slowRefresh) { XmdsVirtual unit_prop = unit.Virtual as XmdsVirtual; if ( unit_prop == null ) { //throw new Exception("Xmds virtual is null : " + unit.Info); Console.WriteLine("Xmds virtual is null : " + unit.Info); } else { unit_prop.OnUpdateTriggerSkill(intervalMS, slowRefresh); } } // 有关联性功能加载 private void InitRelationModule() { // 事件脚本功能扩展 XmdsBattleSkill.loadExtendFuntionEvent(); } } }