using CommonAI.Data; using CommonAI.Zone.Formula; using CommonLang.Log; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CommonAI.data { public abstract class BattleFunction { protected static Logger log = LoggerFactory.GetLogger("BattleFunction"); private static BattleFunction mInstance = null; public static void SetFactory(BattleFunction factory) { mInstance = factory; } public static BattleFunction GetInstance() { return mInstance; } protected virtual void LogError(string text = null) { string error = string.Format("特殊事件错误:未找到事件脚本【{0}】", text);// + new System.Diagnostics.StackTrace().ToString(); log.Error(error); } // 战斗服触发 public abstract int TriggrBattleFunction(int functionID, IVirtualUnit target, IVirtualUnit sender); // 传参,一般游戏服触发 public abstract int TriggrBattleFunction(int functionID, IVirtualUnit target, int value1, int value2, int value3, int value4, int value5, int value6); } public abstract class BattleFunctionEvent { //绑定配置ID private int mBindConfigID = 0; //绑定buffID protected int mBuff_ID = 0; protected static Logger log = LoggerFactory.GetLogger("BattleFunctionEvent"); public virtual int GetEventID() { return 0; } //获取绑定的配置文件id public virtual int GetConfigID() { return mBindConfigID == 0 ? this.GetEventID() : mBindConfigID; } public virtual bool Init(int configID, int buffID) { this.mBindConfigID = configID; this.mBuff_ID = buffID; if (OnInit() == false) { LogError(); return false; } return true; } protected void SetBindBuffID(int buffId) { if(buffId > 0) { this.mBuff_ID = buffId; } } public int GetBindBuffID() { return this.mBuff_ID; } protected virtual bool OnInit() { return true; } // 战斗服触发 public virtual int TriggerEvent(IVirtualUnit target, IVirtualUnit sender) { return 0; } // 传参,一般游戏服触发 public virtual int TriggerEvent(IVirtualUnit target, int value1, int value2, int value3, int value4, int value5, int value6) { return 0; } public virtual object CreateParams() { return null; } protected virtual void LogError(string text = null) { string txt = null; if (text != null) { txt = string.Format("特殊事件【{0}】配置错误, 请检查编辑器或表格:{1}", GetConfigID(), text); log.Error(txt); } else { txt = string.Format("特殊事件【{0}】配置错误, 请检查编辑器或表格", GetConfigID()); log.Error(txt); } //throw new Exception(txt); } } public interface IPlayerCache { bool AddTalentValue(int value); bool UseTalentValue(int value); bool Refresh(bool notify = true); void MarkValid(bool isValid); int GetTalentValue(); byte GetTalentLv(); } public interface ICardModule { ICardData GetCardInterface(); } public interface ICardData { CardType GetCardData(int index); } }