local base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_FourForceFight = class("Decision_FourForceFight", base) local P1_SEARCH_ENEMY_DIS_SQR = FP.newV1(100) local NEW_WANDER_POS_POSIBILITY = FP.newV1(0.05) --四军之战 自动战斗 --[[ 初始化 --]] function Decision_FourForceFight:initialize(entity) base.initialize(self,entity) --类型 self.Type = LuaConst.DecisionType.FourForceFight --瞬时 self.IsOnce = false self.SCENE_RADIUS = FP.newV1(43) self.CENTER = FP.newV2(0,0) end --[[ 进入该Decision --]] function Decision_FourForceFight:DecisionIn(entity, decisionData) --↓ 还未实现 self.eloSkillCDInfo的初始化。各个玩法的eloSkillCDInfo的初始化都得各个Decision自己初始化 -- local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(decisionData) -- local elo = entity._logicInitData.elo or 0 -- for i,info in ipairs(self.eloSkillCDInfo) do -- if info.minElo <= elo and info.maxElo > elo then -- decisionRecordDic[self.MIN_USESKILL_DECISION_CD_KEY] = info.minCd -- decisionRecordDic[self.MAX_USESKILL_DECISION_CD_KEY] = info.maxCd -- end -- end end --[[ 退出该Decision --]] function Decision_FourForceFight:DecisionOut(entity, decisionData) local aiBaseComponent = entity.components.aiBase aiBaseComponent:ClearDecisionRecord(decisionData) end --[[ 能否进入 --]] function Decision_FourForceFight:CanEnter(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return autoFightComponent.IsSyncAuto end --[[ 能否退出 --]] function Decision_FourForceFight:CanExit(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return not autoFightComponent.IsSyncAuto end --[[ 输出指令 --]] function Decision_FourForceFight:SetCommand(entity, decisionData, command) local aiBaseComponent = entity.components.aiBase local decisionRecordDic = aiBaseComponent:GetDecisionRecordDic(decisionData) --索敌 SystemManager.OnSearchTarget(entity, 1, P1_SEARCH_ENEMY_DIS_SQR, 1, 0) if entity.components.target.Target then local isSkillUsed = false --有目标就打目标 command,isSkillUsed= self:CommandUseSkill(entity,command,decisionRecordDic) --如果释放技能失败,就随机闲逛 if not isSkillUsed then command = self:CommandRandomWander(entity,aiBaseComponent,decisionData,entity:GetLogicPos(), self.CENTER, self.SCENE_RADIUS, command, NEW_WANDER_POS_POSIBILITY) end else --没目标就随机闲逛 command = self:CommandRandomWander(entity,aiBaseComponent,decisionData,entity:GetLogicPos(), self.CENTER, self.SCENE_RADIUS, command, NEW_WANDER_POS_POSIBILITY) end end return Decision_FourForceFight