AutoSettingView = AutoSettingView or BaseClass(BaseItem) -- 挂机设置界面 function AutoSettingView:__init(parent) self.base_file = "setting" self.layout_file = "AutoSettingView" self.fight_model = AutoFightManager:getInstance() self.skil_list = {} self:Load() end function AutoSettingView:Load_callback() self:LoadSuccess() self:InitEvent() end function AutoSettingView:LoadSuccess() self.skill_con = self:GetChild("autoSkill") self.autoClick = { autoReborn = self:GetChild("autoSet/autoReborn"), autoFlyShoe = self:GetChild("autoSet/autoFlyShoe"), autoPowerSave = self:GetChild("autoSet/autoPowerSave"), autoReborn_tmp = self:GetChild("autoSet/autoReborn/Label"):GetComponent("TextMeshProUGUI"), autoFlyShoe_tmp = self:GetChild("autoSet/autoFlyShoe/Label"):GetComponent("TextMeshProUGUI"), autoPowerSave_tmp = self:GetChild("autoSet/autoPowerSave/Label"):GetComponent("TextMeshProUGUI"), } self.doubtBtn = self:GetChild("doubtBtn").gameObject if self.need_refreshData then self:SetData() end end function AutoSettingView:InitEvent() --普通toggle local function onToggleClickHandler(target) local state = target:GetComponent("Toggle").isOn if target == self.autoClick.autoReborn.gameObject then lua_settingM:SetAutoRebornSet(state) self.autoClick.autoReborn_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1") elseif target == self.autoClick.autoFlyShoe.gameObject then lua_settingM:SetAutoFlyShoeSet(state) self.autoClick.autoFlyShoe_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1") elseif target == self.autoClick.autoPowerSave.gameObject then lua_settingM:SetAutoPowerSaveSet(state) self.autoClick.autoPowerSave_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1") end end AddClickEvent(self.autoClick.autoReborn.gameObject,onToggleClickHandler) AddClickEvent(self.autoClick.autoFlyShoe.gameObject,onToggleClickHandler) AddClickEvent(self.autoClick.autoPowerSave.gameObject,onToggleClickHandler) local on_click = function ( click_obj ) if self.doubtBtn == click_obj then EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, "102@1") end end AddClickEvent(self.doubtBtn, on_click,LuaSoundManager.SOUND_UI.NONE) local function return_default(cur_index) if not self.is_loaded then return end if cur_index == GameSettingModel.TabData.AUTO then self:ReturnDefault() end end self:BindEvent(GameSettingModel:GetInstance(), GameSettingModel.RETURN_ALL_DEFAULT, return_default) end function AutoSettingView:SetData() if not self.is_loaded then self.need_refreshData = true return end self.need_refreshData = false local reborn_bool = lua_settingM:GetAutoRebornSet() and true or false self.autoClick.autoReborn:GetComponent("Toggle").isOn = reborn_bool self.autoClick.autoReborn_tmp.color = ColorUtil:ConvertHexToRGBColor(reborn_bool and "#f3fcff" or "#a9c1e1") local fly_bool = lua_settingM:GetAutoFlyShoeSet() and true or false self.autoClick.autoFlyShoe:GetComponent("Toggle").isOn = fly_bool self.autoClick.autoFlyShoe_tmp.color = ColorUtil:ConvertHexToRGBColor(fly_bool and "#f3fcff" or "#a9c1e1") local power_bool = lua_settingM:GetAutoFlyShoeSet() and true or false self.autoClick.autoPowerSave:GetComponent("Toggle").isOn = power_bool self.autoClick.autoPowerSave_tmp.color = ColorUtil:ConvertHexToRGBColor(power_bool and "#f3fcff" or "#a9c1e1") self:SetAutoSKill() end function AutoSettingView:SetAutoSKill() local shortcut_list = {} local shortcut_data = DeepCopy(SkillManager.Instance:GetCurShortcutList()) for i,v in ipairs(shortcut_data) do if shortcut_data[i].id ~= 0 then local vo = {skill_id = shortcut_data[i].id, type = shortcut_data[i].type, name = SkillManager:getInstance():GetSkillNameById(shortcut_data[i].id), pos = shortcut_data[i].pos } table.insert(shortcut_list,vo) end end if not shortcut_list[1] then return end if #shortcut_list > 1 then table.sort( shortcut_list, function (a,b) return a.pos < b.pos end ) end local task_cfg = Config.ConfigTaskEffect.SkillPosToTaskId local len = #shortcut_list --插入锁定状态的item for i=len+1,8 do local vo = {} vo.empty_data = true table.insert(shortcut_list,vo) end local item for i,v in ipairs(shortcut_list) do item = self.skil_list[i] if item == nil then item = SelectSkillItem.New(self.skill_con) table.insert(self.skil_list,item) end item:SetData(i,v) end end --旧的技能创建逻辑,先不要干掉 -- function AutoSettingView:OldSetAutoSKill() -- local skil_table = {} -- local cfg = Config.ConfigSkillUI.InitiativeSkill -- if not cfg then return end -- local role_info = RoleManager.Instance:GetMainRoleVo() -- local career = role_info.career -- local sex = role_info.sex -- local data = cfg[career.."@"..sex] -- local hit_skill = SkillManager:getInstance():GetHitSkillVo() -- -- local god_skill = role_info.level >= Config.ConfigOpenLv.FunctionIconOpenLv.God and SkillManager.GodSkillId or nil -- for i=2,#data do -- local vo = { skill_id = data[i],type = 0,name = SkillManager:getInstance():GetSkillNameById(data[i]) } -- table.insert(skil_table,vo) -- end -- if hit_skill then -- local vo = { skill_id = hit_skill.id,type = 1 ,name = SkillManager:getInstance():GetSkillNameById(hit_skill.id)} -- table.insert(skil_table,vo) -- end -- -- if god_skill then -- -- local vo = { skill_id = god_skill,type = 0 ,name = "降神变身"} -- -- table.insert(skil_table,vo) -- -- end -- local list = skil_table -- local len = #list -- local item -- for i,v in ipairs(list) do -- item = self.skil_list[i] -- if item == nil then -- item = SelectSkillItem.New(self.skill_con) -- table.insert(self.skil_list,item) -- end -- item:SetData(i,v) -- item:SetPosition((897/len)*(i-1), 0) -- end -- end function AutoSettingView:__delete( ) for i,item in ipairs(self.skil_list) do item:DeleteMe() end end function AutoSettingView:ReturnDefault( ) lua_settingM:SetAutoRebornSet(false) lua_settingM:SetAutoFlyShoeSet(false) lua_settingM:SetAutoPowerSaveSet(true) for i,item in ipairs(self.skil_list) do item:SetStateCacheDefault() end self:SetData() end