|
|
- require("game.proto.210.Require210")
- require("game.skill.SkillManager")
- require("game.skill.SkillMainView")
- require("game.skill.CareerSkillView")
- require("game.skill.PassiveSkillView")
- require("game.skill.SkillUIItem")
- require("game.skill.SkillUIAttrOne")
- require("game.skill.SkillUIDetailItem")
- require("game.skill.SkillUIListItem")
- require("game.skill.SpecialSkillView")
- require("game.skill.SkillUpLevelPreView")
- require("game.skill.SkillConfigView")
- require("game.skill.SkillUIModel")
-
-
- SkillUIController = SkillUIController or BaseClass(BaseController)
- local SkillUIController = SkillUIController
-
- function SkillUIController:__init()
- SkillUIController.Instance = self
- self.model = SkillManager:getInstance()
- self.skillui_model = SkillUIModel:getInstance()
- self:AddAllEvents()
- self:RegisterAllProtocals()
-
- end
-
- function SkillUIController:AddAllEvents()
- --游戏登录成功
- local game_start_func = function ( )
- self.model:ClearData()
- setTimeout(function()
- self.request_21002 = true
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21002)
- self:StartCheckNetSlowTimer()
- GlobalEventSystem:Fire(EventName.GET_DAILY_LIGHT_SKILL)
- -- self:SendFmtToGame(13086)
- end,0.5)
- end
- GlobalEventSystem:Bind(EventName.FAST_GAME_START, game_start_func)
-
- local function onRequestHandler(...)
- local args = {...}
- if args[1] == 21001 then
- self:SendFmtToGame(args[1],"i",args[2])
- elseif args[1] == 21003 then
- self:SendFmtToGame(args[1],"i",args[2])
- elseif args[1] == 21004 then
- self:SendFmtToGame(args[1],"i",args[2])
- elseif args[1] == 21011 then
- self:SendFmtToGame(args[1], "i", args[2])
- elseif args[1] == 21014 then
- self:SendFmtToGame(args[1], "ii", args[2],args[3])
- else
- self:SendFmtToGame(args[1])
- end
- end
- self.model:Bind(SkillManager.REQUEST_CCMD_EVENT,onRequestHandler)
- local function onOpenSkillViewHandler(index,select_up_skill)
- if self.SkillMainView == nil then
- self.SkillMainView = SkillMainView.New()
- end
- if self.SkillMainView:HasOpen() and index ~= 4 then
- self.SkillMainView:Close()
- else
- self.SkillMainView:Open(index,select_up_skill)
- end
- end
-
- GlobalEventSystem:Bind(EventName.OPEN_SKILL_VIEW,onOpenSkillViewHandler)
- --点按技能快捷栏后响应
- local function skill_shortCut_click (skillId, skill_attack_type, target_compress_id)
- self:PressSkillHandler(skillId, skill_attack_type, target_compress_id)
- end
- GlobalEventSystem:Bind(FightEvent.SKILL_SHORTCUT_CLICK,skill_shortCut_click)
-
- local function save_skill_shortcut (pos, itype, plan, id, is_auto )
- self:request13008(pos, itype, plan, id, is_auto )
- end
- local function request13007 ()
- self:request13007()
- end
- local function request13009 (pos)
- self:request13009(pos)
- end
- local function request13010 (pos1,pos2,plan)
- self:request13010(pos1,pos2,plan)
- end
- local function request14705 ()
- self:request14705()
- end
- local function request14706 (skill_id)
- self:request14706(skill_id)
- end
- GlobalEventSystem:Bind(EventName.GET_SKILL_SHORTCUT,request13007)
- GlobalEventSystem:Bind(EventName.SAVE_SKILL_SHORTCUT,save_skill_shortcut)
- GlobalEventSystem:Bind(EventName.REPLACE_SKILL_SHORTCUT,request13010)
- GlobalEventSystem:Bind(EventName.DELETE_SKILL_SHORTCUT,request13009)
- GlobalEventSystem:Bind(EventName.GET_DAILY_LIGHT_SKILL,request14705)
- GlobalEventSystem:Bind(EventName.SWITCH_DAILY_LIGHT_SKILL,request14706)
-
- -- 升级 重新请求天赋技能点数
- local function onLevelUp(lv)
- --120级,设置一下幻光技能未为自动切换
- if lv == 120 then
- local is_auto_daily_skill = self.skillui_model:IsAutoChangeDailySkillid()
- if not is_auto_daily_skill then
- self.skillui_model:SetAutoChangeDailyState(true)
- end
- end
- if RoleManager:getInstance():GetMainRoleVo().level == 500 then
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21010)
- end
- self.skillui_model:CheckRedDot()
- end
- RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
-
-
- local function role_turn(var,value)
- self.skillui_model:CheckRedDot()
- end
- RoleManager:getInstance():GetMainRoleVo():BindOne("turn",role_turn)
-
-
- local function onOpenSkillUpLevelPreView(skill_vo) --打开技能等级预览界面
- if self.SkillUpLevelPreView == nil then
- self.SkillUpLevelPreView = SkillUpLevelPreView.New()
- end
- self.SkillUpLevelPreView:Open()
- self.SkillUpLevelPreView:SetData(skill_vo)
- end
- self.skillui_model:Bind(SkillUIModel.OPEN_SKILL_UPLEVEL_PREVIEW, onOpenSkillUpLevelPreView)
-
- local function onCloseSkillUpLevelPreView(skill_vo) --打开技能等级预览界面
- if self.SkillUpLevelPreView then
- self.SkillUpLevelPreView:Close()
- end
- end
- self.skillui_model:Bind(SkillUIModel.CLOSE_SKILL_UPLEVEL_PREVIEW, onCloseSkillUpLevelPreView)
-
-
- local function onOpenSkillConfigView() --打开技能配置界面
- if self.SkillConfigView == nil then
- self.SkillConfigView = SkillConfigView.New()
- end
- self.SkillConfigView:Open()
- self.SkillConfigView:SetData()
- end
- self.skillui_model:Bind(SkillUIModel.OPEN_SKILL_CONFIG_VIEW, onOpenSkillConfigView)
-
- local function onSceneChangeHandler()
- self:ChangeScene()
- end
- self:Bind(SceneEventType.SCENE_CHANGED, onSceneChangeHandler)
- self:Bind(SceneEventType.SCENE_REENTER, onSceneChangeHandler)
-
- end
-
- function SkillUIController:RegisterAllProtocals()
- self:RegisterProtocal(13007, "handler13007") --获取快捷栏
- self:RegisterProtocal(13008, "handler13008") --保存快捷栏
- self:RegisterProtocal(13010, "handler13010") --替换快捷键
- self:RegisterProtocal(13086, "handler13086") --怒气技能
-
- self:RegisterProtocal(21001, "handler21001") --职业技能升级
- self:RegisterProtocal(21002, "handler21002") --职业技能列表
- self:RegisterProtocal(21003, "handler21003") --主技能分支强化
-
- self:RegisterProtocal(14705, "handler14705") --查询幻光技能
- self:RegisterProtocal(14706, "handler14706") --切换幻光技能
- self:RegisterProtocal(14707, "handler14707") --幻光技能获得通知
-
-
-
-
-
-
-
-
- --self:RegisterProtocal(21004, "handler21004") --被动升级
- --self:RegisterProtocal(21010, "handler21010")
- --self:RegisterProtocal(21011, "handler21011")
- --self:RegisterProtocal(21012, "handler21012")
- --self:RegisterProtocal(21013, "handler21013")
- --self:RegisterProtocal(21014, "handler21014")
- --self:RegisterProtocal(21015, "handler21015")
- -- self:RegisterProtocal(44008, "handler44008")
- -- self:RegisterProtocal(44009, "handler44009")
- -- self:RegisterProtocal(44010, "handler44010")
- -- self:RegisterProtocal(44011, "handler44011")
- end
-
- function SkillUIController:request13007()
- self:SendFmtToGame(13007)
- end
-
- function SkillUIController:request13008(pos, itype, plan, id, is_auto )
- self:SendFmtToGame(13008, "cccic",pos, itype, plan, id, is_auto)
- end
-
- function SkillUIController:request13010( pos1,pos2, plan )
- self:SendFmtToGame(13010, "ccc",pos1,pos2,plan)
- end
-
- function SkillUIController:request14705( )
- self:SendFmtToGame(14705)
- end
-
- function SkillUIController:request14706( skill_id )
- self:SendFmtToGame(14706, "i", skill_id)
- end
-
- function SkillUIController:handler13007( ... )
- local len = self:ReadFmt("h") --Int16
- self.model.shortcutList = {}
- self.model.skillUseList = {}
- self.model.all_plan_skill = {}
- local skill_vo
- for index = 1, len do
- local plan = self:ReadFmt("c")
- self.model.all_plan_skill[plan] = {}
- self.model.all_plan_skill[plan].skillUseList = {}
- self.model.all_plan_skill[plan].shortcutList = {}
- local len_2 = self:ReadFmt("h") --Int16
- for inde_2 = 1, len_2 do
- local vo = {}
- vo.pos,
- vo.type,
- vo.id,
- vo.is_auto = self:ReadFmt("ccic")
- if vo.id ~= 0 then
- skill_vo = self.model:getSkill(vo.id)
- if skill_vo then
- self.model.all_plan_skill[plan].skillUseList[vo.id] = skill_vo
- self.model.all_plan_skill[plan].shortcutList[vo.pos] = vo
-
- end
- end
- end
- end
- local cur_plan = self.cur_shortcut_plan or 1
- if self.model.all_plan_skill[cur_plan] then
- self.model.shortcutList = self.model.all_plan_skill[cur_plan].shortcutList
- self.model.skillUseList = self.model.all_plan_skill[cur_plan].skillUseList
- end
- SkillManager.Instance:Fire(SkillManager.UPDATE_SKILL_LIST)
- end
-
- function SkillUIController:handler13008( ... )
- local result = self:ReadFmt("c")
- if result == 1 then
- Message.show("替换成功")
- self:request13007()
- else
- Message.show("替换失败")
- end
- end
-
- function SkillUIController:handler13009( ... )
- local result = self:ReadFmt("c")
- if result == 1 then
- self:request13007()
- end
- end
-
- function SkillUIController:handler13010( ... )
- local result = self:ReadFmt("c")
- if result == 1 then
- Message.show("替换成功")
- self:request13007()
- else
- Message.show("替换失败")
- end
- end
-
- --怒气值变更
- function SkillUIController:handler13086( )
- local angry_value, max_angry_value = self:ReadFmt("hh")
- RoleManager.Instance.mainRoleInfo.max_angry_value = max_angry_value
- RoleManager.Instance.mainRoleInfo:ChangeVar("angry_value", angry_value, false, true)
- end
-
-
- function SkillUIController:handler14705( ... )
- local scmd = SCMD14705.New(true)
- self.model:SetDailyLightSkillList(scmd)
- GlobalEventSystem:Fire(EventName.UPDATE_DAILY_LIGHT_SKILL)
- self.model:Fire(SkillManager.UPDATE_SKILL_LIST)
- end
-
- function SkillUIController:handler14706( ... )
- local scmd = SCMD14706.New(true)
- if scmd.result == 1 then
- local skill_id = scmd.skill_id
- self.model:SetSwitchDailyLightSkill(skill_id)
- GlobalEventSystem:Fire(EventName.UPDATE_DAILY_LIGHT_SKILL)
- local skill_vo = self.model:getSkill(skill_id)
- Message.show(string.format("已切换至%s", skill_vo:getName()))
- else
- ErrorCodeShow(scmd.result)
- end
- end
-
- function SkillUIController:handler14707( )
- local scmd = SCMD14707.New(true)
- -- if scmd.skill_id > 0 then
- -- --120001 是第一个幻光技能,需要飘动画
- -- local id = 0
- -- local ignore_fly = nil
- -- local ignore_auto_task = true
- -- if scmd.skill_id == 120001 then
- -- id = 9
- -- ignore_fly = false
- -- ignore_auto_task = false
- -- GlobalEventSystem:Fire(EventName.HIDE_FUNC_OPEN_ICON,{[1] = {type =2, id=9}}) --隐藏幻光技能
- -- end
- -- local skill_data = {skill_id = scmd.skill_id, show_time = 15, ignore_auto_task = ignore_auto_task, id = id, ignore_fly = ignore_fly}
- -- FuncOpenController.Instance:ShowSkill(skill_data)
- -- end
- end
-
- function SkillUIController:handler21001()
- local scmd = SCMD21001.New(true)
- if scmd.errcode ~= 1 then
- ErrorCodeShow(scmd.errcode)
- --物品不足,提示购买
- if scmd.errcode == 1003 then
- local skill_vo = self.model:getSkill(scmd.skill_id)
- if not skill_vo then
- skill_vo = SkillVo.New(scmd.skill_id)
- skill_vo = 0
- end
- local show_type_id = 0
- local goods = skill_vo:GetNextConditionByKey("goods")
- if goods and goods[1][1] and goods[1][2] then
- local type_id = tonumber(goods[1][1])
- local cfg = ShopModel:getInstance():GetShopTypeIdBuyCFG(type_id)
- if cfg and TableSize(cfg) > 0 then
- show_type_id = type_id
- end
- end
- if show_type_id ~= 0 then
- ShopModel:getInstance():Fire(ShopModel.OPEN_SHOP_BUY_TIP_VIEW,show_type_id)
- end
- end
- else
-
- --延时一点点做客升级技能的切换操作
- local function delay_func()
- self.skillui_model:Fire(SkillUIModel.SKILL_UP_SUCCESS, scmd.skill_id)
- end
- setTimeout(delay_func, 0.2)
- self.skillui_model.is_level_up = true
- GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
- end
- end
-
- function SkillUIController:handler21002()
- if self.request_21002 then
- self.model:Fire(SkillManager.RESET_SKILL_LIST)
- self.request_21002 = false
- end
- self.model:CreateSkillList()
- self.skillui_model:CheckRedDot()
- GlobalEventSystem:Fire(EventName.UPDATE_BUFF_VIEW)
- end
-
- function SkillUIController:handler21003()
- local scmd = SCMD21003.New(true)
- if scmd.errcode ~= 1 then
- ErrorCodeShow(scmd.errcode)
- else
- self.model:Fire(SkillManager.SKILL_LEVEL_UP)
- end
- end
-
- function SkillUIController:handler21004()
- local scmd = SCMD21004.New(true)
- if scmd.errcode ~= 1 then
- ErrorCodeShow(scmd.errcode)
- end
- end
-
- function SkillUIController:handler21010( )
- local scmd = SCMD21010.New(true)
- end
-
- function SkillUIController:handler21011( )
- local scmd = SCMD21011.New(true)
- if scmd.errcode == 1 then
- --更新数据
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21010)
- else
- ErrorCodeShow(scmd.errcode)
- end
- end
-
- function SkillUIController:handler21012( )
- local scmd = SCMD21012.New(true)
- if scmd.errcode == 1 then
- else
- ErrorCodeShow(scmd.errcode)
- end
- end
-
- function SkillUIController:handler21013( )
- local scmd = SCMD21013.New(true)
- end
-
- function SkillUIController:handler21014( )
- local scmd = SCMD21014.New(true)
- if scmd.errcode == 1 then
-
- else
- ErrorCodeShow(scmd.errcode)
- end
- end
-
- function SkillUIController:handler21015( )
- local scmd = SCMD21015.New(true)
- SkillManager:getInstance():SetReplaceSkillInfo(scmd)
- end
-
- --按下技能
- function SkillUIController:PressSkillHandler(skill_id, skill_attack_type, target_compress_id)
- if Scene.Instance:GetRole(RoleManager.Instance.mainRoleInfo.role_id):IsRide() then
- FosterModel:GetInstance():Fire(FosterConst.Change_Ride_Status,0)
- end
- local can_pk = true
- if skill_attack_type ~= SkillManager.SKILL_ATTACK_TYPE.ONLY_SHOW_RANGE then
- if not self.model:CanAttack(skill_id,true) then
- can_pk = false
- else
- can_pk = true
- end
- -- OperateManager.Instance:StopMove()
- end
- if can_pk == false then
- if skill_attack_type ~= SkillManager.SKILL_ATTACK_TYPE.ONLY_FIRE_ATTACK and not SkillManager:getInstance():isInRigidity() then
- skill_attack_type = SkillManager.SKILL_ATTACK_TYPE.ONLY_SHOW_RANGE
- self.model:setCurrentSkillId(nil)
- GlobalEventSystem:Fire(FightEvent.RELEASE_MAIN_SKILL,nil,skill_id,target_compress_id,skill_attack_type)
- end
- return
- end
- self.model:setCurrentSkillId(skill_id)
-
- local skillvo = self.model:getCurrentSkill()
- if skillvo and skillvo:GetSelectType() == 1 then --对自己释放技能
- GlobalEventSystem:Fire(FightEvent.RELEASE_MAIN_SKILL,nil,nil,target_compress_id,skill_attack_type)
- else
- Scene.Instance:MainRoleAttackTarget()
- end
- end
-
- function SkillUIController:handler44008()
- local vo = SCMD44008.New(true)
- -- PrintTable(vo)
- self.model.start_time = vo.start_time
- self.model.server_time = vo.server_time
- self.model.every_time_dot = vo.every_time_dot
- self.model.max_dot = vo.max_dot
-
- --只有变身状态才需要进行定时器 变化
- if self.model.curr_god_state == 2 or self.model.curr_god_state == 3 then
- if self.add_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.add_god_dot_timer_id)
- self.add_god_dot_timer_id = false
- end
-
- if self.reduce_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.reduce_god_dot_timer_id)
- self.reduce_god_dot_timer_id = false
- end
-
- if vo.start_time > 0 then --代表累加
- local dot = math.floor(vo.server_time - vo.start_time) * vo.every_time_dot + vo.anger_dot
- dot = math.min(dot,self.model.max_dot)
- if dot >= vo.max_dot then
- self.model:ChangeVar("curr_god_dot", vo.max_dot, nil, true)
- if self.add_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.add_god_dot_timer_id)
- self.add_god_dot_timer_id = false
- end
- return
- end
- self.model:ChangeVar("curr_god_dot", dot)
- if not self.add_god_dot_timer_id then
- local function onTimer()
- local dot = self.model.curr_god_dot + self.model.every_time_dot
- dot = math.min(dot,self.model.max_dot)
- self.model:ChangeVar("curr_god_dot", dot)
- if dot >= self.model.max_dot then
- if self.add_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.add_god_dot_timer_id)
- self.add_god_dot_timer_id = false
- end
- return
- end
- end
- self.add_god_dot_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
- end
- elseif vo.start_time == 0 then --代表减少
- --神格副本持续变身
- if SceneManager.Instance:IsContinueChangeGodScene() then
- local dot = self.model.max_dot - 1
- self.model:ChangeVar("curr_god_dot", dot)
- else
- local real_switch_cd = vo.server_time + vo.switch_cd - TimeUtil:getServerTime( )
- local every_time_dot = vo.max_dot / real_switch_cd
-
- local dot = self.model.max_dot - 1
- --这里 不能加 因为切场景会需要当前的curr_god_dot的值
- -- self.model:ChangeVar("curr_god_dot", dot)
-
- local dot = self.model.curr_god_dot - 1
- self.model.switch_cd = real_switch_cd
- if real_switch_cd <= 0 then
- if self.reduce_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.reduce_god_dot_timer_id)
- self.reduce_god_dot_timer_id = false
- end
- self.model:ChangeVar("curr_god_dot", 0, nil, true, true)
- return
- end
- self.model:ChangeVar("curr_god_dot", dot)
-
- if not self.reduce_god_dot_timer_id then
- local function onTimer()
- self.model.switch_cd = self.model.switch_cd - 1
- local dot = self.model.curr_god_dot - every_time_dot
- dot = math.max(0,dot)
- self.model:ChangeVar("curr_god_dot", dot)
- if self.model.switch_cd <= 0 then
- if self.reduce_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.reduce_god_dot_timer_id)
- self.reduce_god_dot_timer_id = false
- end
- self.model:ResetThreeAttackIndex(true)
- end
- end
- self.reduce_god_dot_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,real_switch_cd)
- end
- end
- end
- setTimeout(function ()
- self.model:Fire(SkillManager.UPDATE_SKILL_LIST)
- end,0.1)
- else
- if self.add_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.add_god_dot_timer_id)
- self.add_god_dot_timer_id = false
- end
-
- if self.reduce_god_dot_timer_id then
- GlobalTimerQuest:CancelQuest(self.reduce_god_dot_timer_id)
- self.reduce_god_dot_timer_id = false
- end
-
- self.model:ChangeVar("curr_god_dot", 0, nil, true, true)
- end
- end
-
- function SkillUIController:handler44009()
- local vo = SCMD44009.New(true)
- if vo then
- self.model.is_receive44009 = true
- if vo.errcode == 1 then
- self.model:ResetThreeAttackIndex(true)
- else
- ErrorCodeShow(vo.errcode)
- end
- end
- end
-
- function SkillUIController:handler44010()
- local anger_dot = UserMsgAdapter.ReadFmt("h") or 0
- --local vo = SCMD44010.New(true)
- if self.model.curr_god_state == 2 then
- local dot = self.model.curr_god_dot + anger_dot
- dot = math.min(dot,self.model.max_dot)
- self.model:ChangeVar("curr_god_dot", dot)
- end
- end
-
- function SkillUIController:handler44011()
- local vo = SCMD44011.New(true)
- if vo.type == 2 then --变身结束
- self.model.curr_god_state = -1
- self.model.curr_god_dot = 0
- self.model.max_dot = 0
- --强制设置为 0
- RoleManager.Instance.mainRoleInfo:ChangeVar("god_id",0)
- setTimeout(function ()
- self.model:Fire(SkillManager.UPDATE_SKILL_LIST)
- end,0.1)
-
-
- else
- RoleManager.Instance.mainRoleInfo:ChangeVar("god_id",GuideModel.CHANGE_GOD_ID)
- setTimeout(function ()
- self.model:Fire(SkillManager.UPDATE_SKILL_LIST)
- end,0.1)
- end
- end
-
- function SkillUIController:StartCheckNetSlowTimer()
- if self.countdown_time_id then
- GlobalTimerQuest:CancelQuest(self.countdown_time_id)
- self.countdown_time_id = nil
- end
-
- local function onTimer()
- if self.request_21002 then
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21002)
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21010)
- self.model:Fire(SkillManager.REQUEST_CCMD_EVENT,21013)
- else
- if self.countdown_time_id then
- GlobalTimerQuest:CancelQuest(self.countdown_time_id)
- self.countdown_time_id = nil
- end
- end
- end
- self.countdown_time_id = GlobalTimerQuest:AddPeriodQuest(onTimer,8)
- end
-
-
- --技能材料变化
- function SkillUIController:UpSkillGoodsChange( )
- self.skillui_model:CheckRedDot()
- end
-
- function SkillUIController:ChangeScene()
- local sceneInfo = SceneManager.Instance:GetSceneInfo()
- if not sceneInfo then return end
- local config = Config.Skillscenesetting
- local plan = 1
- for k,v in pairs(config) do
-
- if v.scene_type == sceneInfo.type then
- plan = v.scheme
- break
- end
- end
- if self.model.cur_shortcut_plan ~= plan then
- self.model.cur_shortcut_plan = plan
- if self.all_plan_skill and self.all_plan_skill[plan] then
- self.model.shortcutList = self.model.all_plan_skill[plan].shortcutList
- self.model.skillUseList = self.model.all_plan_skill[plan].skillUseList
- end
- self.model:Fire(SkillManager.RESET_SKILL_LIST)
- end
- end
|