UpSuccessView = UpSuccessView or BaseClass(BaseView) local UpSuccessView = UpSuccessView function UpSuccessView:__init() self.base_file = "upSuccess" self.layout_file = "UpSuccessView" self.layer_name = "Top" self.destroy_imm = true self.change_scene_close = true self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.is_set_zdepth = true self.click_bg_toClose = true self.fire_change_visible_event = true ------------------------ -- 一级全屏界面: self.hide_maincancas = false --隐藏主界面 self.use_background = true --不一定显示遮罩 -- 二级界面: -- self.hide_maincancas = false --是否需要隐藏主界面,看策划需求 -- self.use_background = true --需要遮罩 self.attr_item_list = {} ------------------------ FosterModel:GetInstance().is_open_up_success = true self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.close_win_callback = function ( ) self:Close() end self.destroy_callback = function ( ) self:DestroySuccess() end end function UpSuccessView:Open( data ) self.data = data BaseView.Open(self) end function UpSuccessView:LoadSuccess() local nodes = { "img_title:img:obj","con_model","bg_0:raw","lb_name:tmp","lb_name_des:tmp", "con_attr/title_attr:tmp","con_attr/scroll_attr","con_attr/scroll_attr/Viewport/Content_attr","con_attr:obj", "con_fight/lb_fight:txt","con_fight:obj","con_fight/lb_fight_change:tmp","con_fight/icon_fight_up:obj", "con_change/lb_change_2:tmp","con_change:obj","lb_close:tmp", "con_goods/scroll_goods/Viewport/Content_goods","con_goods:obj","con_goods/img_goods:img","con_goods/lb_tips:tmp", "con_title_effect", "con_title_effect2", "con_special_attr/lb_special_attr_value:tmp", "con_special_attr:obj", "con_special_attr/lb_special_attr_name:tmp", "con_change/con_star_old/lb_change_1:tmp","con_change/con_star_old", "con_change/con_star_old/star_1_6:img:obj", "con_change/star_2_1:img:obj", "con_change/star_2_3:img:obj", "con_change/con_star_old/star_1_3:img:obj", "con_change/star_2_5:img:obj", "con_change/con_star_old/star_1_5:img:obj", "con_change/con_star_old/star_1_1:img:obj", "con_change/star_2_4:img:obj", "con_change/con_star_old/star_1_4:img:obj", "con_change/star_2_6:img:obj", "con_change/con_star_old/star_1_2:img:obj", "con_change/star_2_2:img:obj", } self:GetChildren(nodes) -- local function bg_back_func( ... ) -- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then -- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend")) -- end -- end -- if self.background_wnd then -- bg_back_func() -- else -- self.bg_back_func = bg_back_func -- end end function UpSuccessView:AddEvent() local function ChangeVisible( ) if self.data and self.data.model_info then self:ShowModel(self.data.model_info) end end self:BindEvent(GlobalEventSystem, BaseView.ChangeVisible, ChangeVisible) end function UpSuccessView:OpenSuccess() self:UpdateView() end function UpSuccessView:UpdateView() print("huangcong:UpSuccessView [start:78] self.data:", self.data) PrintTable(self.data) print("huangcong:UpSuccessView [end]") self:SetBigBg(self.data.big_bg_res) self:SetBigTitle(self.data.big_title_res) self:SetBigTitleEffect(self.data.big_title_effect) self:ShowModel(self.data.model_info) self:ShowGrade(self.data.grade_change) self:ShowPower(self.data.power_data) self:ShowAttr(self.data.attr_data) self:ShowReward( self.data.reward_data ) self:ShowCloseClock( self.data.close_time ) self:ShowSpecialAttr(self.data.special_attr) end function UpSuccessView:ShowCloseClock( time ) if not time then if self.close_clock_id then GlobalTimerQuest:CancelQuest(self.close_clock_id) self.close_clock_id = nil end else self.time = 10--20201009策划说统一进阶成功界面关闭倒计时 -- self.time = 10 or time local function clockFun() if self.time <= 0 then self.lb_close_tmp.text = "" self:Close() else self.lb_close_tmp.text = string.format( "%d 秒后自动关闭" ,self.time) self.time = self.time - 1 end end self.close_clock_id = self.close_clock_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 1, -1) clockFun() end end function UpSuccessView:ShowModel( model_info ) --[[ model_info = { model_type = UpSuccessView.ModelType.Foster, model_id = 1101, name_des = "名字左边的文本", name = "坐骑名字", } --]] if not model_info then return end ------------------------- self.lb_name_tmp.text = model_info.name or "" self.lb_name_des_tmp.text = model_info.name_des or "" if model_info.model_type == SceneBaseType.FWing or model_info.model_type == SceneBaseType.Horse or model_info.model_type == SceneBaseType.Pet or model_info.model_type == SceneBaseType.FCloud or model_info.model_type == SceneBaseType.FArmour or model_info.model_type == SceneBaseType.FPearl or model_info.model_type == SceneBaseType.FWeapon or model_info.model_type == SceneBaseType.FGun then self:ShowFosterModel(model_info.model_type,model_info.model_id) end end function UpSuccessView:SetBigBg( res_name ) res_name = res_name or "up_success_bg" local function func( ... ) -- self:MoveUIToBack(self.bg_0) end lua_resM:setOutsideRawImage(self,self.bg_0_raw,GameResPath.GetViewBigBg(res_name),false,func) end function UpSuccessView:SetBigTitle( res_name ) if res_name then res_name = res_name or "upSuccess_title_1" lua_resM:setImageSprite(self, self.img_title_img, "upSuccess_asset", res_name,true) self.img_title_obj:SetActive(true) end end function UpSuccessView:SetBigTitleEffect( big_title_effect ) if big_title_effect then if type(big_title_effect) == "table" then if #big_title_effect == 2 then if not self.con_title_effect then return end ------------------------- local function end_call_func( ... ) if not self.con_title_effect2 then return end self:AddUIEffect(big_title_effect[2].res,self.con_title_effect2, self.layer_name, Vector3(-37,-180,0), 1, true,nil) end self:AddUIEffect(big_title_effect[1].res,self.con_title_effect, self.layer_name, Vector3(-37,-180,0), 1, false,nil,nil,end_call_func) end end self.img_title_obj:SetActive(false) end end function UpSuccessView:ShowGrade( grade_change ) --[[ grade_change = { old_grade = "5阶", new_grade = "6阶", old_star = 1, new_star = 2, max_star_old = 6, max_star_new = 6, } --]] if not grade_change then self.con_change_obj:SetActive(false) else self.con_change_obj:SetActive(true) self.lb_change_1_tmp.text = grade_change.old_grade or "" self.lb_change_2_tmp.text = grade_change.new_grade or "" end for i=1,6 do lua_resM:setImageSprite(self,self["star_1_"..i.."_img"],'upSuccess_asset', grade_change.old_star >= i and "upSuccess_star_1" or "upSuccess_star_0",true) lua_resM:setImageSprite(self,self["star_2_"..i.."_img"],'upSuccess_asset', "upSuccess_star_0",true) if grade_change.max_star_old and grade_change.max_star_old < 6 then if grade_change.max_star_old < i then self["star_1_"..i.."_obj"]:SetActive(false) end end if grade_change.max_star_new and grade_change.max_star_new < 6 then if grade_change.max_star_new < i then self["star_2_"..i.."_obj"]:SetActive(false) end end end if grade_change.max_star_old and grade_change.max_star_old < 6 then SetAnchoredPositionX( self.con_star_old.transform, -296 + (6-grade_change.max_star_old)*28.2 ) end end function UpSuccessView:ShowPower( power_data ) --[[ power_data = { new_power = 996 change_power = 110 } --]] if not power_data then self.con_fight_obj:SetActive(false) else self.con_fight_obj:SetActive(true) self.lb_fight_txt.text = "f" .. power_data.new_power if power_data.change_power and power_data.change_power > 0 then self.lb_fight_change_tmp.text = power_data.change_power self.icon_fight_up_obj:SetActive(true) else self.lb_fight_change_tmp.text = "" self.icon_fight_up_obj:SetActive(false) end end end function UpSuccessView:ShowAttr( attr_data ) --[[ attr_data = { title_name = "属性标替文本", pos_type = pos_tag,--位置 attr_old = { [1] = {1,100}, [2] = {2,200}, }, attr_new = { [1] = {1,110}, [2] = {2,220}, }, } --]] if not attr_data then self.con_attr_obj:SetActive(false) else local attr_pos_tab = { ["default"] = { ["con_attr_pos"] = {222.46,23.21}, ["scroll_attr_size"] = {355.99,201.49}, ["scroll_attr_pos"] = {2.72,-55.68}, }, ["foster"] = { ["con_attr_pos"] = {222.46,-48.79}, ["scroll_attr_size"] = {355.99,129.58}, ["scroll_attr_pos"] = {14.42-12,8.33-30}, } } local pos_info = false if attr_data.pos_type and attr_pos_tab[attr_data.pos_type] then pos_info = attr_pos_tab[attr_data.pos_type] else pos_info = attr_pos_tab["default"] end if pos_info then local temp = attr_pos_tab[attr_data.pos_type] SetAnchoredPosition( self.con_attr.transform, temp.con_attr_pos[1], temp.con_attr_pos[2] ) ------------------------- SetSizeDelta(self.scroll_attr.transform, temp.scroll_attr_size[1], temp.scroll_attr_size[2] ) SetAnchoredPosition( self.scroll_attr.transform, temp.scroll_attr_pos[1], temp.scroll_attr_pos[2] ) end ------------------------- self.con_attr_obj:SetActive(true) self.title_attr_tmp.text = attr_data.title_name or "获得属性" ------------------------- local old_attr = attr_data.attr_old or {} local new_attr = attr_data.attr_new or {} old_attr,new_attr = GetAttrMatch( old_attr,new_attr ) old_attr = SortAttrList( old_attr ) for k,v in pairs(self.attr_item_list) do v:SetVisible( false ) end for i,v in ipairs(old_attr) do local next_one = false for a,b in pairs(new_attr) do if b[1] == v[1] then next_one = b end end self.attr_item_list[i] = self.attr_item_list[i] or self:CreateItem(UpSuccessAttrItem, self.Content_attr , self.layer_name) self.attr_item_list[i]:SetData( i, v, next_one ) self.attr_item_list[i]:SetVisible( true ) -- local x = i%2 == 1 and 28 or 380 -- local y = math.ceil( i/2 ) * 45 local x = 0 local y = -32*(i-1) self.attr_item_list[i]:SetPosition( x, y ) end SetSizeDeltaY(self.Content_attr.transform, #old_attr*36) end end --[[ special_attr = { [1] = {1,100}, [2] = {2,200}, }, --]] function UpSuccessView:ShowSpecialAttr( special_attr ) if special_attr and special_attr[1] then local _, name1, _, val1 = WordManager:GetPropertyInfo(special_attr[1][1], special_attr[1][2]) self.con_special_attr_obj:SetActive(true) self.lb_special_attr_value_tmp.text = val1 self.lb_special_attr_name_tmp.text = name1 else self.con_special_attr_obj:SetActive(false) end end function UpSuccessView:ShowReward( reward_data ) --[[ reward_data = { title_res = nil, show_list = { [1] = {1,100065,100}, [2] = {1,100065,100}, } show_name = "", } --]] if not reward_data then self.con_goods_obj:SetActive(false) else self.con_goods_obj:SetActive(true) local res_name = reward_data.title_res or "upSuccess_title_2" lua_resM:setImageSprite(self, self.img_goods_img, "upSuccess_asset", res_name,true) ------------------------- self.tip_award_list = self.tip_award_list or {} for k,v in pairs(self.tip_award_list) do v:SetVisible( false ) end local show_info = reward_data.show_list or {} for i,v in ipairs(show_info) do self.tip_award_list[i] = UIObjPool:PopItem(UIObjPool.UIType.AwardItem,self.Content_goods) self.tip_award_list[i]:SetItemSize(59,59) self.tip_award_list[i]:SetDataWithMapId(v[2], v[3], v[1]) self.tip_award_list[i]:SetPosition( 70 * (i-1)+6,-15) end SetSizeDeltaX(self.Content_goods, #show_info * 108) if reward_data.show_name and reward_data.show_name ~= "" then self.lb_tips_tmp.text = string.format("您已成功激活:%s\n现已将等值材料返还给您", HtmlColorTxt(reward_data.show_name, "#2CF86F")) else self.lb_tips_tmp.text = "" end end end function UpSuccessView:ShowFosterModel( model_type,model_id ) local res_data = { father_node = self, transform = self.con_model, fashion_type = self.data.extra_type_id + 1000, figure_id = model_id, ------------------------- raycast_size = Vector2(500,530), ui_model_type = UIModelCommon.ModelType.Model, layer_name = self.layer_name, --这个翅膀,是半透明翅膀,使用特殊shader处理一下 using_material = self.data.extra_type_id == FosterConst.ModuleId.FWing and "render_texture" or false, } FuncOpenModel:getInstance():SetModelRes(res_data) end function UpSuccessView:DestroySuccess( ) if self.close_clock_id then GlobalTimerQuest:CancelQuest(self.close_clock_id) self.close_clock_id = nil end if self.tip_award_list then for k,v in pairs(self.tip_award_list) do UIObjPool:PushItem(UIObjPool.UIType.AwardItem, v) end self.tip_award_list = {} end self:ClearUIEffect(self.con_title_effect) self:ClearUIEffect(self.con_title_effect2) end