LightSubView = LightSubView or BaseClass(BaseItem) local LightSubView = LightSubView -- LightSubView.Width = 200 -- LightSubView.Height = 90 function LightSubView:__init(parent_wnd,prefab_asset,layer_name) self.base_file = "light" self.layout_file = "LightSubView" self.layer_name = layer_name self.model = LightModel:GetInstance() self.full_screen = true self.ani_left = -200 self.ani_right = 200 self.adjust_mid = {left = 240, right = 600} self.cur_select_id = false self.tab_item_list = {} self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) self:Load() end function LightSubView:Load_callback() self.nodes = { "right", "mid", "left", "left/scroll_left/Viewport/Content_left", "left/scroll_left", "right/btn_skin:img:obj", "mid/power_text:txt", "right/attr_scroll/Viewport/attr_con", "right/attr_scroll", "mid/roleCon", "mid/di_name:img", "right/attr_scroll/Viewport:img", "right/con_skill/icon_skill:img:obj", "right/con_skill/skill_name:tmp", "right/con_skill/skill_des:tmp", "right/con_skill/skill_level:tmp", "right/con_condition_other:obj","right/con_condition_other/lb_active_other:tmp", "right/con_up:obj", "right/con_condition_other/di_active_other", "right/con_up/btn_up:obj:img", "right/con_up/btn_up/btn_red:obj", "right/con_up/btn_up/btn_up_text:tmp", "right/con_up/cost_con/name_text:tmp", "right/con_up/cost_con/num_text:tmp", "right/con_up/cost_con/cost_item_con","right/con_up/cost_con:obj", "right/con_star_2:obj", "right/con_star_1", "right/con_star_1/star_5:img", "right/con_star_1/star_2:img", "right/con_star_1/star_3:img", "right/con_star_1/star_6:img", "right/con_star_1/star_1:img", "right/con_star_1/star_4:img", "right/con_star_2/star2_5:img", "right/con_star_2/star2_2:img", "right/con_star_2/star2_3:img", "right/con_star_2/star2_6:img", "right/con_star_2/star2_1:img", "right/con_star_2/star2_4:img", "right/lb_attr:tmp", "right/lb_attr_des:tmp", "right/icon_special:img", "right/lb_grade:tmp", "right/btn_active:obj:img", "mid/lb_name:tmp", "right/btn_active/btn_active_red:obj", "right/lb_tip_up:tmp", "right/di_1:img","right/con_di_cost:obj", "mid/di_fight", } self:GetChildren(self.nodes) self:RegisterMask(self.Viewport_img) self.cost_item = self.cost_item or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.cost_item_con) self.cost_item:SetItemSize(59,59) lua_resM:setOutsideImageSprite(self,self.di_1_img,"/client/assets/icon/light/light_bg_1.png") ------------------------- self:AddEvents() self:UpdateView() self:AddToStageHandler() end function LightSubView:AddEvents( ) local function call_back( target ) if target == self.btn_skin_obj then self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14702,self.cur_select_id) elseif target == self.btn_up_obj then local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,4) if helpVo then GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) end if self.need_more_goods_id then --道具不足弹物品 UIToolTipMgr:getInstance():AppendGoodsTips(self.need_more_goods_id,nil,nil,nil,nil,nil,nil,true) return end local is_active = self.model:GetLightIsActive( self.cur_select_id ) if is_active then self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14701,self.cur_select_id) else self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14703,self.cur_select_id) end elseif target == self.icon_skill_obj then local conf = self.model:GetLightConfOne( self.cur_select_id ) if not conf then return end local skill_info = stringtotable(conf.skill) ------------------------- local data = { skill_id = tonumber(skill_info[1]), skill_lv = tonumber(skill_info[2]), } GlobalEventSystem:Fire(EventName.OPEN_COMMON_SKILL_TIPS, data) elseif target == self.btn_active_obj then if self.need_more_goods_id then --道具不足弹物品 UIToolTipMgr:getInstance():AppendGoodsTips(self.need_more_goods_id,nil,nil,nil,nil,nil,nil,true) return elseif self.jump_active and self.jump_active[1] then OpenFun.Open(self.jump_active[1],self.jump_active[2]) return end self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14703,self.cur_select_id) local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,4) if helpVo then GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) end end end AddClickEvent(self.btn_skin_obj,call_back,false) AddClickEvent(self.btn_up_obj,call_back,false) AddClickEvent(self.icon_skill_obj,call_back,false) AddClickEvent(self.btn_active_obj,call_back,false) local function updata_all( ) self:UpdateView() end self:BindEvent(self.model, LightModel.ANS_LIGHT_BASE, updata_all) local function ANS_LIGHT_UPGRADE( lv ) if lv then self:ShowEveryUpEffect(true) self:ShowStarEffect(lv) else self:UpdateView() end end self:BindEvent(self.model, LightModel.ANS_LIGHT_UPGRADE, ANS_LIGHT_UPGRADE) local function on_ans_update_red_dot( ) self:CheckRedDot() end self:BindEvent(NewMainRoleModel:getInstance(), NewMainRoleModel.ANS_UPDATE_RED_DOT, on_ans_update_red_dot) local function onGuideTrigger() self:AddToStageHandler() end self.guide_trigger_id = GlobalEventSystem:Bind(EventName.TRIGGER_GUIDE_TYPE,onGuideTrigger) end function LightSubView:CheckRedDot( ) if self.is_loaded then local can_active = self.model:CanLightActive( false,self.cur_select_id ) self.btn_red_obj:SetActive(can_active or self.model:CanLightUpGrade( false,self.cur_select_id )) self.btn_active_red_obj:SetActive(can_active) if self.jump_active and self.jump_active[1] then SetImageGray( self.btn_active_img, false ) else SetImageGray( self.btn_active_img, not can_active ) end if self.item_list_com then self.item_list_com:IterateItems(function( item, i ) item:UpdateRed() end) end end end function LightSubView:UpdateView( ) self:UpdateRight() self:ShowModel() end function LightSubView:ShowStarEffect( star ) if not star then return end star = star % 6 star = star == 0 and 6 or star if self["star_"..star] then self:AddUIEffect("ui_jinjiestar", self["star_"..star].transform, self.layer_name, nil, 1, false) end end function LightSubView:ShowEveryUpEffect( is_upgrade ) if not self.showing_attr_effect then --快速点击还能看到重播是因为节点隐藏显示重复触发 self.showing_attr_effect = true local function clockFun() self.showing_attr_effect = false if self.attr_effect_time_id then GlobalTimerQuest:CancelQuest(self.attr_effect_time_id) self.attr_effect_time_id = nil end end self.attr_effect_time_id = self.attr_effect_time_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 0.75, 1) ------------------------- if self.attr_list_com and self.attr_list_com.item_list then for k,v in pairs(self.attr_list_com.item_list) do if v.attr_icon1 then self:AddUIEffect("ui_jinjieshuxing", v.attr_icon1, self.layer_name, Vector3(-40,0,0), 1, false, nil, true) end end end end ------------------------- if is_upgrade then --跳级才播放 if not self.showing_mode_effect then local function call_back( ) self.showing_mode_effect = false end self:ClearUIEffect(self.di_fight.transform) self:AddUIEffect("ui_jinjie", self.di_fight, self.layer_name, Vector3(165,180,0), 1, false, 1.5, nil, call_back) self.showing_mode_effect = true end end end function LightSubView:UpdateRight( ) self:SetTabItem() self:ShowProp() self:UpdateSkill() self:UpdateCost() self:UpdateStarShow() self:ShowUseStatus() ------------------------- self:CheckRedDot() end function LightSubView:SetTabItem( ) local list_data = self.model:GetLightSubTabInfo( ) ------------------------- if not self.cur_select_id then if not list_data[1] then return end self.cur_select_id = list_data[1].id end ------------------------- local function call_back( cur_select_id ) if cur_select_id and cur_select_id ~= self.cur_select_id then self.cur_select_id = cur_select_id self:UpdateView() end end if not self.item_list_com then self.item_list_com = self:AddUIComponent(UI.ItemListCreator) end local info = { data_list = list_data, item_con = self.Content_left, item_class = LightTabItem, item_width = 143, item_height = 125, space_x = 8, space_y = 5.25, start_x = 4, start_y = -8, scroll_view = self.scroll_left, create_frequency = 0, is_scroll_back_on_update = false, on_update_item = function(item, i, v) item:SetData(i, v, call_back,self.cur_select_id) end, } self.item_list_com:UpdateItems(info) end function LightSubView:ShowProp( ) if not self.is_loaded then return end local basic = self.model:GetLightInfoOne( self.cur_select_id ) local grade,star = 0,0 if basic then grade = basic.grade star = basic.lv end ------------------------- local conf = self.model:GetLightLvConfOne( self.cur_select_id, grade, star ) if not conf then return end ------------------------- local base_attr = stringtotable(conf.attrs) local is_active = self.model:GetLightIsActive( self.cur_select_id ) self.power_text_txt.text = "f" .. GetFighting(base_attr, is_active) --处理一下attr_list 改成两个一组 local count = #base_attr local new_base_attr = {} local is_max = self.model:GetLightIsMax( self.cur_select_id ) 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 not is_max then local conf_next = self.model:GetLightLvConfOne( self.cur_select_id,conf.next_grade,conf.next_lv ) if conf_next then local last_attrs = stringtotable(conf_next.attrs) for kk,vv in pairs(last_attrs) do if vv[1] == data.attr_id1 then data.next_value1 = vv[2] break end end end end ------------------------- table.insert(new_base_attr, data) 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 = LightAttrItemThree, item_width = 363, item_height = 36, space_x = 20, -- space_y = 0, start_x = 2, -- start_y = 0, scroll_view = self.attr_scroll, -- create_frequency = 0, is_scroll_back_on_update = false, on_update_item = function(item, i, v) item:SetData(i,v) end, } self.attr_list_com:UpdateItems(info) end function LightSubView:ShowUseStatus( ) local is_active = self.model:GetLightIsActive( self.cur_select_id ) self.btn_skin_obj:SetActive(is_active) local basic = self.model:GetLightInfoOne( self.cur_select_id ) ------------------------- if basic and (basic.display == 1) then lua_resM:setImageSprite(self,self.btn_skin_img,'light_asset',"light_icon_17",true) else lua_resM:setImageSprite(self,self.btn_skin_img,'light_asset',"light_icon_16",true) end end function LightSubView:ShowModel( force ) if not self.is_loaded then return end if (self.show_effect_id ~= self.cur_select_id) or force then local res_data = { father_node = self, transform = self.roleCon, fashion_type = FuncOpenModel.TypeId.Light, -- size = Vector2(720,720), scale = 3, position = Vector3(-20,-150,0), ui_model_type = UIModelCommon.ModelType.BackModel, light_id = self.cur_select_id, layer_name = self.layer_name } FuncOpenModel:getInstance():SetModelRes(res_data) self.show_effect_id = self.cur_select_id ------------------------- local conf = self.model:GetLightConfOne( self.cur_select_id ) -- 幻光名字根据品质变色 lua_resM:setImageSprite(self, self.di_name_img, "light_asset", "light_di_16" .. "_" .. conf.color, true) 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) end end function LightSubView:UpdateSkill( ) if not self.is_loaded then return end local conf = self.model:GetLightConfOne( self.cur_select_id ) if not conf then return end local skill_info = stringtotable(conf.skill) local skill_conf = SkillManager:getInstance():getSkillFromConfig(skill_info[1]) -- 品质变色 self.skill_name_tmp.text = HtmlColorTxt(Trim(skill_conf.name or ""), self.model.text_color[conf.color]) .. HtmlColorTxt(conf.color == 3 and "" or "(激活高阶幻光可升级)", ColorUtil.ORANGE, 0.8) self.skill_level_tmp.text = "lv." .. Trim(conf.color) -- local skill_desc_str = Trim(skill_conf.lvs[tonumber(skill_info[2])].desc or "") -- if skill_desc_str ~= "" then -- local pos = string.find(skill_desc_str, '(') -- end self.skill_des_tmp.text = Trim(skill_conf.lvs[tonumber(skill_info[2])].desc or "") lua_resM:setOutsideImageSprite(self, self.icon_skill_img, GameResPath.GetSkillIcon(tonumber(skill_info[1])),true) end function LightSubView:UpdateStarShow( ) local basic = self.model:GetLightInfoOne( self.cur_select_id ) local grade,star = 0,0 if basic then grade = basic.grade star = basic.lv end local conf = self.model:GetLightConfOne(self.cur_select_id) local is_active = self.model:GetLightIsActive( self.cur_select_id ) self.lb_grade_tmp.text = is_active and ((grade == 0 and 1 or grade) .. "阶") or "" ------------------------- local is_max = self.model:GetLightIsMax( self.cur_select_id ) self.con_star_2_obj:SetActive(not is_max) SetAnchoredPositionX( self.con_star_1.transform, is_max and 70 or -32.59065 ) local img_node,use_style,next_lv,next_grade,temp_conf = false,false,false,false,false 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["star_" .. 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 ------------------------- if not is_max then temp_conf = self.model:GetLightLvConfOne( self.cur_select_id,grade,star ) if temp_conf then next_lv = temp_conf.next_lv next_grade = temp_conf.next_grade img_node = self["star2_" .. i .. "_img"] use_style = next_grade > 0 and next_grade or 1 if next_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 end end end ------------------------- --特殊属性 local lv_conf = self.model:GetLightLvConfOne( self.cur_select_id, 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_id 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 is_active = self.model:GetLightIsActive( self.cur_select_id ) self.lb_attr_tmp.text = name1 .. ":" .. val1 SetAttrIconByColorType(self, self.icon_special_img, attr_id, nil, 2) local temp_str = is_active and (temp_data2[1] and "提升)" or "激活)") or "解锁)" self.lb_attr_des_tmp.text = "(" .. min_grade .. "阶" .. min_lv .. "星" .. temp_str if min_grade == 999 then self.lb_attr_des_tmp.text = "" end else local _, name1, _, val1 = WordManager:GetPropertyInfo(attr_id, attr_num == 0 and min_val or attr_num) self.lb_attr_tmp.text = name1 .. ":" .. val1 self.lb_attr_des_tmp.text = "" end end function LightSubView:UpdateCost( ) local is_active = self.model:GetLightIsActive( self.cur_select_id ) local success_rate = 0--成功率 ------------------------- local base_conf = self.model:GetLightConfOne( self.cur_select_id ) if not base_conf then return end local basic = self.model:GetLightInfoOne( self.cur_select_id ) local grade,star = 0,0 if basic then grade = basic.grade star = basic.lv end local cost_data = stringtotable(base_conf.item)[1] local lv_conf = self.model:GetLightLvConfOne( self.cur_select_id, grade, star ) if not is_active then cost_data = stringtotable(base_conf.item)[1] else if lv_conf then cost_data = stringtotable(lv_conf.cost)[1] success_rate = lv_conf.rate end end if is_active then self.lb_tip_up_tmp.text = string.format( "成功率:%d%%", success_rate ) else self.lb_tip_up_tmp.text = "" end if self.model:GetLightIsMax( self.cur_select_id ) then self.lb_tip_up_tmp.text = "" self.btn_up_text_tmp.text = "已满级" SetImageGray( self.btn_up_img, true ) SetTMPSharedMaterial(self.btn_up_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn) else if is_active then self.btn_up_text_tmp.text = (lv_conf.next_lv == 1 and grade ~= 0) and "突破" or "升星" else self.btn_up_text_tmp.text = "激活" end SetImageGray( self.btn_up_img, false ) SetTMPSharedMaterial(self.btn_up_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZSDFOutlineDarkOrangeBtn) end self.need_more_goods_id = false self.jump_active = false if cost_data then --使用道具 self.btn_up_obj:SetActive(true) self.con_condition_other_obj:SetActive(false) self.btn_active_obj:SetActive(false) self.cost_con_obj:SetActive(true) ------------------------- self.cost_item:SetDataWithMapId(cost_data[2]) self.name_text_tmp.text = GoodsModel:getInstance():getGoodsName(cost_data[2], true) local goods_num = GoodsModel:getInstance():GetGoodsNumFromType(cost_data[1], cost_data[2]) self.num_text_tmp.text = WordManager:AddColorToString(goods_num,goods_num >= cost_data[3] and '2CF86F' or 'ff203a',false) .. "/" .. cost_data[3] self.need_more_goods_id = goods_num < cost_data[3] and cost_data[2] --消耗道具提示 self.con_di_cost_obj:SetActive(true) else self.cost_con_obj:SetActive(false) --不需要使用道具 if is_active then --满级? self.btn_up_obj:SetActive(true) self.con_condition_other_obj:SetActive(false) self.btn_active_obj:SetActive(false) ------------------------- self.con_di_cost_obj:SetActive(true) else --需要条件激活 self.btn_up_obj:SetActive(false) local can_active = self.model:CanLightActive(false,self.cur_select_id) self.con_condition_other_obj:SetActive(true) self.btn_active_obj:SetActive(true) ------------------------- if not can_active then self.jump_active = stringtotable(base_conf.guide) or false end if self.jump_active and self.jump_active[1] then lua_resM:setImageSprite(self,self.btn_active_img,'light_asset',"light_icon_23",true) else lua_resM:setImageSprite(self,self.btn_active_img,'light_asset',"light_icon_22",true) end self.lb_active_other_tmp.text = Trim(base_conf.desc) or "" local info_condition = stringtotable(base_conf.condition) if info_condition[1] and info_condition[1][1] == "login" then local cur = self.model:GetLoginDay( ) local is_enough = cur >= tonumber(info_condition[1][2]) cur = is_enough and tonumber(info_condition[1][2]) or cur local color = is_enough and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK self.lb_active_other_tmp.text = self.lb_active_other_tmp.text .. "(" .. HtmlColorTxt( cur, color) .. "/" .. tonumber(info_condition[1][2]) .. ")" end self.con_di_cost_obj:SetActive(false) ------------------------- --但是仍然要显示进阶道具? --[[local lv_conf = self.model:GetLightLvConfOne( self.cur_select_id, 0, 0 ) if lv_conf then cost_data = stringtotable(lv_conf.cost)[1] end self.cost_item:SetDataWithMapId(cost_data[2]) self.name_text_tmp.text = GoodsModel:getInstance():getGoodsName(cost_data[2], false) local goods_num = GoodsModel:getInstance():GetGoodsNumFromType(cost_data[1], cost_data[2]) self.num_text_tmp.text = WordManager:AddColorToString(goods_num,goods_num >= cost_data[3] and '00b82b' or 'fa1022',false) .. "/" .. cost_data[3] self.need_more_goods_id = (not can_active) and cost_data[2] or false --消耗道具提示--]] end end end function LightSubView:SetData( _a,_b,select_id ) self.select_id = select_id if self.is_loaded then -- self.need_refreshData = false self:UpdateView() self:ShowModel(true) -- else -- self.need_refreshData = true end end function LightSubView:__delete( ) if self.cost_item then UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.cost_item) self.cost_item = nil end if self.attr_effect_time_id then GlobalTimerQuest:CancelQuest(self.attr_effect_time_id) self.attr_effect_time_id = nil end if self.guide_trigger_id then GlobalEventSystem:UnBind(self.guide_trigger_id) self.guide_trigger_id = nil end if self.di_fight then self:ClearUIEffect(self.di_fight.transform) end end function LightSubView:AddToStageHandler() local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,4) if not helpVo then return end local help_type = helpVo.help_type local step = helpVo.step local button = false if help_type == HelpType.TYPE_LIGHT and step == 4 then button = self.btn_active_obj end if button then local function call_back() end GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file) end end