public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if (ret == LogicStateTickRet.TimeFinish) { return ret; } double effectTickTime = self.GetSkillStateDoubleParam(skillConfig, key_EffectTickTime, self.GetSkillStateIndex(skillInfo)); if (effectTickTime < 0) { self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Effect effectTickTime< 0".F(self.GetID(), self.GetSkillID(skillInfo))); return LogicStateTickRet.TimeFinish; } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); var leftTickTime = self.GetSkillDoubleParam(skillInfo, key_ticlLeftTime_SkillInfo); if (leftTickTime - self.GetSkillStateTime(skillInfo) >= effectTickTime) { self.SetSkillDoubleParam(skillInfo, leftTickTime - effectTickTime, key_ticlLeftTime_SkillInfo); self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Effect".F(self.GetID(), self.GetSkillID(skillInfo))); ret = LogicStateTickRet.OnEffect; } else if (self.GetSkillStateTime(skillInfo) <= 0) { ret = LogicStateTickRet.NextState; self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } else { ret = LogicStateTickRet.None; } return ret; }
/// <summary> /// 单人技能的tick,这个需要手动调用 /// </summary> /// <param name="self"></param> public static void Tick_Battle(SkillObj self) { if (self.IsDead()) { return; } var skillList = self.GetSkillList(true); var buffList = self.GetBuffList(true); var CDKeyList = self.GetCDKeyList(); //buff if (buffList != null) { foreach (var buffInfo in buffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, self); if (buffLogic != null) { int buffId = self.GetBuffID(buffInfo); BuffConfig_New buffConfig = self.GetBuffConfig(buffId); buffLogic.Tick(self, buffInfo, buffConfig); } else { self.LogInfo("something error {0}".F(self.GetBuffID(buffInfo))); } } } //技能 if (skillList != null) { foreach (var skillInfo in skillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, self); if (skillLogic != null) { int skillId = self.GetSkillID(skillInfo); SkillConfig_New skillConfig = self.GetSkillConfig(skillId); skillLogic.Tick(self, skillInfo, skillConfig); } else { self.LogInfo("something error2 {0}".F(self.GetSkillID(skillInfo))); } } } //CD if (CDKeyList != null) { foreach (var key in CDKeyList) { self.SetCD(key, self.GetCD(key) - self.GetDeltaTime()); } } }
public override bool InitSkillInfo(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { bool ret = base.InitSkillInfo(self, skillInfo, skillConfig); var targetSelectName = "Range"; var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if (targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); Debug.Assert(false, "targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); return false; } var targetTypeName = "Harm"; var targetType = BattleModule.GetTargetType(targetTypeName); if (targetType == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); Debug.Assert(false, "targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); return false; } var targets = BattleModule.GetTargets(self, targetSelect, targetType, skillInfo, skillConfig).ToList(); if(targets == null || targets.Count <= 0) { return true; } int count = self.GetSkillIntParam(skillConfig, key_SummonCount_SkillConfig); int realCount = 0; int index = 0; foreach (var tar in targets) { if(index < count) { self.SetSkillIntParam(skillInfo, key_SummonTraceTarget_SkillInfo + index++, tar.GetID()); realCount++; } else { break; } } if(index < count) { var tank = targets.OrderBy(t => t.GetHP()).FirstOrDefault(); for (int i = index; i < count; i++) { self.SetSkillIntParam(skillInfo, key_SummonTraceTarget_SkillInfo + i, tank.GetID()); realCount++; } } self.SetSkillIntParam(skillInfo, key_SummonIdx_SkillInfo, 0); ret = true; return ret; }
public static bool IsActionLimited(SkillObj self, ActionLimitType limit) { var skillList = self.GetSkillList(); var buffList = self.GetBuffList(); //buff if (buffList != null) { foreach (var buffInfo in buffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, self); if (buffLogic != null) { int buffId = self.GetBuffID(buffInfo); BuffConfig_New buffConfig = self.GetBuffConfig(buffId); if (buffLogic.IsActionLimited(self, limit, buffInfo, buffConfig)) { return(true); } } else { self.LogInfo("something error {0}".F(self.GetBuffID(buffInfo))); } } } //技能 if (skillList != null) { foreach (var skillInfo in skillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, self); if (skillLogic != null) { int skillId = self.GetSkillID(skillInfo); SkillConfig_New skillConfig = self.GetSkillConfig(skillId); if (skillLogic.IsActionLimited(self, limit, skillInfo, skillConfig)) { return(true); } } else { self.LogInfo("something error2 {0}".F(self.GetSkillID(skillInfo))); } } } return(false); }
/// <summary> /// 使用技能,这个需要手动调用 /// </summary> /// <param name="self"></param> /// <param name="skillId"></param> /// <returns></returns> public static UseSkillRet UseSkill(SkillObj self, int skillId) { UseSkillRet ret = UseSkillRet.Success; if (BattleModule.IsActionLimited(self, ActionLimitType.UseSkill)) { return(UseSkillRet.ActionLimit); } if (self.IsDead()) { return(UseSkillRet.Dead); } //检查特殊状态 if (!self.CanUseSkill(skillId)) { return(UseSkillRet.None); } SkillConfig_New skillConfig = self.GetSkillConfig(skillId); if (skillConfig == null) { return(UseSkillRet.None); } //检查技能消耗 if (!UseSkillCheckDeplete(self, skillConfig)) { return(UseSkillRet.Deplete); } string skillLogicId = self.GetSkillLogicId(skillConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { return(UseSkillRet.None); } SkillLogic skillLogic = SkillLogics[skillLogicId]; if (skillLogic != null) { //检查CD if (!skillLogic.CheckCD(self, skillConfig)) { string key = self.GetSkillCDKey(skillConfig); self.LogInfo("skill:[{0}] CD ing [{1}]:[{2}]".F(self.GetSkillID(skillConfig), key, self.GetCD(key))); return(UseSkillRet.CD); } SkillInfo_New skillInfo = skillLogic.Begin(self, skillConfig); if (skillInfo != null) { skillLogic.BeginCD(self, skillInfo, skillConfig); self.AddSkillList(skillInfo); self.LogInfo("Skill Begin Successed [{0}]".F(skillId)); } else { self.LogInfo("Skill Begin Failed [{0}]".F(skillId)); } } return(ret); }
public override bool InitSkillInfo(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { bool ret = base.InitSkillInfo(self, skillInfo, skillConfig); var targetSelectName = "Range"; var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if (targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); Debug.Assert(false, "targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); return(false); } var targetTypeName = "Harm"; var targetType = BattleModule.GetTargetType(targetTypeName); if (targetType == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); Debug.Assert(false, "targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); return(false); } var targets = BattleModule.GetTargets(self, targetSelect, targetType, skillInfo, skillConfig).ToList(); if (targets == null || targets.Count <= 0) { return(true); } int count = self.GetSkillIntParam(skillConfig, key_SummonCount_SkillConfig); int realCount = 0; int index = 0; foreach (var tar in targets) { if (index < count) { self.SetSkillIntParam(skillInfo, key_SummonTraceTarget_SkillInfo + index++, tar.GetID()); realCount++; } else { break; } } if (index < count) { var tank = targets.OrderBy(t => t.GetHP()).FirstOrDefault(); for (int i = index; i < count; i++) { self.SetSkillIntParam(skillInfo, key_SummonTraceTarget_SkillInfo + i, tank.GetID()); realCount++; } } self.SetSkillIntParam(skillInfo, key_SummonIdx_SkillInfo, 0); ret = true; return(ret); }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if (ret == LogicStateTickRet.TimeFinish) { return ret; } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); if (self.GetSkillStateTime(skillInfo) <= 0) { ret = LogicStateTickRet.NextState; self.LogInfo("ShowEffectSkillState:skillObj[{0}] skill:[{1}] ShowEffectState Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } return ret; }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if(ret == LogicStateTickRet.TimeFinish) { return ret; } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); //self.LogInfo("State [{0}] Time:[{1}]".F(self.GetSkillLogicStateName(skillInfo), self.GetSkillStateTime(skillInfo))); if (self.GetSkillStateTime(skillInfo) <= 0) { self.LogInfo("State [{0}] NowTime fINISH:[{1}]".F(self.GetSkillLogicStateName(skillInfo), self.GetNowTime())); ret = LogicStateTickRet.NextState; self.LogInfo("ChargeState:skillObj[{0}] skill:[{1}] Charge Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } return ret; }
public virtual void BeginCD(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { string key = self.GetSkillCDKey(skillConfig); if (key == null || key.Equals("")) { return ; } double time = self.GetSkillCD(skillConfig); if (time <= 0) { return ; } self.SetCD(key, time); self.NotifySkillInfo(skillInfo, BattleInfoNotifyType.CD_Skill, BattleNotifyTime.TickEnd); self.LogInfo("skill:[{0}] CD Begin [{1}]".F(self.GetSkillID(skillInfo), self.GetCD(key))); return ; }
public virtual void BeginCD(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { string key = self.GetSkillCDKey(skillConfig); if (key == null || key.Equals("")) { return; } double time = self.GetSkillCD(skillConfig); if (time <= 0) { return; } self.SetCD(key, time); self.NotifySkillInfo(skillInfo, BattleInfoNotifyType.CD_Skill, BattleNotifyTime.TickEnd); self.LogInfo("skill:[{0}] CD Begin [{1}]".F(self.GetSkillID(skillInfo), self.GetCD(key))); return; }
private static SkillLogic GetSkillLogic(SkillInfo_New skillInfo, SkillObj logObj) { int skillId = logObj.GetSkillID(skillInfo); SkillConfig_New buffConfig = logObj.GetSkillConfig(skillId); if (buffConfig == null) { logObj.LogInfo("SkillConfig not found skillid[{0}]".F(skillId)); return(null); } string skillLogicId = logObj.GetSkillLogicId(buffConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { logObj.LogInfo("SkillLogic not found skillid[{0}] SkillLogicId[{1}]".F(skillId, skillLogicId)); return(null); } SkillLogic skillLogic = SkillLogics[skillLogicId]; return(skillLogic); }
public virtual bool InitSkillInfo(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { var guid = BattleModule.BattleID; //var time = self.GetSkillTime(skillConfig); var skillId = self.GetSkillID(skillConfig); //var nowTime = self.GetNowTime(); //var activeNum = self.GetActiveNum(skillConfig); self.SetSkillId(skillInfo, skillId); //self.SetSkillTime(skillInfo, time); self.SetSkillGuid(skillInfo, guid); //self.SetSkillStateTime(skillInfo, nowTime); //self.SetSkillSrcObj(skillInfo, self); //self.SetActiveNum(skillInfo, activeNum); self.SetSkillStateIndex(skillInfo, 0); var startLogicStateName = self.GetLogicState(skillConfig, 0); var startLogicState = BattleModule.GetSkillLogicState(startLogicStateName); if (startLogicState == null) { self.LogInfo("startLogicState == null skillId:[{0}] startLogicStateName:[{1}]".F(skillId, startLogicStateName)); return(false); } //init startLogicState.InitSkill(self, skillInfo, skillConfig, 0); startLogicState.InitState(self, skillInfo, skillConfig, 0); var targetSelectName = self.GetTargetSelect(skillConfig); var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if (targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(skillId, targetSelectName)); return(false); } targetSelect.Init(self, skillInfo, skillConfig); return(true); }
public virtual bool InitSkillInfo(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { var guid = BattleModule.BattleID; //var time = self.GetSkillTime(skillConfig); var skillId = self.GetSkillID(skillConfig); //var nowTime = self.GetNowTime(); //var activeNum = self.GetActiveNum(skillConfig); self.SetSkillId(skillInfo, skillId); //self.SetSkillTime(skillInfo, time); self.SetSkillGuid(skillInfo, guid); //self.SetSkillStateTime(skillInfo, nowTime); //self.SetSkillSrcObj(skillInfo, self); //self.SetActiveNum(skillInfo, activeNum); self.SetSkillStateIndex(skillInfo, 0); var startLogicStateName = self.GetLogicState(skillConfig, 0); var startLogicState = BattleModule.GetSkillLogicState(startLogicStateName); if (startLogicState == null) { self.LogInfo("startLogicState == null skillId:[{0}] startLogicStateName:[{1}]".F(skillId, startLogicStateName)); return false; } //init startLogicState.InitSkill(self, skillInfo, skillConfig, 0); startLogicState.InitState(self, skillInfo, skillConfig, 0); var targetSelectName = self.GetTargetSelect(skillConfig); var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if(targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(skillId, targetSelectName)); return false; } targetSelect.Init(self, skillInfo, skillConfig); return true; }
public virtual void Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { if (!CommonCheck(self, skillInfo, skillConfig)) { return; } var logicState = BattleModule.GetSkillLogicState(skillInfo, self); if (logicState == null) { return; } var ret = logicState.Tick(self, skillInfo, skillConfig); switch (ret) { case LogicStateTickRet.TimeFinish: SkillOnEnd(self, skillInfo, skillConfig); break; case LogicStateTickRet.NextState: int index = self.GetSkillStateIndex(skillInfo); string nextStateName = self.GetLogicState(skillConfig, ++index); if (nextStateName == null || nextStateName.Equals("")) { SkillOnEnd(self, skillInfo, skillConfig); return; } var nextLogicState = BattleModule.GetSkillLogicState(nextStateName); if (nextLogicState == null) { self.LogInfo("startLogicState {0} not found".F(nextStateName)); return; } double fixTime = logicState.OnStateChanged(nextStateName, self, skillInfo, skillConfig); self.SetSkillStateIndex(skillInfo, index); nextLogicState.InitState(self, skillInfo, skillConfig, fixTime); self.NotifySkillInfo(skillInfo, BattleInfoNotifyType.ChangeState_Skill, BattleNotifyTime.TickEnd); break; case LogicStateTickRet.OnEffect: //var srcObj = self.GetSkillSrcObj(skillInfo); { var targetSelectName = self.GetTargetSelect(skillConfig); var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if (targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); return; } var targetTypeName = self.GetTargetType(skillConfig); var targetType = BattleModule.GetTargetType(targetTypeName); if (targetType == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); return; } var targets = BattleModule.GetTargets(self, targetSelect, targetType, skillInfo, skillConfig); foreach (var tar in targets) { OnEffect(self, tar, skillInfo, skillConfig); } } break; } }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if (ret == LogicStateTickRet.TimeFinish) { return(ret); } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); if (self.GetSkillStateTime(skillInfo) <= 0) { ret = LogicStateTickRet.NextState; self.LogInfo("ShowEffectSkillState:skillObj[{0}] skill:[{1}] ShowEffectState Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } return(ret); }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if (ret == LogicStateTickRet.TimeFinish) { return(ret); } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); //self.LogInfo("State [{0}] Time:[{1}]".F(self.GetSkillLogicStateName(skillInfo), self.GetSkillStateTime(skillInfo))); if (self.GetSkillStateTime(skillInfo) <= 0) { self.LogInfo("State [{0}] NowTime fINISH:[{1}]".F(self.GetSkillLogicStateName(skillInfo), self.GetNowTime())); ret = LogicStateTickRet.NextState; self.LogInfo("ChargeState:skillObj[{0}] skill:[{1}] Charge Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } return(ret); }
/// <summary> /// 单人技能的tick,这个需要手动调用 /// </summary> /// <param name="self"></param> public static void Tick_Battle(SkillObj self) { if (self.IsDead()) { return; } var skillList = self.GetSkillList(true); var buffList = self.GetBuffList(true); var CDKeyList = self.GetCDKeyList(); //buff if (buffList != null) { foreach (var buffInfo in buffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, self); if (buffLogic != null) { int buffId = self.GetBuffID(buffInfo); BuffConfig_New buffConfig = self.GetBuffConfig(buffId); buffLogic.Tick(self, buffInfo, buffConfig); } else { self.LogInfo("something error {0}".F(self.GetBuffID(buffInfo))); } } } //技能 if (skillList != null) { foreach (var skillInfo in skillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, self); if (skillLogic != null) { int skillId = self.GetSkillID(skillInfo); SkillConfig_New skillConfig = self.GetSkillConfig(skillId); skillLogic.Tick(self, skillInfo, skillConfig); } else { self.LogInfo("something error2 {0}".F(self.GetSkillID(skillInfo))); } } } //CD if(CDKeyList != null) { foreach (var key in CDKeyList) { self.SetCD(key, self.GetCD(key) - self.GetDeltaTime()); } } }
public static bool IsActionLimited(SkillObj self, ActionLimitType limit) { var skillList = self.GetSkillList(); var buffList = self.GetBuffList(); //buff if (buffList != null) { foreach (var buffInfo in buffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, self); if (buffLogic != null) { int buffId = self.GetBuffID(buffInfo); BuffConfig_New buffConfig = self.GetBuffConfig(buffId); if(buffLogic.IsActionLimited(self, limit, buffInfo, buffConfig)) { return true; } } else { self.LogInfo("something error {0}".F(self.GetBuffID(buffInfo))); } } } //技能 if (skillList != null) { foreach (var skillInfo in skillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, self); if (skillLogic != null) { int skillId = self.GetSkillID(skillInfo); SkillConfig_New skillConfig = self.GetSkillConfig(skillId); if (skillLogic.IsActionLimited(self, limit, skillInfo, skillConfig)) { return true; } } else { self.LogInfo("something error2 {0}".F(self.GetSkillID(skillInfo))); } } } return false; }
private static void DamageFix(SkillObj tarObj, SkillObj srcObj, Damage damage) { if (tarObj == null) { return; } if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); //Source skill fix if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, srcObj); int skillId = srcObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); skillLogic.DamageTargetFix(srcObj, tarObj, damage, skillInfo, skillConfig); } else { srcObj.LogInfo("something error in BattleModule.DamageFix src skill:[{0}]".F(skillId)); } } } //Source buff fix if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, srcObj); int buffId = srcObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New skillConfig = srcObj.GetBuffConfig(buffId); buffLogic.DamageTargetFix(srcObj, tarObj, damage, buffInfo, skillConfig); } else { srcObj.LogInfo("something error in BattleModule.DamageFix src buff:[{0}]".F(buffId)); } } } } { var tarBuffList = tarObj.GetBuffList(); var tarSkillList = tarObj.GetSkillList(); //Target skill fix if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); skillLogic.BeHurtDamageFix(tarObj, srcObj, damage, skillInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageFix tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New skillConfig = tarObj.GetBuffConfig(buffId); buffLogic.BeHurtDamageFix(tarObj, srcObj, damage, buffInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageFix tar buff:[{0}]".F(buffId)); } } } } }
public static bool AddBuff(SkillObj tarObj, SkillObj srcObj, int newBuffId, BattleReason reason) { if (tarObj == null) { return(false); } var buffConfig = tarObj.GetBuffConfig(newBuffId); if (buffConfig == null) { return(false); } var buffSuperpositionLogicId = tarObj.GetBuffSuperpositionLogicId(buffConfig); if (!BuffSuperpositionLogics.ContainsKey(buffSuperpositionLogicId)) { return(false); } BuffSuperpositionLogic buffSuperpositionLogic = BuffSuperpositionLogics[buffSuperpositionLogicId]; var buffRet = buffSuperpositionLogic.OnBuffSuperposition(tarObj, srcObj, reason, buffConfig); BuffInfo_New buff = buffRet.buff; if (buffRet.bType == BuffSuperpositionType.Refresh) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return(false); } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig, false); } else if (buffRet.bType == BuffSuperpositionType.Add) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return(false); } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig); //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.OnAttach(tarObj, srcObj, buff, buffConfig); tarObj.AddTempBuffList(buff); } tarObj.NotifyBuffInfo(buff, BattleInfoNotifyType.All_Buff, BattleNotifyTime.TickEnd); return(true); }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); self.SetSkillTime(skillInfo, self.GetSkillTime(skillInfo) - self.GetDeltaTime()); if (self.GetSkillTime(skillInfo) <= 0) { ret = LogicStateTickRet.TimeFinish; self.LogInfo("SkillLogicState:skillObj[{0}] skill:[{1}] [{2}]".F(self.GetID(), self.GetSkillID(skillInfo), ret.ToString())); } return(ret); }
private static SkillLogic GetSkillLogic(SkillInfo_New skillInfo, SkillObj logObj) { int skillId = logObj.GetSkillID(skillInfo); SkillConfig_New buffConfig = logObj.GetSkillConfig(skillId); if (buffConfig == null) { logObj.LogInfo("SkillConfig not found skillid[{0}]".F(skillId)); return null; } string skillLogicId = logObj.GetSkillLogicId(buffConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { logObj.LogInfo("SkillLogic not found skillid[{0}] SkillLogicId[{1}]".F(skillId, skillLogicId)); return null; } SkillLogic skillLogic = SkillLogics[skillLogicId]; return skillLogic; }
private static void DamageFix(SkillObj tarObj, SkillObj srcObj, Damage damage) { if(tarObj == null) { return; } if(srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); //Source skill fix if(srcSkillList != null) { foreach (var skillInfo in srcSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, srcObj); int skillId = srcObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); skillLogic.DamageTargetFix(srcObj, tarObj, damage, skillInfo, skillConfig); } else { srcObj.LogInfo("something error in BattleModule.DamageFix src skill:[{0}]".F(skillId)); } } } //Source buff fix if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, srcObj); int buffId = srcObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New skillConfig = srcObj.GetBuffConfig(buffId); buffLogic.DamageTargetFix(srcObj, tarObj, damage, buffInfo, skillConfig); } else { srcObj.LogInfo("something error in BattleModule.DamageFix src buff:[{0}]".F(buffId)); } } } } { var tarBuffList = tarObj.GetBuffList(); var tarSkillList = tarObj.GetSkillList(); //Target skill fix if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); skillLogic.BeHurtDamageFix(tarObj, srcObj, damage, skillInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageFix tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New skillConfig = tarObj.GetBuffConfig(buffId); buffLogic.BeHurtDamageFix(tarObj, srcObj, damage, buffInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageFix tar buff:[{0}]".F(buffId)); } } } } }
public override LogicStateTickRet Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { LogicStateTickRet ret = base.Tick(self, skillInfo, skillConfig); if (ret == LogicStateTickRet.TimeFinish) { return(ret); } double effectTickTime = self.GetSkillStateDoubleParam(skillConfig, key_EffectTickTime, self.GetSkillStateIndex(skillInfo)); if (effectTickTime < 0) { self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Effect effectTickTime< 0".F(self.GetID(), self.GetSkillID(skillInfo))); return(LogicStateTickRet.TimeFinish); } self.SetSkillStateTime(skillInfo, self.GetSkillStateTime(skillInfo) - self.GetDeltaTime()); var leftTickTime = self.GetSkillDoubleParam(skillInfo, key_ticlLeftTime_SkillInfo); if (leftTickTime - self.GetSkillStateTime(skillInfo) >= effectTickTime) { self.SetSkillDoubleParam(skillInfo, leftTickTime - effectTickTime, key_ticlLeftTime_SkillInfo); self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Effect".F(self.GetID(), self.GetSkillID(skillInfo))); ret = LogicStateTickRet.OnEffect; } else if (self.GetSkillStateTime(skillInfo) <= 0) { ret = LogicStateTickRet.NextState; self.LogInfo("TickSkillState:skillObj[{0}] skill:[{1}] Tick Finish".F(self.GetID(), self.GetSkillID(skillInfo))); } else { ret = LogicStateTickRet.None; } return(ret); }
/// <summary> /// 造成伤害或治疗 /// </summary> /// <param name="tarObj"></param> /// <param name="srcObj"></param> /// <param name="damage">大于0是伤害,小于0是治疗</param> public static void DamageTarget(SkillObj tarObj, SkillObj srcObj, Damage damage) { SkillObj realSrcObj = srcObj; if (tarObj == null || tarObj.IsDead()) { return; } if (realSrcObj != null && damage.srcId > 0 && realSrcObj.GetID() != damage.srcId) { realSrcObj = tarObj.GetSkillObj(damage.srcId); } BattleModule.CalcDamage(tarObj, realSrcObj, damage); //先修正伤害 BattleModule.DamageFix(tarObj, realSrcObj, damage); //质量和造成伤害都是这个 //造成伤害 if (damage.value >= 0) { tarObj.OnDamage(damage, realSrcObj); } else { tarObj.OnDamage(damage, realSrcObj); } //检查技能与BUFF的相应触发 if (realSrcObj != null && !realSrcObj.IsDead()) { var srcSkillList = realSrcObj.GetSkillList(); var srcBuffList = realSrcObj.GetBuffList(); //Source skill fix if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, realSrcObj); int skillId = realSrcObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = realSrcObj.GetSkillConfig(skillId); if (damage.value >= 0) { skillLogic.OnDamageTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig); } else { skillLogic.OnHealTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig); } } else { realSrcObj.LogInfo("something error in BattleModule.DamageTarget src skill:[{0}]".F(skillId)); } } } //Source buff fix if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, realSrcObj); int buffId = realSrcObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = realSrcObj.GetBuffConfig(buffId); if (damage.value >= 0) { buffLogic.OnDamageTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig); } else { buffLogic.OnHealTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig); } } else { realSrcObj.LogInfo("something error in BattleModule.DamageTarget src buff:[{0}]".F(buffId)); } } } } var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); //Target skill fix if (!tarObj.IsDead()) { if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); if (damage.value >= 0) { skillLogic.OnBeHurt(tarObj, realSrcObj, damage, skillInfo, skillConfig); } else { skillLogic.OnBeHeal(tarObj, realSrcObj, damage, skillInfo, skillConfig); } } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId); if (damage.value >= 0) { buffLogic.OnBeHurt(tarObj, realSrcObj, damage, buffInfo, buffConfig); } else { buffLogic.OnBeHeal(tarObj, realSrcObj, damage, buffInfo, buffConfig); } } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId)); } } } } if (tarObj.IsDead()) { if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); skillLogic.OnDie(tarObj, realSrcObj, skillInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId); buffLogic.OnDie(tarObj, realSrcObj, buffInfo, buffConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId)); } } } bool ret = tarObj.OnDie(realSrcObj); } }
public virtual void Tick(SkillObj self, SkillInfo_New skillInfo, SkillConfig_New skillConfig) { if (!CommonCheck(self, skillInfo, skillConfig)) { return ; } var logicState = BattleModule.GetSkillLogicState(skillInfo, self); if(logicState == null) { return; } var ret = logicState.Tick(self, skillInfo, skillConfig); switch(ret) { case LogicStateTickRet.TimeFinish: SkillOnEnd(self, skillInfo, skillConfig); break; case LogicStateTickRet.NextState: int index = self.GetSkillStateIndex(skillInfo); string nextStateName = self.GetLogicState(skillConfig, ++index); if (nextStateName == null || nextStateName.Equals("")) { SkillOnEnd(self, skillInfo, skillConfig); return; } var nextLogicState = BattleModule.GetSkillLogicState(nextStateName); if (nextLogicState == null) { self.LogInfo("startLogicState {0} not found".F(nextStateName)); return; } double fixTime = logicState.OnStateChanged(nextStateName, self, skillInfo, skillConfig); self.SetSkillStateIndex(skillInfo, index); nextLogicState.InitState(self, skillInfo, skillConfig, fixTime); self.NotifySkillInfo(skillInfo, BattleInfoNotifyType.ChangeState_Skill, BattleNotifyTime.TickEnd); break; case LogicStateTickRet.OnEffect: //var srcObj = self.GetSkillSrcObj(skillInfo); { var targetSelectName = self.GetTargetSelect(skillConfig); var targetSelect = BattleModule.GetTargetSelect(targetSelectName); if (targetSelect == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetSelectName:[{1}]".F(self.GetSkillID(skillInfo), targetSelectName)); return; } var targetTypeName = self.GetTargetType(skillConfig); var targetType = BattleModule.GetTargetType(targetTypeName); if (targetType == null) { self.LogInfo("targetSelect == null skillId:[{0}] targetType:[{1}]".F(self.GetSkillID(skillInfo), targetTypeName)); return; } var targets = BattleModule.GetTargets(self, targetSelect, targetType, skillInfo, skillConfig); foreach (var tar in targets) { OnEffect(self, tar, skillInfo, skillConfig); } } break; } }
public static void DetachBuff(SkillObj tarObj, SkillObj srcObj, BuffInfo_New buff, BuffConfig_New buffConfig) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return ; } BuffLogic buffLogic = BuffLogics[buffLogicId]; //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnClearBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnClearBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnDetachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList.Where(b=>b.buff!=buff.buff)) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnDetachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.BuffOnEnd(tarObj, buff, buffConfig); buffLogic.OnDetach(tarObj, srcObj, buff, buffConfig); }
public static bool AddBuff(SkillObj tarObj, SkillObj srcObj, int newBuffId, BattleReason reason) { if (tarObj == null) { return false; } var buffConfig = tarObj.GetBuffConfig(newBuffId); if(buffConfig == null) { return false; } var buffSuperpositionLogicId = tarObj.GetBuffSuperpositionLogicId(buffConfig); if (!BuffSuperpositionLogics.ContainsKey(buffSuperpositionLogicId)) { return false; } BuffSuperpositionLogic buffSuperpositionLogic = BuffSuperpositionLogics[buffSuperpositionLogicId]; var buffRet = buffSuperpositionLogic.OnBuffSuperposition(tarObj, srcObj, reason, buffConfig); BuffInfo_New buff = buffRet.buff; if(buffRet.bType == BuffSuperpositionType.Refresh) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return false; } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig, false); } else if(buffRet.bType == BuffSuperpositionType.Add) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return false; } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig); //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.OnAttach(tarObj, srcObj, buff, buffConfig); tarObj.AddTempBuffList(buff); } tarObj.NotifyBuffInfo(buff, BattleInfoNotifyType.All_Buff, BattleNotifyTime.TickEnd); return true; }
public static void DetachBuff(SkillObj tarObj, SkillObj srcObj, BuffInfo_New buff, BuffConfig_New buffConfig) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return; } BuffLogic buffLogic = BuffLogics[buffLogicId]; //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnClearBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnClearBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnDetachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList.Where(b => b.buff != buff.buff)) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnDetachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.BuffOnEnd(tarObj, buff, buffConfig); buffLogic.OnDetach(tarObj, srcObj, buff, buffConfig); }
/// <summary> /// 使用技能,这个需要手动调用 /// </summary> /// <param name="self"></param> /// <param name="skillId"></param> /// <returns></returns> public static UseSkillRet UseSkill(SkillObj self, int skillId) { UseSkillRet ret = UseSkillRet.Success; if (BattleModule.IsActionLimited(self, ActionLimitType.UseSkill)) { return UseSkillRet.ActionLimit; } if(self.IsDead()) { return UseSkillRet.Dead; } //检查特殊状态 if (!self.CanUseSkill(skillId)) { return UseSkillRet.None; } SkillConfig_New skillConfig = self.GetSkillConfig(skillId); if (skillConfig == null) { return UseSkillRet.None; } //检查技能消耗 if (!UseSkillCheckDeplete(self, skillConfig)) { return UseSkillRet.Deplete; } string skillLogicId = self.GetSkillLogicId(skillConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { return UseSkillRet.None; } SkillLogic skillLogic = SkillLogics[skillLogicId]; if(skillLogic != null) { //检查CD if (!skillLogic.CheckCD(self, skillConfig)) { string key = self.GetSkillCDKey(skillConfig); self.LogInfo("skill:[{0}] CD ing [{1}]:[{2}]".F(self.GetSkillID(skillConfig), key, self.GetCD(key))); return UseSkillRet.CD; } SkillInfo_New skillInfo = skillLogic.Begin(self, skillConfig); if (skillInfo != null) { skillLogic.BeginCD(self, skillInfo, skillConfig); self.AddSkillList(skillInfo); self.LogInfo("Skill Begin Successed [{0}]".F(skillId)); } else { self.LogInfo("Skill Begin Failed [{0}]".F(skillId)); } } return ret; }
/// <summary> /// 造成伤害或治疗 /// </summary> /// <param name="tarObj"></param> /// <param name="srcObj"></param> /// <param name="damage">大于0是伤害,小于0是治疗</param> public static void DamageTarget(SkillObj tarObj, SkillObj srcObj, Damage damage) { SkillObj realSrcObj = srcObj; if(tarObj == null || tarObj.IsDead()) { return; } if(realSrcObj != null && damage.srcId > 0 && realSrcObj.GetID() != damage.srcId) { realSrcObj = tarObj.GetSkillObj(damage.srcId); } BattleModule.CalcDamage(tarObj, realSrcObj, damage); //先修正伤害 BattleModule.DamageFix(tarObj, realSrcObj, damage); //质量和造成伤害都是这个 //造成伤害 if(damage.value >= 0) { tarObj.OnDamage(damage, realSrcObj); } else { tarObj.OnDamage(damage, realSrcObj); } //检查技能与BUFF的相应触发 if (realSrcObj != null && !realSrcObj.IsDead()) { var srcSkillList = realSrcObj.GetSkillList(); var srcBuffList = realSrcObj.GetBuffList(); //Source skill fix if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, realSrcObj); int skillId = realSrcObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = realSrcObj.GetSkillConfig(skillId); if (damage.value >= 0) { skillLogic.OnDamageTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig); } else { skillLogic.OnHealTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig); } } else { realSrcObj.LogInfo("something error in BattleModule.DamageTarget src skill:[{0}]".F(skillId)); } } } //Source buff fix if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, realSrcObj); int buffId = realSrcObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = realSrcObj.GetBuffConfig(buffId); if (damage.value >= 0) { buffLogic.OnDamageTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig); } else { buffLogic.OnHealTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig); } } else { realSrcObj.LogInfo("something error in BattleModule.DamageTarget src buff:[{0}]".F(buffId)); } } } } var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); //Target skill fix if(!tarObj.IsDead()) { if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); if (damage.value >= 0) { skillLogic.OnBeHurt(tarObj, realSrcObj, damage, skillInfo, skillConfig); } else { skillLogic.OnBeHeal(tarObj, realSrcObj, damage, skillInfo, skillConfig); } } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId); if (damage.value >= 0) { buffLogic.OnBeHurt(tarObj, realSrcObj, damage, buffInfo, buffConfig); } else { buffLogic.OnBeHeal(tarObj, realSrcObj, damage, buffInfo, buffConfig); } } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId)); } } } } if (tarObj.IsDead()) { if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj); int skillId = tarObj.GetSkillID(skillInfo); if (skillLogic != null) { SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); skillLogic.OnDie(tarObj, realSrcObj, skillInfo, skillConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId)); } } } //Target buff fix if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj); int buffId = tarObj.GetBuffID(buffInfo); if (buffLogic != null) { BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId); buffLogic.OnDie(tarObj, realSrcObj, buffInfo, buffConfig); } else { tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId)); } } } bool ret = tarObj.OnDie(realSrcObj); } }