123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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
- {
- /// <summary>
- /// FileName: XmdsFormula.cs
- /// Author: Alex.Yu
- /// Corporation:...
- /// Description:
- /// DateTime: 2015/4/22 19:31:22
- /// </summary>
- 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<FileInfo> 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<XCSVMeta> xls2csv, List<FileInfo> savedfiles, AtomicFloat progress_percent)
- {
- base.OnEditorPluginSaved(datas, xls2csv, savedfiles, progress_percent);
- }
- // public override void OnEditorPluginSaved(EditorTemplatesData datas, List<XmlDocument> xls2csv, DirectoryInfo xls_dir, List<FileInfo> 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();
- }
- }
- }
|