RoleLogic = {} RoleLogic.__index = RoleLogic --local RoleLogic = RoleLogic --local RoleDataName = RoleDataName --local BattleLogic = BattleLogic local Random = Random local floor = math.floor local max = math.max local Passivity = require("Modules/Battle/Logic/Base/Passivity") local function InitData(property) --初始化属性 local index = 1 local getData = function(property) local p = property[index] index = index + 1 return p end return { [RoleDataName.Level] = {getData(property), false}, [RoleDataName.Hp] = {getData(property), false}, [RoleDataName.MaxHp] = {getData(property), false}, [RoleDataName.Attack] = {getData(property), false}, [RoleDataName.PhysicalDefence] = {getData(property), false}, [RoleDataName.MagicDefence] = {getData(property), false}, [RoleDataName.Speed] = {getData(property), false}, [RoleDataName.DamageBocusFactor] = {getData(property), true}, [RoleDataName.DamageReduceFactor] = {getData(property), true}, [RoleDataName.Hit] = {getData(property), true}, [RoleDataName.Dodge] = {getData(property), true}, [RoleDataName.Crit] = {getData(property), true}, [RoleDataName.CritDamageFactor] = {getData(property), true}, [RoleDataName.TreatFacter] = {getData(property), true}, [RoleDataName.FireDamageBocusFactor] = {getData(property), true}, [RoleDataName.IceDamageBocusFactor] = {getData(property), true}, [RoleDataName.LightDamageBocusFactor] = { getData(property), true}, [RoleDataName.WindDamageBocusFactor] = {getData(property), true}, [RoleDataName.LandDamageBocusFactor] = {getData(property), true}, [RoleDataName.DarkDamageBocusFactor] = {getData(property), true}, [RoleDataName.FireDamageReduceFactor] = {getData(property), true}, [RoleDataName.IceDamageReduceFactor] = {getData(property), true}, [RoleDataName.LightDamageReduceFactor] = { getData(property), true}, [RoleDataName.WindDamageReduceFactor] = {getData(property), true}, [RoleDataName.LandDamageReduceFactor] = {getData(property), true}, [RoleDataName.DarkDamageReduceFactor] = {getData(property), true}, } end function RoleLogic.New(uid, data) local instance = {} setmetatable(instance, RoleLogic) instance.uid = uid instance.roleData = data instance.data = RoleData.New(instance, InitData(data.property)) instance.camp = data.camp --阵营 0:我方 1:敌方 instance.name = data.name instance.roleType = 1 --阵营 1:普通 2:Boss 3:召唤物 instance.BuffMgr = BuffManager.New(instance) instance.Event = BattleEvent:New() instance.passiveList = {} if data.skill and #data.skill > 0 then instance.skill = Skill:New(instance, data.skill) instance.skill.sp = 0 local time = max(6-instance:GetRoleData(RoleDataName.Speed)/(8*(instance:GetRoleData(RoleDataName.Level)+10)), 1.5) instance.skill.spPass = floor( time * BattleLogic.GameFrameRate) end if data.superSkill and #data.superSkill > 0 then instance.superSkill = Skill:New(instance, data.superSkill) instance.superSkill.spPass = floor(instance.superSkill.cd * BattleLogic.GameFrameRate) instance.superSkill.sp = instance.superSkill.spPass end for i = 1, #data.passivity do local v = data.passivity[i] local id = v[1] local args = v[2] Passivity[id](instance, args) end instance.isDead = false instance.Auto = true instance.IsDebug = false instance.enable = true return instance end function RoleLogic:GetRoleData(property) return self.data:GetData(property) end function RoleLogic:AddBuff(buff) self.BuffMgr:AddBuff(buff) end function RoleLogic:Update() self.BuffMgr:Update() if not self.enable then return end if self.superSkill then if self.superSkill.sp >= self.superSkill.spPass then if self.skill then if self.skill.sp >= self.skill.spPass then if self.Auto and not self.IsDebug then if Random.Range01() <= 0.75 then self.skill:Cast() else self.superSkill:Cast() end end else self.skill.sp = self.skill.sp + 1 end else if self.Auto and not self.IsDebug then self.superSkill:Cast() end end else self.superSkill.sp = self.superSkill.sp + 1 end else if self.skill then if self.skill.sp >= self.skill.spPass then if self.Auto and not self.IsDebug then self.skill:Cast() end else self.skill.sp = self.skill.sp + 1 end end end end