|
|
- require("game.skill.SkillVo")
-
- SkillManager = SkillManager or BaseClass(BaseVo, true)
- local SkillManager = SkillManager
- SkillManager.REQUEST_CCMD_EVENT = "SkillManager.REQUEST_CCMD_EVENT"
- SkillManager.UPDATE_SKILL_LIST = "UPDATE_SKILL_LIST"
- SkillManager.RESET_SKILL_LIST = "RESET_SKILL_LIST"
- SkillManager.START_SKILL_CD = "START_SKILL_CD"
- SkillManager.FORCE_RELEASE_BASE_SKILL = "FORCE_RELEASE_BASE_SKILL"
- SkillManager.FORCE_STOP_BASE_SKILL = "FORCE_STOP_BASE_SKILL"
- SkillManager.SHORT_CUT_SKILL_ACTIVE = "SHORT_CUT_SKILL_ACTIVE"
- SkillManager.SHORT_CUT_SKILL_ACTIVE_IN_STORY = "SHORT_CUT_SKILL_ACTIVE_IN_STORY"
- SkillManager.SHORT_CUT_SKILL_ACTIVE_BY_INDEX = "SHORT_CUT_SKILL_ACTIVE_BY_INDEX"
- SkillManager.SHOW_USE_SKILL_TIP = "SHOW_USE_SKILL_TIP"
- SkillManager.LOCK_CD = "LOCK_CD"
- SkillManager.REFRESH_CD = "SkillManager.REFRESH_CD"
- SkillManager.CHANGE_GOD_GUIDE = "SkillManager.CHANGE_GOD_GUIDE"
- SkillManager.HIT_SKILL_GUIDE = "SkillManager.HIT_SKILL_GUIDE"
- SkillManager.SET_SKILL_GRAY_STATE = "SkillManager.SET_SKILL_GRAY_STATE"
- SkillManager.SKILL_LEVEL_UP = "SkillManager.SKILL_LEVEL_UP" --技能升级
-
-
- SkillManager.ThreeAttackSkills =
- {
- --key:职业@性别
- ["1@1"] = {101001,101002,101003,101004},
- ["2@2"] = {102001,102002,102003,102004},
- ["3@1"] = {103001,103002,103003,103004},
- ["4@2"] = {104001,104002,104003,104004},
- }
-
- --怒气技能id
- SkillManager.AngerSkill =
- {
- ["1@1"] = 101091,
- ["2@2"] = 102091,
- ["3@1"] = 103091,
- ["4@2"] = 104091,
- }
-
- SkillManager.GodThreeAttackSkills =
- {
-
- }
-
- SkillManager.ThreeAttackSkillInfo =
- {
- --职业普攻
- [101001] = 4, [101002] = 4, [101003] = 4, [101004] = 4,
- [102001] = 4, [102002] = 4, [102003] = 4, [102004] = 4,
- [103001] = 4, [103002] = 4, [103003] = 4, [103004] = 4,
- [104001] = 4, [104002] = 4, [104003] = 4, [104004] = 4,
- }
-
-
- --被动技能显示类型 (暂时只支持2个)
- -- 1 表示 PVE
- -- 2 表示 PVP
- -- 3 表示 单体
- -- 4 表示 群攻
- SkillManager.PassivesSkillTypeList =
- {
- [20000] = {1,3,},
- [20001] = {2,4,},
- }
-
- SkillManager.MonsterBaseSkill_1 = 1110000001
- SkillManager.MonsterBaseSkill_2 = 1110000003
-
- SkillManager.SkillCacheTime = 1.5 --技能缓存时间
-
-
- --技能攻击类型 1只发起攻击(默认) 2只显示技能范围ui 3.两者都有
- SkillManager.SKILL_ATTACK_TYPE = {
- ONLY_FIRE_ATTACK = 1,
- ONLY_SHOW_RANGE = 2,
- ATTACK_AND_RANGE = 3,
- }
-
- SkillManager.JUMP_SKILL_ID = 10001 --跳跃技能
- SkillManager.GodSkillId = 1234578 --变身降神的技能id
-
- -- SkillManager.BabyDunMainRoleBaseSkill = 502001 -- 宝宝副本主角普攻技能
- SkillManager.BabyDunMainRoleBaseSkill = 502002 -- 宝宝副本主角普攻技能
-
- function SkillManager:__init()
- SkillManager.Instance=self
- self:ResetData()
- end
-
- function SkillManager:__delete()
-
- end
-
- function SkillManager:ResetData()
- self.currentSkillId = 0 --点击技能栏选择的技能
- self.currentSkillVo = nil --当前技能VO
- self.currentAttackRange = 0 --根据当前技能和角色角色,取到的当前攻击距离
- self.curSelectSkillId = 0 --技能面板的选中的技能id
-
- self.mySkillList = {} --我的技能表
- self.shortcutList = {} --快捷栏列表 出战的职业技能列表
- self.dailyLightSkill = {} --幻光技能
- self.skillUseList = {} --快捷栏类表 技能id为Key
- self.replaceSkillList = {} --一些特殊效果发过来的替换当前技能的
- self.replaceNewSkillList = {} --一些特殊效果发过来的替换当前技能的
- self.has_replace_skill_del = false --是否有替换的删除
-
-
- self.cur_shortcut_plan = 1
-
- self.skill_Rigidity = nil --施法僵直结束的时候(注意和技能CD不一样,是说必须等到该时间点之后,才能尝试释放下个技能)
-
- --主角技能用到的特效列表
- self.particle_list = {}
-
- self.three_attack_index = 1 --三段攻击的当前序号
- -- self.cached_skills = {} --缓存的技能列表
- self.cached_skill_id = nil --缓存的技能id
-
- self.otherSkillList = {} --所有技能(除了主角的技能表)
-
- --主技能最近一次释放的时间列表
- self.release_main_skill_time_list = {}
- --被动技能cd列表
- self.release_passive_skill_time_list = {}
-
- self.cd_skill_list = {}
-
- self.shortcut_gray_flag = 0
-
- self.start_time = 0
- self.server_time = 0
- self.every_dot_time = 0
- self.max_dot = 0
- self.switch_cd = 0 --降神主界面图标信息
-
- self.curr_god_dot = 0 --当前的降神点数
- self.curr_god_state = -1 --当前降神的出战状态 -1无 0未开启 1已开启未出战 2已出战未变身 3变身中
-
- self.can_use_hit_skill = true --是否可以使用羁绊技能
-
- self.scene_mgr = SceneManager:getInstance()
-
- self.hide_black_views_list = {} --隐藏技能的黑色遮罩
-
- self.skill_back_swing_list = {} --技能后摇列表
-
- self.multi_skill_list = {} --多段伤害技能列表
-
- --新手期特殊表现技能id
- self.guide_skill_list = {
- --key:职业@性别
- ["1@1"] = {
- show_list = {101011,101031,101003,101061},
- real_list = {101001,101002,101003,101004},
- },
- ["2@2"] = {
- show_list = {102011,102031,102003,102061},
- real_list = {102001,102002,102003,102004},
- },
- ["3@1"] = {
- show_list = {103061,103011,103003,103004},
- real_list = {103001,103002,103003,103004},
- },
- ["4@2"] = {
- show_list = {104061,104011,104003,104004},
- real_list = {104001,104002,104003,104004},
- },
- }
- self.cur_guide_skill_index = 1
- end
-
- function SkillManager:ClearData()
- self:ResetData()
- end
-
- function SkillManager:AddReleaseMainSkill(skill_id)
- if not self:IsThreeAttackSkill(skill_id) then
- self.release_main_skill_time_list[skill_id] = Status.NowTime
- end
- end
-
- function SkillManager:GetReleaseMainSkill(skill_id)
- return self.release_main_skill_time_list[skill_id]
- end
-
- function SkillManager:AddReleasePassiveSkill(skill_id, last_trigger_time)
- self.release_passive_skill_time_list[skill_id] = last_trigger_time
- end
-
- function SkillManager:GetReleasePassiveSkill(skill_id)
- return self.release_passive_skill_time_list[skill_id] or 0
- end
-
- function SkillManager:AddCDItem(skill_id,item)
- self.cd_skill_list[skill_id] = item
- end
-
- function SkillManager:RemoveCdItem(skill_id)
- self.cd_skill_list[skill_id] = nil
- end
-
- function SkillManager:Update(now_time, elapsed_time)
- if self.three_attack_index ~= 1 and self.skill_Rigidity and now_time - self.skill_Rigidity > 3 then
- -- Message.show("Update重置重置")
- SkillManager.ResetThreeAttackIndex(self)
- SkillManager.ClearCachedSkill(self)
- end
-
- if self.cache_skill_time and now_time - self.cache_skill_time > self.cache_secs then --缓存的技能超过一定时间就会清空
- self.cache_skill_time = false
- SkillManager.ClearCachedSkill(self)
- end
-
- -- if TableSize(self.replaceSkillList) > 0 then
- -- self.has_replace_skill_del = false
- -- for index,info in pairs(self.replaceSkillList) do
- -- if TimeUtil:getServerTimeMs( ) - info.end_time >= 0 then
- -- self.replaceSkillList[info.skill_id] = nil
- -- self.replaceNewSkillList[info.new_skill_id] = nil
- -- self.has_replace_skill_del = true
- -- end
- -- end
- -- if self.has_replace_skill_del then
- -- self:Fire(SkillManager.UPDATE_SKILL_LIST)
- -- end
- -- end
- end
-
- function SkillManager:ResetThreeAttackIndex(bool)
- -- if bool then
- self.three_attack_index = 1
- -- end
- end
-
- function SkillManager:getThreeAttackIndex()
- return self.three_attack_index
- end
- --角色的基本技能
- function SkillManager:IsThreeAttackSkill(id)
- return SkillManager.ThreeAttackSkillInfo[id]
- end
-
-
- --怪物的基本技能
- function SkillManager:IsMonsterBaseSkill(id)
- return SkillManager.MonsterBaseSkill_1 == id or SkillManager.MonsterBaseSkill_2 == id
- end
-
-
- --得到基础技能id
- function SkillManager:getBaseSkill(career,index)
- career = career or RoleManager.Instance.mainRoleInfo.career
- index = index or self.three_attack_index
- local sex = RoleManager.Instance.mainRoleInfo.sex
- local turn = RoleManager.Instance.mainRoleInfo.turn
- local id = SkillManager.ThreeAttackSkills[career.."@"..sex][index]
- return id
- end
-
- function SkillManager:resetRigidityTime()
- self.Rigidity_start_time = Status.NowTime
- end
- -------------------------------------------
-
-
- function SkillManager:getInstance()
- if SkillManager.Instance==nil then
- SkillManager.New()
- end
- return SkillManager.Instance
- end
- function SkillManager:getSkill(id)
-
- if id == nil or id <= 0 then
- return
- end
- if self.mySkillList[id] ~= nil then
- return self.mySkillList[id]
- end
- if self:getSkillFromConfig(id) == nil then
- print(string.format("getSkill:warning! can't find skill(%s) in data_skill.db!", id))
- return nil
- end
- if self.otherSkillList[id] == nil then
- local skillVo = SkillVo.New(id)
- self.otherSkillList[id] = skillVo
- end
- return self.otherSkillList[id]
- end
-
- --根据副技能组装出对应的主技能
- function SkillManager:PackageMainSkillId(combo_skill)
- return math.floor(combo_skill / 10) * 10 + 1 --主技能最后一位一定为1
- end
-
-
- --返回主角的技能需要用到的所有特效资源
- function SkillManager:getParticleList()
- return self.particle_list
- end
-
-
- --改变释放的技能
- -- skillId 可传nil
- function SkillManager:setCurrentSkillId(skillId)
- -- skillId = skillId or self:getBaseSkill()
-
- if self.currentSkillId ~= skillId then
- self.currentSkillId = skillId
- self.currentSkillVo = self:getSkill(skillId)
- -- self:Fire(SkillManager.CHANGESKILL)
-
- --刷新攻击距离
- self:UpdateAttackDistance()
- end
- end
-
- --返回当前技能id,可能为nil
- function SkillManager:getCurrentSkillId()
- return self.currentSkillId
- end
-
- --返回当前可用技能,如果当前技能id为nil,则返回普攻技能
- function SkillManager:getCurrentSkill()
- return self.currentSkillVo
- end
-
- --复位技能 技能成功释放后设置CD
- function SkillManager:ResetSkill(skillId)
- self.cacheReset_skillId = skillId
- self:SetCacheResetSkillId()
- end
-
- --[[
- 功能:从配置中获取技能信息
- 其他.
- 作者:zsm
- ]]
- function SkillManager:getSkillFromConfig(id)
- return ConfigItemMgr.Instance:GetSkillItem(id)
- end
-
- --[[
- 功能:从配置中获取技能战力
- is_have: 是否是已经获得的技能
- ]]
- function SkillManager:GetSkillPower( id,level,is_get )
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- local power = 0
- if skill_cfg ~= nil then
- if skill_cfg.lvs[level] ~= nil then
- local cfg = skill_cfg.lvs[level]
- if cfg and cfg.power then
- local skill_power = Trim(cfg.power)
- if string.len(skill_power) > 0 then
- power = power + tonumber(skill_power)
- end
- end
- if cfg.base_attr then
- local attr_list = stringtotable(cfg.base_attr)
- if #attr_list > 0 then
- power = GetFighting(attr_list,is_get)
- end
- end
- end
- end
- print("技能战力 :", id,level,power)
- return power
- end
-
-
- --[[
- 功能:从配置文件中获取对应等级的技能描述信息
- 参数:技能id和技能等级
- 作者:yzd
- ]]
- function SkillManager:GetSkillFromConfigByIdAndLevel(id,level)
- local description = ""
- local name = ""
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- if skill_cfg ~= nil then
- if skill_cfg.lvs[level] ~= nil then
- description = skill_cfg.lvs[level].desc
- name = skill_cfg.name
- end
- end
- return description, name
- end
-
- --[[
- 功能:从配置文件中获取技能名字
- 参数:技能id
- 作者:yzd
- ]]
- function SkillManager:GetSkillNameById(id)
- local name = ""
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- if skill_cfg ~= nil then
- name = skill_cfg.name
- end
- return name
- end
-
- --[[
- 功能:从配置文件中获取技能所属职业
- 参数:技能id
- 作者:yzd
- ]]
- function SkillManager:GetSKillCareerById(id)
- local career
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- if skill_cfg ~= nil then
- name = skill_cfg.career
- end
- return name
- end
-
- --[[
- 功能:从配置文件中获取对应等级的技能CD
- 参数:技能id和技能等级
- 作者:yzd
- ]]
- function SkillManager:GetSkillCdByIdAndLevel(id,level)
-
- local cd
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- if skill_cfg ~= nil then
- if skill_cfg.lvs[level] ~= nil then
- cd = skill_cfg.lvs[level].cd
- end
- end
- return cd
- end
-
- --[[
- 功能:从配置文件中获取对应等级的技能距离
- 参数:技能id和技能等级
- 作者:yzd
- ]]
- function SkillManager:GetSkillDistanceByIdAndLevel(id,level)
-
- local distance
- local skill_cfg = ConfigItemMgr.Instance:GetSkillItem(id)
- if skill_cfg ~= nil then
- if skill_cfg.lvs[level] ~= nil then
- distance = skill_cfg.lvs[level].distance
- end
- end
- return distance
- end
-
- --获取战斗技能配置信息
- function SkillManager:GetFightSkillMovie(skill_id)
- return Config.CareerFightMovies[skill_id] or Config.MonsterFightMovies[skill_id] --or Config.StarFightMovies[skill_id] or {}
- end
-
- --处理三段攻击技能
- function SkillManager:IncreaseThreeAttackIndex(skillId)
- local i = self.three_attack_index + 1
- if i > SkillManager.ThreeAttackSkillInfo[skillId] then
- i = 1
- end
- self.three_attack_index = i
- end
-
-
- --设置施法僵直的时间秒数,结束时间
- function SkillManager:SetSkillRigidity(time_len)
- if time_len > 4 then
- print("施法僵直异常,", time_len)
- time_len = 4
- end
- time_len = time_len - 0.1 --僵直时间统一减少,方便动作衔接
- self.Rigidity_start_time = self.Rigidity_start_time or Status.NowTime
- local time_off = Status.NowTime - self.Rigidity_start_time
- local rigidity_end_time = time_len + Status.NowTime - time_off
- --可能服务端有延迟 赋值到一个较短的值
- if self.skill_Rigidity and rigidity_end_time < self.skill_Rigidity then
- return
- end
-
- self.skill_Rigidity = rigidity_end_time
- end
-
- --判断角色是否在施法僵直的过程中
- function SkillManager:isInRigidity()
- if self.skill_Rigidity and Status.NowTime - self.skill_Rigidity < -4 then
- print("SkillManager:isInRigidity:在异常CD中,", Status.NowTime - self.skill_Rigidity)
- end
- return (self.skill_Rigidity ~= nil and Status.NowTime < self.skill_Rigidity)
- end
-
- function SkillManager:GetRigidityLeftTime()
- if not self.skill_Rigidity then
- return 0
- end
- return self.skill_Rigidity - Status.NowTime
- end
-
- function SkillManager:AddCacheSkill(id, cache_secs)
- --缓存一个技能
- if not id then
- return
- end
- local skillVo = SkillManager.Instance:getSkill(id)
- if skillVo and skillVo:CoolDown() then
- self.cached_skill_id =id
- self.cache_skill_time = Status.NowTime
- self.cache_secs = cache_secs or SkillManager.SkillCacheTime
- end
- end
-
- function SkillManager:ClearCachedSkill()
- self.cached_skill_id = nil
- end
-
- function SkillManager:PopCachedSkill()
- if self.cached_skill_id then
- local cached_id = self.cached_skill_id
- self.cached_skill_id = nil
- return cached_id
- end
- end
-
-
- function SkillManager:CreateSkillList()
- self.mySkillList = {}
-
- --主角技能用到的特效列表
- -- self.particle_list = {}
- local len = UserMsgAdapter.ReadFmt("h")
- local three_attack_level = nil
- for index = 1, len do
- local skillId,skillLv = UserMsgAdapter.ReadFmt("ih")
- print("= = = = = = = skillId,skillLv", skillId,skillLv)
- local skill_cfg = self:getSkillFromConfig(skillId)
- if skill_cfg ~= nil then
- local skillVo = self.mySkillList[skillId] or SkillVo.New(skillId)
-
- skillVo.level = skillLv
-
- self.mySkillList[skillId] = skillVo
- --[[
- --把技能用到的特效资源记录下来
- local movie_cfg = SkillManager.Instance:GetFightSkillMovie(skillId)
- if movie_cfg and movie_cfg.particles then
- local particles = movie_cfg.particles
- for _, particle_info in pairs(particles) do
- local res = particle_info.res
- if res then
- table.insert(self.particle_list, res)
- -- print("用到的特效:", res)
- end
- end
- end
- ]]
- else
- print(string.format("CreateSkillList:warning! can't find skill(%s) in data_skill.db!", skillId))
- end
- end
- GlobalEventSystem:Fire(EventName.GET_SKILL_SHORTCUT) --刷新快捷栏
- self.currentSkillId = self:getBaseSkill()
- self.currentSkillVo = self:getSkill(self.currentSkillId)
- self:UpdateAttackDistance()
- end
-
- function SkillManager:AddSkillToSkillList(skillId)
- local skill_cfg = self:getSkillFromConfig(skillId)
- if skill_cfg ~= nil then
- local skillVo = self.mySkillList[skillId] or SkillVo.New(skillId)
- skillVo.level = 1
- self.mySkillList[skillId] = skillVo
- end
- end
-
- --is_base 是否获取基本技能
- function SkillManager:GetShortCutList()
- return self.shortcutList
- end
-
- --技能是否在快捷栏上面
- function SkillManager:IsSkillHasUse(id)
- if not id then
- return
- end
- return self.skillUseList[id]
- end
-
- function SkillManager:SetHitSkillVo(vo)
- local skill_vo = self:getSkill(vo.id)
- if skill_vo then
- self.skillUseList[vo.id] = vo
- self.shortcutList[vo.pos] = skill_vo
- end
- end
-
- --获取羁绊技能数据
- function SkillManager:GetHitSkillVo()
- return self.shortcutList[9]
- end
-
- function SkillManager:getCfgInitiativeSkillList(career,sex)
- local mvo = RoleManager.Instance:GetMainRoleVo()
- local key = mvo.career .. "@" .. mvo.sex
- if career and sex then
- key = career .. "@" .. sex
- end
- return Config.ConfigSkillUI.InitiativeSkill[key]
- end
-
- --刷新攻击距离
- function SkillManager:UpdateAttackDistance()
- local skillVo = self.currentSkillVo
- if skillVo == nil then
- self.currentAttackRange = 0
- return
- end
-
- local skill_distance = skillVo:GetDistance() or 100
- skill_distance = skill_distance
-
- if skill_distance < 50 then
- skill_distance = 50
- end
- self.currentAttackRange = skill_distance
- end
-
- --返回当前可用技能的攻击距离
- function SkillManager:GetCurrentAttackRange()
- return self.currentAttackRange
- end
- --检测是否是缓存技能id
- function SkillManager:CheckCacheSkill(id)
- if self.cacheReset_skillId and self.cacheReset_skillId == id then
- return true
- else
- return false
- end
- end
-
- --显示技能cd
- function SkillManager:SetCacheResetSkillId()
- local skillVo = self:getSkill(self.cacheReset_skillId)
- if skillVo ~= nil and skillVo:getCd() ~= 0 then
- local cdTime = 1
- cdTime = skillVo:getCd()/1000
- skillVo:startCD()
-
- self:Fire(SkillManager.START_SKILL_CD,self.cacheReset_skillId,cdTime)
- end
-
- -- if self.cacheReset_skillId == self.currentSkillId then
- self:setCurrentSkillId()
- -- end
- self.cacheReset_skillId = nil
- end
-
- function SkillManager:ClearAllSkillCD()
- for id,info in pairs(self.cd_skill_list) do
- self:ClearSkillCD(id)
- end
- end
-
- function SkillManager:ClearSkillCD(skill_id)
- local skillVo = self:getSkill(skill_id)
- if skillVo then
- skillVo:clearCD()
- self:Fire(SkillManager.START_SKILL_CD,skill_id,0)
- end
- end
-
- function SkillManager:LockCD(lock)
- SkillManager:getInstance():Fire(SkillManager.LOCK_CD,lock)
- end
-
- --完成当前攻击后释放的技能
- function SkillManager:SetAttackCompleteSkill(skill_id)
- self.fire_skill_id_after_current_attack = skill_id
- end
-
- function SkillManager:GetAngrySkillVo( )
- local career = RoleManager.Instance.mainRoleInfo.career
- local sex = RoleManager.Instance.mainRoleInfo.sex
- local career_str = career.."@"..sex
- local skill_id = SkillManager.AngerSkill[career_str]
- local skill_vo = self.mySkillList[skill_id]
- return skill_vo
- end
-
- -- 判断是否为怒气技能
- function SkillManager:IsAngrySkill( skill_id )
- for k,v in pairs(SkillManager.AngerSkill) do
- if v == skill_id then
- return true
- end
- end
- return false
- end
-
- function SkillManager:PrepareAutoFightSkill(not_auto_release_assist_skill)
- local now_skill_vo = self:getCurrentSkill()
- if now_skill_vo and not now_skill_vo:CoolDown() then
- now_skill_vo = nil
- end
-
- --怒气技能满足条件就放
- local anger_skill_vo = self:GetAngrySkillVo( )
- local role_vo = RoleManager.Instance.mainRoleInfo
- if anger_skill_vo and role_vo.angry_value > 0 and role_vo.angry_value == role_vo.max_angry_value and anger_skill_vo:CoolDown() then
- -- local can_auto = AutoFightManager:getInstance():FindSkillIsAuto(anger_skill_vo.id)
- -- if can_auto then
- self:setCurrentSkillId(anger_skill_vo.id)
- return anger_skill_vo.id
- -- end
- end
-
- --如果当前没技能,就随机一个
- if now_skill_vo == nil then
- local short_cut_list = self:GetShortCutList()
-
- local main_role = Scene:getInstance():GetMainRole()
- local is_in_god_state = main_role and main_role:IsInGodState()
- if is_in_god_state then
- local id = RoleManager.Instance:GetMainRoleVo():GetGodID()
- short_cut_list = GodModel:getInstance():GetGodSkillList(id)
- end
-
- local skills_can_use = {}
- --把所有可用的非普通攻击技能塞进队列,准备随机一个
- local main_role = Scene.Instance.main_role
- if not main_role then
- return false
- end
-
- local id,skillVo,can_auto
- for i, vo in pairs(short_cut_list) do
- if is_in_god_state then
- id = vo
- else
- id = vo.id
- end
- skillVo = self:getSkill(id)
- if skillVo then
- can_auto = AutoFightManager:getInstance():FindSkillIsAuto(id)
- if can_auto and skillVo:CoolDown() then
- table.insert(skills_can_use, skillVo)
- end
- end
- end
-
- --随机取技能
- if #skills_can_use >= 1 then
- local max_cd_time = 0
- local max_skill_vo = nil
- for i, skillVo in pairs(skills_can_use) do
- if skillVo:getCd() > max_cd_time then
- max_cd_time = skillVo:getCd()
- max_skill_vo = skillVo
- end
- end
- now_skill_vo = max_skill_vo
- if now_skill_vo then
- self:setCurrentSkillId(now_skill_vo.id)
- end
- end
-
- if now_skill_vo == nil then
- local id = self:getBaseSkill()
- self:setCurrentSkillId(id)
- now_skill_vo = self:getSkill(id)
- end
- end
-
- if now_skill_vo ~= nil then
- return now_skill_vo.id
- end
- return nil
- end
-
- -- 宝宝副本定制自动挂机自动技能
- function SkillManager:PrepareAutoFightSkillInBabyDun(not_auto_release_assist_skill)
- local now_skill_vo = self:getCurrentSkill()
- if now_skill_vo and not now_skill_vo:CoolDown() then
- now_skill_vo = nil
- end
- local dun_model = BaseDungeonModel:getInstance()
- --如果当前没技能,就随机一个
- if now_skill_vo == nil then
- -- 获取宝宝副本内技能 (1技能位置|2技能id|3技能解锁波数|4技能释放消耗能量)
- local short_cut_list = dun_model:GetBabyDunSkillList()
- -- 获取宝宝副本内玩家当前能量值
- local energy = dun_model:GetBabyDunEnergyValue()
- local main_role = Scene:getInstance():GetMainRole()
- local skills_can_use = {}
- --把所有可用的非普通攻击技能塞进队列,准备随机一个
- local main_role = Scene.Instance.main_role
- if not main_role then
- return false
- end
- local skill_id, skillVo, can_auto
- for i, cfg_data in pairs(short_cut_list) do
- if energy >= cfg_data[4] then -- 能量满足需求,加入到候选列表中
- skill_id = cfg_data[2]
- skillVo = self:getSkill(skill_id)
- if skillVo then
- can_auto = AutoFightManager:getInstance():FindSkillIsAuto(skill_id)
- if can_auto and skillVo:CoolDown() then
- table.insert(skills_can_use, skillVo)
- end
- end
- end
- end
- --随机取技能
- if #skills_can_use >= 1 then
- local max_cd_time = 0
- local max_skill_vo = nil
- for i, skillVo in pairs(skills_can_use) do
- if skillVo:getCd() > max_cd_time then
- max_cd_time = skillVo:getCd()
- max_skill_vo = skillVo
- end
- end
- now_skill_vo = max_skill_vo
- if now_skill_vo then
- self:setCurrentSkillId(now_skill_vo.id)
- end
- end
-
- if now_skill_vo == nil then
- local id = SkillManager.BabyDunMainRoleBaseSkill
- self:setCurrentSkillId(id)
- now_skill_vo = self:getSkill(id)
- end
- end
-
- if now_skill_vo ~= nil then
- return now_skill_vo.id
- end
- return nil
- end
-
- --提前获取下一个可释放的技能,保证技能连招流畅
- function SkillManager:GetNextSkill( )
- local main_role = Scene.Instance.main_role
- if not main_role then
- return false
- end
-
- --怒气技能
- local anger_skill_vo = self:GetAngrySkillVo( )
- local role_vo = RoleManager.Instance.mainRoleInfo
- if anger_skill_vo and role_vo.angry_value > 0 and role_vo.angry_value == role_vo.max_angry_value and anger_skill_vo:CoolDown() then
- return anger_skill_vo.id
- end
- --随机取技能
- local skills_can_use = {}
- for id, skill_vo in pairs(self.skillUseList) do
- if skill_vo then
- local can_auto = AutoFightManager:getInstance():FindSkillIsAuto(id)
- if can_auto and skill_vo:CoolDown() then
- table.insert(skills_can_use, skill_vo)
- end
- end
- end
- local now_skill_vo
- if #skills_can_use >= 1 then
- local max_cd_time = 0
- local max_skill_vo = nil
- for i, skillVo in pairs(skills_can_use) do
- if skillVo:getCd() > max_cd_time then
- max_cd_time = skillVo:getCd()
- max_skill_vo = skillVo
- end
- end
- now_skill_vo = max_skill_vo
- if now_skill_vo then
- return now_skill_vo.id
- end
- end
- --随机普攻
- if now_skill_vo == nil then
- local id = self:getBaseSkill()
- return id
- end
- end
-
- --主角是否可以发起攻击
- function SkillManager:CanAttack(skill_id,show_tip)
- local main_role = Scene.Instance.main_role
- if main_role == nil then
- return false
- end
- if main_role:IsInState(PoseState.DEAD) or main_role:IsInState(PoseState.DOWN) or main_role:IsInState(PoseState.RISE) or main_role:IsInState(PoseState.HITED)
- or main_role:IsInState(PoseState.RUSH) or main_role:IsInState(PoseState.JUMP)
- or main_role:IsInState(PoseState.FLY_SHOE) or main_role:IsInState(PoseState.TASK_JUMP)
- or main_role:IsSwimState() then
- return false
- end
- local tip_str = ""
- if skill_id then
- local skillVo = self:getSkill(skill_id)
- if skillVo == nil then
- print("取不到技能信息??: skill_id:", skill_id)
- return false
- end
- if self:isInRigidity() then
- if show_tip and skill_id ~= SkillManager.JUMP_SKILL_ID and skillVo:CoolDown() then
- self:AddCacheSkill(skill_id)
- end
- return false
- end
-
- local main_role_buff = main_role.buff_manager
- if skill_id ~= self:getBaseSkill() and skillVo:CoolDown() == false then
- tip_str = "技能冷却时间未到"
- elseif RoleManager.Instance.mainRoleInfo.ghost_mode == 1 then
- tip_str = "幽灵状态,不能发起攻击"
- -- elseif skillVo:getAnger() > RoleManager.Instance.mainRoleInfo.anger then
- -- tip_str = "怒气不足"
- elseif main_role_buff:hasYunBuff() then
- tip_str = "眩晕状态不能释放技能"
- -- elseif main_role_buff:hasMabiBuff() then
- -- tip_str = "麻痹状态不能释放技能"
- -- elseif main_role_buff:hasDingshenBuff() then
- -- tip_str = "定身状态不能释放技能"
- -- elseif main_role_buff:hasHunluanBuff() then
- -- tip_str = "混乱状态不能释放技能"
- -- elseif main_role_buff:hasChanraoBuff() then
- -- tip_str = "缠绕状态不能释放技能"
- -- elseif main_role_buff:hasTuidingBuff() then
- -- tip_str = "推顶状态不能释放技能"
- -- elseif main_role:IsInMagic() then
- -- tip_str = "补魔状态不能释放技能"
- elseif main_role.is_shoe_flying then
- tip_str = "传送状态不能释放技能"
- -- elseif main_role_buff:hasChenMoBuff() then --沉默只能释放普攻
- -- if not SkillManager.ThreeAttackSkillInfo[skill_id] then
- -- tip_str = "沉默状态只能释放普攻"
- -- end
- end
-
- end
- if tip_str ~= "" then
- if show_tip then
- Message.show(tip_str)
- end
- return false
- else
- return true
- end
- end
-
- SkillManager.SKILL_SHORTCUT_GRAY = {}
- SkillManager.SKILL_SHORTCUT_GRAY.buff = 0x001
- SkillManager.SKILL_SHORTCUT_GRAY.scene = 0x002
- SkillManager.SKILL_SHORTCUT_GRAY.manul_forbid = 0x004
- SkillManager.SKILL_SHORTCUT_GRAY.horse = 0x008
- SkillManager.SKILL_SHORTCUT_GRAY.hun_luan = 0x010
- SkillManager.SKILL_SHORTCUT_GRAY.all = SkillManager.SKILL_SHORTCUT_GRAY.buff + SkillManager.SKILL_SHORTCUT_GRAY.scene + SkillManager.SKILL_SHORTCUT_GRAY.manul_forbid + SkillManager.SKILL_SHORTCUT_GRAY.horse
- + SkillManager.SKILL_SHORTCUT_GRAY.hun_luan
- function SkillManager:SetSkillShortcutGray(flag, gray)
- local now_flag = 0
- if gray then
- now_flag = bit.bor(self.shortcut_gray_flag, flag)
- else
- now_flag = bit.band(self.shortcut_gray_flag, bit.bnot(flag))
- end
- -- if now_flag == self.shortcut_gray_flag then
- -- print("SetSkillShortcutGraySetSkillShortcutGraySetSkillShortcutGraySetSkillShortcutGray")
- -- return
- -- end
- self.shortcut_gray_flag = now_flag
- if self.shortcut_gray_flag > 0 and gray then
- SkillManager.getInstance():Fire(SkillManager.SHORT_CUT_SKILL_ACTIVE, false, flag)
- elseif self.shortcut_gray_flag == 0 and not gray then
- SkillManager.getInstance():Fire(SkillManager.SHORT_CUT_SKILL_ACTIVE, true, flag)
- end
- end
-
- function SkillManager:IsSkillShortcutGray(index)
- --沉默不置灰普攻
- if index == 0 and self.shortcut_gray_flag == SkillManager.SKILL_SHORTCUT_GRAY.buff then
- return false
- end
-
- return self.shortcut_gray_flag > 0
- end
-
-
- function SkillManager:ChangeGodsInfo(god_list)
- local temp_state = -1
- if RoleManager.Instance.mainRoleInfo.god_id > 0 then
- temp_state = 3
- else
- if god_list and god_list then
- local vo = nil
- local len = #god_list
- local has_go_out = false
- if len > 0 then
- for i = 1, len do
- vo = god_list[i]
- if vo.pos > 0 then
- has_go_out = true
- temp_state = 2
- break
- end
- end
- if not has_go_out then
- temp_state = 1
- end
- else
- temp_state = 0
- end
- end
- end
-
- self.curr_god_state = temp_state
- end
-
- function SkillManager:IsGodFullEnergy()
- return self.curr_god_dot > 0 and self.curr_god_dot >= self.max_dot
- end
-
- function SkillManager:SetReplaceSkillInfo(info)
- self.replaceSkillList[info.skill_id] = info
- self.replaceNewSkillList[info.new_skill_id] = info
- --变身将神不需要
- if self.curr_god_state ~= 3 then
- self:Fire(SkillManager.UPDATE_SKILL_LIST)
- end
- end
-
- function SkillManager:IsReplaceSkillId(skill_id)
- return self.replaceNewSkillList[skill_id]
- end
-
- function SkillManager:RemoveReplaceSkillInfo(skill_id)
- local info = self.replaceNewSkillList[skill_id]
- if info then
- self.replaceSkillList[info.skill_id] = nil
- self.replaceNewSkillList[info.new_skill_id] = nil
- self:Fire(SkillManager.UPDATE_SKILL_LIST)
- end
- end
-
- function SkillManager:SetCanUseHitSkill(bool)
- self.can_use_hit_skill = bool
- end
-
- function SkillManager:IsCanUseHitSkill()
- return self.can_use_hit_skill
- end
-
- function SkillManager:AddHideBlackViews(layout_file)
- self.hide_black_views_list[layout_file] = true
- end
-
- function SkillManager:RemoveHideBlackViews(layout_file)
- self.hide_black_views_list[layout_file] = nil
- end
-
- function SkillManager:NeedHideSkillBlack()
- return TableSize(self.hide_black_views_list) > 0
- end
-
- --被动技能id列表
- function SkillManager:GetPassiveSkillList()
- local t = {}
- for k, v in pairs(SkillManager.PassivesSkillTypeList) do
- table.insert(t, k)
- end
- if TableSize(t) >= 2 then
- table.sort(t, function (a,b)
- return a < b
- end)
- end
- return t
- end
-
- --设置幻光技能
- function SkillManager:SetDailyLightSkillList(vo)
- self.dailyLightSkill = {}
- self.otherSkillList = self.otherSkillList or {}
- if vo then
- self.dailyLightSkill.cur_skill = vo.use_skill_id
- self.dailyLightSkill.list = {}
- for i,v in ipairs(vo.skill_list) do
- local skillVo = self:getSkill(v.skill_id) --SkillVo.New(v.skill_id)
- skillVo.level = v.lv
- self.dailyLightSkill.list[i] = skillVo
- self.otherSkillList[v.skill_id] = skillVo
- end
- end
- -- print("self.dailyLightSkill.list")
- -- PrintTable(self.dailyLightSkill.list)
- end
-
- --切换幻光技能
- function SkillManager:SetSwitchDailyLightSkill(skill_id)
- self.dailyLightSkill.cur_skill = skill_id
- end
-
- --获取当前激活的幻光技能
- function SkillManager:GetCurDailyLightSkill()
- local vo
- if self.dailyLightSkill.cur_skill and self.dailyLightSkill.list then
- for i,v in ipairs(self.dailyLightSkill.list) do
- if v.id == self.dailyLightSkill.cur_skill then
- vo = v
- break
- end
- end
- end
- return vo
- end
-
- --获取当前使用的幻光技能id
- function SkillManager:GetCurrentUseDailyLightSkillId()
- if self.dailyLightSkill and self.dailyLightSkill.cur_skill then
- return self.dailyLightSkill.cur_skill
- end
- return 0
- end
-
- --获取下一个幻光技能
- function SkillManager:GetNextDailyLightSkill()
- local skill_id = 0
- if self.dailyLightSkill.cur_skill and self.dailyLightSkill.list and #self.dailyLightSkill.list > 1 then
- local len = #self.dailyLightSkill.list
- local idx = 0
- for i,v in ipairs(self.dailyLightSkill.list) do
- if v.id == self.dailyLightSkill.cur_skill then
- idx = i
- break
- end
- end
- if idx == len then
- idx = 1
- else
- idx = idx + 1
- end
- skill_id = self.dailyLightSkill.list[idx].id
- end
- return skill_id
- end
-
- --是否学习了该幻光技能
- function SkillManager:IsLearnDailyLightSkill(skill_id)
- if self.dailyLightSkill.list and #self.dailyLightSkill.list > 0 then
- for i,v in ipairs(self.dailyLightSkill.list) do
- if v.id == skill_id then
- return true
- end
- end
- end
- return false
- end
-
- --获取当前方案所有出战技能列表
- function SkillManager:GetCurShortcutList()
- local plan = self.cur_shortcut_plan
- if self.all_plan_skill and self.all_plan_skill[plan] then
- local t = self.all_plan_skill[plan].shortcutList
- for i=1,8 do
- if not t[i] then
- t[i] = {}
- t[i].pos = i
- t[i].id = 0
- end
- end
- return t
- end
- return {}
- end
-
- --获取当前技能僵直,受到动作倍速影响
- function SkillManager:GetBackSwing( skill_id )
- -- if self.skill_back_swing_list[skill_id] then
- -- return self.skill_back_swing_list[skill_id]
- -- end
-
- local skill_cfg = self:GetFightSkillMovie(skill_id)
- -- if not skill_cfg then
- -- return 0
- -- end
- local back_swing = skill_cfg.back_swing
- -- if skill_cfg.action_speed_info then
- -- local start_time = skill_cfg.action_speed_info.start_time
- -- local end_time = skill_cfg.action_speed_info.end_time
- -- local action_speed = skill_cfg.action_speed_info.action_speed
- -- local change_time = end_time == 0 and back_swing - start_time or end_time - start_time
- -- local change_speed_time = action_speed * change_time
- -- if change_speed_time > back_swing then
- -- back_swing = back_swing / action_speed
- -- else
- -- back_swing = change_time + (back_swing - change_speed_time)
- -- end
- -- end
- -- self.skill_back_swing_list[skill_id] = back_swing
- return back_swing
- end
-
- --设置当前技能的多段伤害数据
- function SkillManager:SetMultiHurtInfo( skill_id, pos_x, pos_y)
- local m_skill_vo = self.multi_skill_list[skill_id]
- --检查缓存技能
- if m_skill_vo then
- --非多段技能
- if not m_skill_vo.is_multi_skill then
- return 0
- else
- --多段技能,记录第一段技能的中心点
- if m_skill_vo.index == 1 then
- m_skill_vo.pos_x, m_skill_vo.pos_y = pos_x, pos_y
- end
- --到上限重置
- if m_skill_vo.index >= m_skill_vo.segment then
- m_skill_vo.index = 1
- return 0
- else
- return m_skill_vo.interval
- end
- end
- else
- --检查新技能
- local skill_vo = self:getSkill(skill_id)
- if not skill_vo then
- return 0
- end
- local m_segment, m_interval = skill_vo:getMultiHurtInfo()
- if m_segment and m_segment > 1 and m_interval and m_interval > 0 then
- local temp_vo = {
- is_multi_skill = true,
- skill_id = skill_id,
- index = 1,
- segment = m_segment,
- interval = m_interval,
- pos_x = pos_x,
- pos_y = pos_y,
- }
- self.multi_skill_list[skill_id] = temp_vo
- return m_interval
- else
- self.multi_skill_list[skill_id] = {is_multi_skill = false}
- return 0
- end
- end
- end
-
- --获取当前技能的多段伤害数据,每次累增多段伤害序列
- function SkillManager:GetMultiHurtVo( skill_id )
- local m_skill_vo = self.multi_skill_list[skill_id]
- if m_skill_vo and m_skill_vo.is_multi_skill then
- m_skill_vo.index = m_skill_vo.index + 1
- return m_skill_vo
- end
- return false
- end
-
- function SkillManager:ResetMultiHurtInfo( skill_id )
- if skill_id and self.multi_skill_list[skill_id] and self.multi_skill_list[skill_id].index then
- self.multi_skill_list[skill_id].index = 1
- end
- end
-
- --新手期特殊技能表现
- function SkillManager:PrepareGuideSkill( )
- local career = RoleManager.Instance.mainRoleInfo.career
- local sex = RoleManager.Instance.mainRoleInfo.sex
- local career_str = career.."@"..sex
- local show_skill_list = self.guide_skill_list[career_str] and self.guide_skill_list[career_str].show_list
- local real_skill_list = self.guide_skill_list[career_str] and self.guide_skill_list[career_str].real_list
- if not show_skill_list or not real_skill_list or self.cur_guide_skill_index > #show_skill_list then
- return
- end
- local skill_id = show_skill_list[self.cur_guide_skill_index]
- local real_skill_id = real_skill_list[self.cur_guide_skill_index]
- if skill_id and real_skill_id then
- self:setCurrentSkillId(skill_id)
- self.cur_guide_skill_index = self.cur_guide_skill_index + 1
- return skill_id, real_skill_id
- end
- end
-
- --是否是上阵的技能
- function SkillManager:IsCurShortcutSkill(skill_id)
- local list = self:GetCurShortcutList()
- if list then
- for i,v in ipairs(list) do
- if skill_id == v.id then
- return true
- end
- end
- end
- return false
- end
-
- --是否是上阵的技能
- function SkillManager:IsShowSpecialSkill(skill_id)
- return Config.ConfigSkillUI.ShowSpecialSkill[skill_id]
- end
-
-
-
|