--[[ 新功能开启,包括功能图标、技能图标的展示 ]] NewFuncOpenView = NewFuncOpenView or BaseClass(BaseView) local NewFuncOpenView = NewFuncOpenView function NewFuncOpenView:__init() self.base_file = "func" self.layout_file = "NewFuncOpenView" self.layer_name = "Top" self.destroy_imm = true self.change_scene_close = true self.open_guide_close = nil self.is_set_zdepth = true self.blur_activity_bg = true self.model = FuncOpenModel:getInstance() self.model.is_open_func_model_view = true self.time_diff = 15 FosterModel:GetInstance().wait_new_func_open = true self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.close_callback = function () self:CloseSuccess() end self.destroy_callback = function ( ) self:DestroySuccess() end end function NewFuncOpenView:Open( voList ) -- self.model.is_newFuncOpenView_opening = true --为了战力后显示,先记录界面是否打开 self.voList = voList BaseView.Open(self) end function NewFuncOpenView:LoadSuccess() self.center_obj = self:GetChild("mid/center_cont").gameObject self.mask_obj = self:GetChild("mid/mask_img").gameObject self.mask_img = self:GetChild("mid/mask_img"):GetComponent("Image") self.title_img = self:GetChild("mid/center_cont/title_img"):GetComponent("Image") self.name_txt = self:GetChild("mid/center_cont/up_cont/name_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI)) self.desc_txt = self:GetChild("mid/center_cont/up_cont/desc_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI)) self.time_txt = self:GetChild("mid/center_cont/time_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI)) self.icon_cont = self:GetChild("icon_cont") self.icon_cont_obj = self:GetChild("icon_cont").gameObject self.effect = self:GetChild("mid/center_cont/effect") self.up_cont = self:GetChild("mid/center_cont/up_cont").gameObject self.skill_name_txt = self:GetChild("mid/center_cont/up_cont/skill_name_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI)) local nodes = { "mid/center_cont/bg_img:img", "mid/center_cont/up_cont/desc_bg:obj", "mid/center_cont/up_cont/icon_img:img","icon_raw", } self:GetChildren(nodes) -- self:AddUIEffect("ui_guangxiao", self.effect, self.layer_name, nil, 1, true) -- self:SetGameObjectDepth(self.up_cont, true) self.mask_img.alpha = 0.8 self.mask_obj.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight) -- self.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight) self.transform:SetInsetAndSizeFromParentEdge(self.transform.EdgeLeft, 0, ScreenWidth) end function NewFuncOpenView:AddEvent() local function on_click( target ) if target == self.mask_obj then if Scene.Instance.main_role then local cfg = Scene.Instance.main_role:GetMainRoleStorycfg(PoseState.STORY) if cfg and cfg.ignore_click then return end end self:PlayAction() end end AddClickEvent(self.mask_obj, on_click) end function NewFuncOpenView:OpenSuccess() GlobalEventSystem:Fire(SceneEventType.CLOSE_DIALOGUE_VIEW) self:UpdateView() --是否忽略任务状态,不主动停止,也不主动继续任务 local is_ignore_auto_task = false if self.cur_vo and self.cur_vo.ignore_auto_task then is_ignore_auto_task = true end if not is_ignore_auto_task then self.is_auto_fight = AutoFightManager:getInstance():GetAutoFightState() if self.is_auto_fight then GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT) --停止自动挂机 self.need_close_fight = true end self.is_auto_task = TaskModel:getInstance():GetTaskAutoFlag() if self.is_auto_task then GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK) --停止自动任务 self.need_close_task = true end end self:PlaySound() end function NewFuncOpenView:PlaySound( ) if IsTableEmpty(self.cur_vo) then return end if self.cur_vo then lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.FUNC, self.sound_id) if self.cur_vo.sound and Trim(self.cur_vo.sound) ~= "" then if lua_soundM then self.sound_id = lua_soundM:PlayEffect(self, Trim(self.cur_vo.sound),false,LuaSoundManager.SOUND_TYPE.FUNC) end end end end function NewFuncOpenView:UpdateView() if self.voList then self.cur_vo = self.voList[1] local bg_res = self.cur_vo.type == 2 and "open_func_skill_bg" or "open_func_fun_bg" lua_resM:setOutsideImageSprite(self, self.bg_img_img, GameResPath.GetFuncIcon(bg_res),true) local effect_res = false if self.cur_vo.type == 2 then --技能 effect_res = "huodexinjineng" self.desc_bg_obj:SetActive(true) else SetAnchoredPosition(self.bg_img,1,6) SetAnchoredPosition(self.title_img.transform,-2,180) SetAnchoredPosition(self.time_txt.transform,2,-230) SetAnchoredPosition(self.desc_txt.transform,10,-190) SetAnchoredPosition(self.name_txt.transform,1,-146) SetAnchoredPosition(self.effect.transform,0,6) self.desc_txt.fontSize = 24 self.name_txt.fontSize = 24 SetTMPSharedMaterial(self.name_txt, ShaderTools.TMPSharedMaterialType.HKYTW7SDFOutlineBrightBlueTitle) effect_res = "jiesuoxingongneng" self.desc_bg_obj:SetActive(false) end if effect_res then local function delay_method( ) self:AddUIEffect(effect_res, self.effect, self.layer_name, nil, 1, true) end setTimeout(delay_method, 0.02) end local name = self.cur_vo.name or "" local desc = self.cur_vo.saying if self.cur_vo then lua_resM:setImageSprite(self, self.title_img, "func_asset", "open_func_title1", true) self.image_obj = UiFactory.createChild(self.icon_cont, UIType.ImageExtend) self.image_obj.transform.sizeDelta = Vector2(78, 78) self.image_icon = self.image_obj:GetComponent("ImageExtend") --资源可能有多个地址,默认activityIcon local ab_name, res_name = "activityIcon_asset", "" local is_out_res = false if self.cur_vo.winId and self.cur_vo.subId then local fun_vo = OpenFun.LinkWin[self.cur_vo.winId.."@"..self.cur_vo.subId] if fun_vo then res_name = fun_vo.icon_res end end --右上角玩法 if self.cur_vo.type == 1 then if self.cur_vo.tabId and self.cur_vo.tabId ~= 0 then is_out_res = true res_name = self.cur_vo.tabId end -- name = self.cur_vo.saying -- desc = "" --技能 elseif self.cur_vo.type == 2 then local list = SkillManager.Instance:getCfgInitiativeSkillList() if list then local id = list[self.cur_vo.id + 1] ab_name = "mainUI_asset" res_name = id or self.cur_vo.skill_id if self.cur_vo.id ~= 0 and id then self.cur_vo.skill_id = id -- local skill_cfg = SkillManager.Instance:getSkillFromConfig(skill_id) -- self.cur_vo.saying = (skill_cfg and skill_cfg.name or "获取新技能") local skill_vo = SkillManager.Instance:getSkill(id) name = skill_vo and skill_vo:getName() or "获取新技能" if not self.cur_vo.saying or self.cur_vo.saying == "" then self.cur_vo.saying = skill_vo and skill_vo:GetDesc() or "" end end else Message.show("没有技能配置") end lua_resM:setImageSprite(self, self.title_img, "func_asset", "open_func_title2", true) if Config.ConfigHelper.PassiveSkillDesc[self.cur_vo.skill_id] then--禁跳神技特殊处理 desc = Config.ConfigHelper.PassiveSkillDesc[self.cur_vo.skill_id] end --右下角功能 elseif self.cur_vo.type == 3 then -- name = self.cur_vo.saying -- desc = "" if self.cur_vo.tabId and self.cur_vo.tabId ~= 0 then is_out_res = true res_name = self.cur_vo.tabId local skill_vo = SkillManager.Instance:getSkill(self.cur_vo.tabId) if skill_vo then name = skill_vo and skill_vo:getName() or "获取新技能" end end --背包 elseif self.cur_vo.type == 4 then if self.cur_vo.id == 152 then--装备 res_name = "icon_152_1" else res_name = "icon_29_bb" end --人格主动技能 elseif self.cur_vo.type == 5 then res_name = self.cur_vo.skill_id local skill_vo = SkillManager.Instance:getSkill(id) name = skill_vo and skill_vo:getName() or name if not self.cur_vo.saying or self.cur_vo.saying == "" then self.cur_vo.saying = skill_vo and Trim(skill_vo:GetDesc()) or self.cur_vo.saying end -- lua_resM:setImageSprite(self, self.title_img, "func_asset", "func_skill_font", true) --支线任务 elseif self.cur_vo.type == 6 then res_name = "icon_300_2" end if self.cur_vo.ab_name then ab_name = self.cur_vo.ab_name end if self.cur_vo.res_name then ab_name = self.cur_vo.res_name end if self.cur_vo.show_time then self.time_diff = self.cur_vo.show_time end local size_width = 60 local size_height = 60 if self.cur_vo.winId == 145 and self.cur_vo.subId == 0 then--套装收集 ab_name, res_name = "activityIcon_asset","zjmui_equipCollect_btn_2" size_width = 58 size_height = 62 elseif self.cur_vo.winId == 450 and self.cur_vo.subId == 22 then--V3激活 ab_name, res_name = "vip_asset","vip3_icon" elseif self.cur_vo.winId == 460 and self.cur_vo.subId == 0 then--异域幻魔 ab_name, res_name = "mainUI_asset","zjmui_mapbtn1" size_width = 64 size_height = 127 elseif self.cur_vo.winId == 610 and self.cur_vo.subId == 2 then--经验副本宝箱 res_name = nil local data = { father_node = self, transform = self.icon_raw, fashion_type = FuncOpenModel.TypeId.Monster, clothe_res_id = 10010401, size = Vector2(128, 128), scale = 250, can_rotate = false, action_name_list = {"idle"}, position = Vector3(0, 110, 0), rotate = Vector3(0, 0, 0), ui_model_type = UIModelCommon.ModelType.RT, callBack = function( ) end } FuncOpenModel:getInstance():SetModelRes(data) end --设置图标 self.center_obj:SetActive(true) self.image_obj:SetActive(true) local function callback( ... ) if ab_name == "activityIcon_asset" or (self.cur_vo.winId == 460 and self.cur_vo.subId == 0) then self.image_obj.transform.sizeDelta = Vector2(size_width, size_height) SetSizeDelta(self.icon_img,size_width,size_height) end end if res_name and res_name ~= "" then if self.cur_vo.outside_res then lua_resM:setOutsideImageSprite(self, self.image_icon, self.cur_vo.outside_res, true,callback) lua_resM:setOutsideImageSprite(self, self.icon_img_img, self.cur_vo.outside_res, true,callback) elseif is_out_res then local path = GameResPath.GetDailyImage(res_name) if res_name == 110006 then path = GameResPath.GetSkillIcon(res_name) end lua_resM:setOutsideImageSprite(self, self.image_icon, path, true,callback) lua_resM:setOutsideImageSprite(self, self.icon_img_img, path, true,callback) else lua_resM:setImageSprite(self, self.image_icon, ab_name, res_name, ab_name ~= "activityIcon_asset",callback) lua_resM:setImageSprite(self, self.icon_img_img, ab_name, res_name, ab_name ~= "activityIcon_asset",callback) end end --设置文本 if self.cur_vo.type == 2 then self.skill_name_txt.text = name or "" self.name_txt.text = "" else self.skill_name_txt.text = "" self.name_txt.text = name or "" end self.desc_txt.text = desc --倒计时 self:StartTimer() end end end --动画开始 function NewFuncOpenView:PlayAction( ) if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end local callback = function() if self.cur_vo and self.cur_vo.type == 2 then GlobalEventSystem:Fire(EventName.GET_SKILL_SHAKE_ANI,self.cur_vo.id) end if self.cur_vo.winId == 450 and self.cur_vo.subId == 22 then GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW,VipModel.TabType.Noble,3) end self:Close() end if self.cur_vo and self.cur_vo.ignore_fly then callback() return end local pos = self.cur_vo and self.cur_vo.pos and self.cur_vo.pos or Vector3.zero --被动技能引导技能引导,坐标现在才获取 if self.cur_vo then pos = self.model:GetFlyPos(self.cur_vo) end if pos and self.image_obj then--飞图标拉 self.center_obj:SetActive(false) self.icon_cont_obj:SetActive(true) local transform = self.cur_vo.winId == 610 and self.cur_vo.subId == 2 and self.icon_raw.transform or self.image_obj.transform self.tween_id = TweenLite.to(self, transform, TweenLite.UiAnimationType.POS, pos, 0.8, callback) else callback() end end --开始倒计时 function NewFuncOpenView:StartTimer( ) if self.time_id == nil then self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf89a") .. " 秒后自动关闭" local function onTimer() self.time_diff = self.time_diff - 1 if self.time_diff >= 0 then self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf89a") .. " 秒后自动关闭" else if self.time_id then GlobalTimerQuest:CancelQuest(self.time_id) self.time_id = nil end self:PlayAction() end end self.time_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1) end end --[[function NewFuncOpenView:ReShowFightingUp()--存储的战力提交再次显示 self.model.is_newFuncOpenView_opening = false local fight_num = RoleManager.Instance.mainRoleInfo.fighting if self.model.old_fightNum and fight_num > self.model.old_fightNum then GlobalEventSystem:Fire(FightingUpEvent.FIGHTING_UP, self.model.old_fightNum, fight_num) end end--]] --关闭界面后做什么 function NewFuncOpenView:CloseSuccess( ) if self.image_obj then self.image_obj:SetActive(false) end GlobalEventSystem:Fire(EventName.SHOW_FUNC_OPEN_ICON,self.voList) --完成引导 local main_role = Scene.Instance.main_role if main_role and main_role:IsInState(PoseState.STORY) then main_role:ChangeState(PoseState.STAND) end if self.need_close_fight then GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) --启动自动挂机 end local helpVo, endVo = GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,1) if helpVo and not endVo then GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) else if self.cur_vo and self.cur_vo.ignore_auto_task then else -- if not self.cur_vo.is_angry then--怒气技能不继续做任务 --当前没有引导才继续做任务 GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK) -- end local task_data = TaskModel:getInstance():GetMainTask() if self.need_close_task and task_data and task_data.id > 0 then GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK) --启动自动任务 end end end -- end -- self:ReShowFightingUp() -- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,1) -- or GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,2) -- if helpVo then -- GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) -- end end function NewFuncOpenView:DestroySuccess( ) self.model.is_open_func_model_view = false self:ClearUIEffect(self.effect) if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end if self.time_id then GlobalTimerQuest:CancelQuest(self.time_id) self.time_id = nil end FosterModel:GetInstance().wait_new_func_open = false GlobalEventSystem:Fire(EventName.BOARD_CLOSE_FUNC_OPEN_VIEW) if self.cur_vo and self.cur_vo.winId == 157 and self.cur_vo.subId == 0 then TaskModel.getInstance():ShowMainLineTips(true) end end