--[[@------------------------------------------------------------------ @description:幻光成功界面 @author:LZR ----------------------------------------------------------------------]] LightSuccessView = LightSuccessView or BaseClass(BaseView) local LightSuccessView = LightSuccessView function LightSuccessView:__init() self.base_file = "light" self.layout_file = "LightSuccessView" self.layer_name = "Activity" self.destroy_imm = true self.change_scene_close = true self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.click_bg_toClose = false self.is_set_zdepth = true ------------------------ -- 一级全屏界面: self.hide_maincancas = false --隐藏主界面 self.use_background = true --不一定显示遮罩 self.ignore_use_anim = true self.use_show_anim = true self.use_hide_anim = true -- self.blur_activity_bg = true self.model = LightModel:getInstance() self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.destroy_callback = function ( ) self:DestroySuccess() end end function LightSuccessView:DestroySuccess( ) if self.close_time_id then GlobalTimerQuest:CancelQuest(self.close_time_id) self.close_time_id = nil end if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end if self.tween_scale_id then TweenLite.Stop(self.tween_scale_id) self.tween_scale_id = nil end GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK) end function LightSuccessView:Open(cur_select_right, grade, star) self.cur_select_right = cur_select_right or 1003 self.grade = grade or 1 self.star = star or 1 BaseView.Open(self) end function LightSuccessView:OpenSuccess( ) self:UpdateView() end function LightSuccessView:LoadSuccess() local nodes = { "back_touch:obj", "close_btn:obj", "mid:obj", "mid/bg:raw:obj", "mid/bg2:raw:obj", "mid/roleCon", "mid/attr_scroll", "mid/attr_scroll/Viewport/attr_con", "mid/powerText:txt", "mid/skillDesc:tmp", "mid/lb_attr:tmp", "mid/lb_level:tmp", "mid/skillName:tmp", "mid/lb_attr_des:tmp", "mid/skillImg:img", "mid/icon_special:img", "mid/img_title:img", "mid/lb_name:tmp", "skillImg_other:img:obj", "mid/con_star_2", "mid/con_star_1:obj", "mid/img_arrow_change:obj", "mid/lb_change_1:tmp", "mid/lb_change_2:tmp", "mid/lb_time:tmp", "mid/powerTextAdd:tmp", "mid/icon_add", "mid/con_star_1/star_5:img", "mid/con_star_1/star_2:img", "mid/con_star_1/star_3:img", "mid/con_star_1/star_6:img", "mid/con_star_1/star_1:img", "mid/con_star_1/star_4:img", "mid/con_star_2/star2_5:img", "mid/con_star_2/star2_2:img", "mid/con_star_2/star2_3:img", "mid/con_star_2/star2_6:img", "mid/con_star_2/star2_1:img", "mid/con_star_2/star2_4:img", } self:GetChildren(nodes) lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("light_success_bg_3"), false) -- lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetViewBigBg("light_success_bg_3"), false) if self.need_load_again then self:UpdateView() end self.time = 11 local function clockFun() self.time = self.time - 1 if self.time > 0 then self.lb_time_tmp.text = string.format( "%d 秒后自动关闭" , self.time ) else self:CustomClose() end end -- local function bg_back_func( ... ) -- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then -- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend")) -- self:MoveUIToBack(self.bg_raw) -- self:MoveUIToBack(self.bg2_raw) -- end -- end -- if self.background_wnd then -- bg_back_func() -- else -- self.bg_back_func = bg_back_func -- end clockFun() self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 1, -1) end function LightSuccessView:AddEvent() local function on_click( target ) if target == self.back_touch_obj then self:CustomClose() elseif target == self.close_btn_obj then self:CustomClose() end end AddClickEvent(self.back_touch_obj, on_click) AddClickEvent(self.close_btn_obj, on_click) end function LightSuccessView:UpdateView() if not self.is_loaded then self.need_load_again = true return end if not self.cur_select_right then print("LightSuccessView [start:95] 数据不正确:") return end self:ShowModel() self:UpdateSkill() self:UpdateAttrProp() self:UpdateSpeacielProp() self:UpdateStar() end --更新技能 function LightSuccessView:UpdateSkill( ) if not self.is_loaded then return end local conf = self.model:GetLightConfOne( self.cur_select_right ) if not conf then return end self.lb_name_tmp.text = conf and Trim(conf.name) or "" local mat = conf.color == 1 and ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkBlueBtn or (conf.color == 2 and ShaderTools.TMPSharedMaterialType.FZZZOutlineDeepPurpleTitle or (conf.color == 3 and ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn or ShaderTools.TMPSharedMaterialType.FZZZSDFDefault)) SetTMPSharedMaterial(self.lb_name_tmp, mat) -- self.lb_name_tmp.text = HtmlColorTxt(Trim(conf.name), self.model.text_color[conf.color]) self.lb_level_tmp.text = tostring(self.grade == 0 and 1 or self.grade) .. "阶" local skill_info = stringtotable(conf.skill) local skill_id = tonumber(skill_info[1]) local skill_conf = SkillManager:getInstance():getSkillFromConfig(skill_info[1]) self.skillName_tmp.text = HtmlColorTxt(Trim(skill_conf.name or ""), self.model.text_color[conf.color]) --特殊写死,只需要描述的一部分 -- if skill_id == 120001 then -- self.skillDesc_tmp.text = "攻击时有30%的概率令敌人流血,每秒损失1%气血" -- else self.skillDesc_tmp.text = Trim(skill_conf.lvs[tonumber(skill_info[2])].desc or "") -- end lua_resM:setOutsideImageSprite(self, self.skillImg_img, GameResPath.GetSkillIcon(tonumber(skill_info[1])),true) lua_resM:setOutsideImageSprite(self, self.skillImg_other_img, GameResPath.GetSkillIcon(tonumber(skill_info[1])),true) end --更新属性列表 function LightSuccessView:UpdateAttrProp( ) if not self.is_loaded then return end local grade = self.grade local star = self.star ------------------------- local conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star ) if not conf then return end ------------------------- local base_attr = stringtotable(conf.attrs) self.powerText_txt.text = "f" .. GetFighting(base_attr,true) --处理一下attr_list 改成两个一组 local count = #base_attr local new_base_attr = {} local add_attr = {} for i = 1, count do local data = { attr_id1 = base_attr[i] and base_attr[i][1] or nil, value1 = base_attr[i] and base_attr[i][2] or nil, next_value1 = base_attr[i] and base_attr[i][3] or nil, } if grade == 0 and star == 0 then data.next_value1 = data.value1 data.value1 = 0 table.insert( add_attr, {data.attr_id1, data.next_value1}) else local conf_last = false for k,v in pairs(Config.Visuslv) do if v.next_grade == grade and v.next_lv == star and v.id == self.cur_select_right then conf_last = v break end end if conf_last then local last_attrs = stringtotable(conf_last.attrs) for kk,vv in pairs(last_attrs) do if vv[1] == data.attr_id1 and (vv[2]~=data.value1) then data.next_value1 = data.value1 data.value1 = vv[2] table.insert( add_attr, {data.attr_id1, data.next_value1 - data.value1}) break end end end end table.insert(new_base_attr, data) end if grade == 0 and star == 0 then self.powerTextAdd_tmp.text = GetFighting(add_attr, true) else self.powerTextAdd_tmp.text = GetFighting(add_attr, true) end if not self.attr_list_com then self.attr_list_com = self:AddUIComponent(UI.ItemListCreator) end local info = { data_list = new_base_attr, item_con = self.attr_con, item_class = LightAttrItemTwo, item_width = 395, item_height = 33, space_x = 0, start_x = 0, start_y = 0, space_y = 0, scroll_view = self.attr_scroll, create_frequency = 0.05, is_scroll_back_on_update = false, -- init_value = "LightActiveItem",--不同的预制 on_update_item = function(item, i, v) item:SetData(i,v) end, } self.attr_list_com:UpdateItems(info) end --更新特殊数 function LightSuccessView:UpdateSpeacielProp( ) local grade = self.grade local star = self.star self.lb_attr_tmp.text = "" self.lb_attr_des_tmp.text = "" ------------------------- --当前属性,下层属性 local lv_conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star ) if not lv_conf then return end --特殊属性 local temp_data2 = stringtotable(lv_conf.spe_attrs) local attr_num = temp_data2[1] and tonumber(temp_data2[1][2] or 0) or 0 local min_val = 999 local min_grade,min_lv = 999,999 local attr_id = false for k,v in pairs(Config.Visuslv) do if v.id == self.cur_select_right then for a,b in pairs(stringtotable(v.spe_attrs)) do attr_id = attr_id or b[1] if b[1] == attr_id and b[2] > attr_num then if min_grade > v.grade then min_val = b[2] min_grade = v.grade min_lv = v.lv elseif min_grade == v.grade then if min_lv > v.lv then min_val = b[2] min_grade = v.grade min_lv = v.lv end end end end end end if attr_id then local _, name1, _, val1 = WordManager:GetPropertyInfo(attr_id, attr_num == 0 and min_val or attr_num) local temp_str = "(" .. min_grade .. "阶" .. min_lv .. "星" .. (temp_data2[1] and "提升)" or "激活)") if min_grade == 999 then temp_str = "" end self.lb_attr_tmp.text = name1 .. ": " .. val1 .. temp_str SetAttrIconByColorType(self, self.icon_special_img, attr_id, nil, 2) end end function LightSuccessView:UpdateStar( ) local grade = self.grade local star = self.star local is_first = grade == 0 and star == 0 -- self.con_star_1_obj:SetActive(not is_first) -- SetAnchoredPositionX( self.con_star_2.transform, is_first and 250 or 342 ) lua_resM:setImageSprite(self, self.img_title_img, "light_asset", is_first and "func_light_title_1" or "func_light_title_2",true) local img_node,use_style,last_lv,last_grade,temp_conf = false,false,false,false,false if not is_first then --获得上一次的等级 for k,v in pairs(Config.Visuslv) do if v.next_grade == grade and v.next_lv == star then last_lv = v.lv last_grade = v.grade end end self.img_arrow_change_obj:SetActive(true) SetLocalPosition(self.powerText.transform, 173, 173, 0) SetLocalPosition(self.powerTextAdd.transform, 378, 173, 0) SetLocalPosition(self.icon_add.transform, 316, 173, 0) SetLocalScale(self.powerText.transform, 1, 1, 1) SetLocalScale(self.powerTextAdd.transform, 1, 1, 1) SetLocalScale(self.icon_add.transform, 1, 1, 1) self.lb_change_1_tmp.text = (last_grade or 0) .. "阶" self.lb_change_2_tmp.text = (self.grade or 0) .. "阶" else self.img_arrow_change_obj:SetActive(false) SetLocalPosition(self.powerText.transform, 173, 140, 0) SetLocalPosition(self.powerTextAdd.transform, 384, 143, 0) SetLocalPosition(self.icon_add.transform, 316, 143, 0) SetLocalScale(self.powerText.transform, 1.1, 1.1, 1) SetLocalScale(self.powerTextAdd.transform, 1.1, 1.1, 1) SetLocalScale(self.icon_add.transform, 1.1, 1.1, 1) self.lb_change_1_tmp.text = "" self.lb_change_2_tmp.text = "" end local function get_show_style( id ) id = id or 1 id = id % 6 return (id == 0) and 6 or id end for i=1,6 do img_node = self["star2_" .. i .. "_img"] use_style = grade > 0 and grade or 1 if star >= i then lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_" .. get_show_style(use_style) .. "_1",true) else if use_style == 1 then lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_0",true) else lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_" .. get_show_style(use_style-1) .. "_1",true) end end ------------------------- img_node = self["star_" .. i .. "_img"] if last_lv and last_grade then use_style = last_grade > 0 and last_grade or 1 if last_lv >= i then lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_" .. get_show_style(use_style) .. "_1",true) else if use_style == 1 then lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_0",true) else lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_" .. get_show_style(use_style-1) .. "_1",true) end end else lua_resM:setImageSprite(self, img_node, "light_asset", "light_star_0",true) end end ------------------------- local index = star%6 index = index == 0 and 6 or index local img_node = self["star2_" .. index .. "_img"] self:AddUIEffect("ui_jinjiestar", img_node.transform, self.layer_name, nil, 1, false) end function LightSuccessView:ShowModel( ) if not self.is_loaded then return end local res_data = { father_node = self, transform = self.roleCon, fashion_type = FuncOpenModel.TypeId.Clothes, raycast_size = Vector2(0,0), scale = 160, position = Vector3(10,-10,-500), layer_name = self.layer_name, ui_model_type = UIModelCommon.ModelType.Model, -- show_shadow = false, -- use_bloom = false, light_id = self.cur_select_right, } FuncOpenModel:getInstance():SetModelRes(res_data) end function LightSuccessView:CustomClose() local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,6) if not helpVo then self:Close() return end local help_type = helpVo.help_type local step = helpVo.step if help_type == HelpType.TYPE_LIGHT and step == 6 then GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) self:PlayAction() else self:Close() end end --动画开始 function LightSuccessView:PlayAction( ) local callback = function() self.skillImg_other_obj:SetActive(false) GlobalEventSystem:Fire(EventName.GET_SKILL_SHAKE_ANI,9) self:Close() end local pos = MainUIController:GetInstance():GetSkillBtnPos(9) or Vector3.zero if pos then--右下角图标怒气大招 self.mid_obj:SetActive(false) self.bg_obj:SetActive(false) -- self.bg2_obj:SetActive(false) self.skillImg_other_obj:SetActive(true) local target_scale = Vector3.New(0.75, 0.75, 0.75) self.tween_id = TweenLite.to(self, self.skillImg_other_obj.transform, TweenLite.UiAnimationType.POS, pos, 0.8, callback) self.tween_scale_id = TweenLite.to(self, self.skillImg_other_obj.transform, TweenLite.UiAnimationType.SCALE, target_scale, 0.8) else callback() end end