123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- ---@class KLTaskGuidePanel:UIKmlLuaPanelBase
- ---@field view KLTaskGuidePanelView
- local KLTaskGuidePanel = class(UIKmlLuaPanelBase)
- local this =KLTaskGuidePanel
- ---创建时调用一次
- function this:Init()
- self.goalId = self.args.goalId
-
- self.args.position.z = 100 --Canvas Plane Distance
- GUI:SetWorldPosition(self.view.root, self.args.position.x, self.args.position.y, self.args.position.z)
- --self.view.root.rectTransform.position = self.args.position
- --GUI:setAnchorPoint(self.view.root, localPoint.x, localPoint.y)
-
- ---@type cfg_task_target_column
- self.cfg = SL:GetConfig('cfg_task_target', self.goalId)
- GUI:DataListInitData(self.view.task_guide_list, function(realIndex)
- return #self.cfg.instruction
- end, function(realIndex)
-
- end, function(realIndex, kmlcontrol)
- local guide_name = self.cfg.extraControlName[realIndex+1]
- local guide_text = GUI:GetChildControl(self.view.task_guide_list, realIndex, 'guide_text')
- GUI:Text_setString(guide_text, guide_name)
-
- local guide_button = GUI:GetChildControl(self.view.task_guide_list, realIndex, 'guide_button')
- GUI:AddOnClickEvent(guide_button, self, function()
- local instruction = self.cfg.instruction[realIndex+1]
- local autoFight = self.cfg.autoFight
- local autoTask = self.cfg.autoTask
- local moveToArriveCallBack
- if autoFight == EAutoFight.AutoFight and string.contains(instruction[1],"transfer") then
- if not SL:GetMetaValue(EMetaVarGetKey.GET_IS_SAFEAREA) then
- SL:SetBattleState(true)
- end
- elseif autoFight == EAutoFight.AutoFight and string.contains(instruction[1],"moveTo") then
- SL:SetBattleState(false)
- moveToArriveCallBack = function()
- if not SL:GetMetaValue(EMetaVarGetKey.GET_IS_SAFEAREA) then
- SL:SetBattleState(true)
- end
- end
- end
- if autoTask == EAutoTalk.AutoTalk and string.contains(instruction[1],"moveToNPC") then
- SL:SetBattleState(false)
- moveToArriveCallBack = function()
- SL:TalkToNpc(tonumber(instruction[2]), true)
- end
- end
- --ShortcutMgr.Do(instruction,nil,nil,moveToArriveCallBack)
- SL:ShortcutDO(instruction,nil,nil,moveToArriveCallBack)
- self:ClosePanel()
- end)
-
- end, function(realIndex, kmlcontrol)
- -- self:SetTaskState(realIndex)
- end)
- GUI:DataListUpdateData(self.view.task_guide_list)
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
-
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.closeMask, self, self.ClosePanel)
- end
- function this:ClosePanel()
- GUI:UIPanel_Close("dev/ui/Task/Panel/KLTaskGuide/KLTaskGuidePanel")
- end
- function this:Close()
- end
- return this
|