|
|
- --通用奖励结算界面
- ComSpecialTaskRewardView = ComSpecialTaskRewardView or BaseClass(BaseView)
- local ComSpecialTaskRewardView = ComSpecialTaskRewardView
-
- function ComSpecialTaskRewardView:__init()
- self.base_file = "common"
- self.layout_file = "ComSpecialTaskRewardView"
- self.layer_name = "Top"
- self.destroy_imm = true
- self.use_background = true
- self.hide_maincancas = true --全屏界面需要放开隐藏主UI
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
- self.delay_time = 15
- self.col_num = 3 -- 奖励展示的行展示数
- self.item_list = {}
- self.is_set_zdepth = true --是否设置z深度,当需要盖住下层的UI界面上的模型时,要设true
- self.jump_close = true --用于某些界面跳转了之后就需要关掉界面
- ItemUseModel:getInstance():HideItemUseView( )
- -- self.model = NatureModel: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 ComSpecialTaskRewardView:LoadSuccess()
- local nodes = {
- "mask_bg:obj","bg:raw","titlebg:img","time_text:tmp","awardScroll/Viewport/award_con"
- ,"scroll_mask:obj","awardSmall_con:obj", "awardScroll:obj","effect","effect_forever",
- "natureDes:tmp", "natureValue:tmp",
- }
- self:GetChildren(nodes)
-
- lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("nature_reward_view_997_586"),false)
- lua_resM:setOutsideImageSprite(self, self.titlebg_img, GameResPath.GetCommonImage("com_award_title_bg"),false)
- local function onDelay()
- local function end_call_func( ... )
- if self.effect_forever then
- self:AddUIEffect("getgoods_02",self.effect_forever, self.layer_name, nil, 1, true,nil,nil,nil)
- end
- end
- self:AddUIEffect("getgoods_01",self.effect, self.layer_name, nil, 1, false,nil,nil,end_call_func)
- end
- self.slow_effect_id = GlobalTimerQuest:AddDelayQuest(onDelay, 0.1)
-
- self.natureDes_tmp.text = ""
- self.natureValue_tmp.text = ""
- if self.need_refreshData then
- self:UpdateView( )
- end
- end
-
- function ComSpecialTaskRewardView:UpdateView( )
- if self.is_loaded then
- self.need_refreshData = false
- else
- self.need_refreshData = true
- return
- end
- if not self.data then return end
-
- self:UpdateItemList()
- self:UpdateTime()
- -- self:UpdateNatureTxt()
- end
-
- -- function ComSpecialTaskRewardView:UpdateNatureTxt( )
- -- self.natureDes_tmp.text = self.model:GetTaskNatureTxtStr()
- -- self.natureValue_tmp.text = string.format('额外奖励%s点性格点奖励', HtmlColorTxt( self.model:GetTaskNatureValue(), ColorUtil.GREEN_DARK))
- -- end
-
- function ComSpecialTaskRewardView:DestroySuccess()
- self:ClearUIEffect(self.effect)
- self:ClearUIEffect(self.effect_forever)
-
- if self.slow_effect_id then
- GlobalTimerQuest:CancelQuest(self.slow_effect_id)
- self.slow_effect_id = nil
- end
-
- if self.pos_id then
- TweenLite.Stop(self.pos_id)
- self.pos_id = nil
- end
-
- if self.award_timer_id then
- GlobalTimerQuest:CancelQuest(self.award_timer_id)
- self.award_timer_id = nil
- end
-
- if self.timer_id then
- GlobalTimerQuest:CancelQuest(self.timer_id)
- self.timer_id = nil
- end
-
- for i,item in pairs(self.item_list) do
- item:DeleteMe()
- item = nil
- end
- self.item_list = {}
-
- ItemUseModel:getInstance():ShowItemUseView( )
- end
-
- function ComSpecialTaskRewardView:AddEvent()
- local function onBtnClickHandler(target,x,y)
- if target == self.mask_bg_obj then--关闭
- self:Close()
- end
- end
- AddClickEvent(self.mask_bg_obj,onBtnClickHandler,1)
- end
-
- --data.delay_time--关闭时间
- --data.title_res--标题资源
- --data.title_ab_name--标题资源ab包路径
- --data.award = {kind,type_id,goods_num,goods_vo}
- --data.col_num = 6 -- 每行展示的个数
- function ComSpecialTaskRewardView:Open( data )
- self.data = data
- self.delay_time = self.data and self.data.delay_time or self.delay_time
- BaseView.Open(self)
- end
-
- function ComSpecialTaskRewardView:OpenSuccess( )
- self:UpdateView()
- end
-
- function ComSpecialTaskRewardView:BtnCloseEvt()--关闭按钮回调
- self:Close()
- end
-
- function ComSpecialTaskRewardView:UpdateItemList( )
- for k,v in pairs(self.item_list) do
- v:SetVisible(false,nil,true)
- end
- self.col_num = 3
- local item_list = self.data.award
- if not item_list or TableSize(item_list) == 0 then return end
- local len = #item_list
- local parent_node = len > self.col_num and self.award_con or self.awardSmall_con
- self.awardScroll_obj:SetActive(len > self.col_num)
- local offer_x = 0
- local offer_y = 0
- local x = 0
- local y = 0
- for i, v in ipairs(item_list) do
- local item = self.item_list[i]
- if item == nil then
- item = ComSpecialTaskRewardItem.New(parent_node)
- self.item_list[i] = item
- end
- item:SetData(v)
- item:SetVisible(true)
- --local total_num = 108*6 + 5*10 -- 限定容器长度
- --local offset_x = (total_num - self.col_num * 118)/2 + 10 -- 根据尾部的剩余宽度,整体往右偏移一半
- --item:SetPosition((108+10)*((i - 1)%self.col_num) + offset_x,-(108+10)*math.floor((i-1)/self.col_num))
- --local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
- --local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
- --local stren_data = nil
- -- if v[4] then
- -- stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(v[4])
- -- stren_data.equip_key = "EquipView"
- -- end
- -- if not v.is_mul then--副本多倍
- -- if v.is_rare == 2 then
- -- item:SetNumLimitVisible(true,12)
- -- elseif v.is_rare == 1 then
- -- item:SetNumLimitVisible(true,13)
- -- end
- -- else
- -- item:SetNumLimitVisible(v.is_mul ~= nil ,15)
- -- end
- -- if goodVo then
- -- item:SetData(goods_Id, v[3], goodVo.color, stren_data, lock,true,nil)
- -- else
- -- -- error("没有找到物品信息 "..v.typeId)
- -- end
- --item:SetVisible(false,nil,true)
- end
-
- --SetSizeDeltaY(parent_node,math.ceil(len/self.col_num)*(108+10) + 216)
- --self.awardSmall_con_obj:SetActive(len <= self.col_num)
- -- if not self.data.not_show_anim then
- -- self.scroll_mask_obj:SetActive(true)
- -- local index = 0
- -- local function countDown()
- -- index = index + 1
- -- if index >= 12 and (index - 1)/self.col_num == math.floor((index - 1)/self.col_num) then
- -- if self.pos_id then
- -- TweenLite.Stop(self.pos_id)
- -- self.pos_id = nil
- -- end
- -- local function callback( ... )
- -- SetAnchoredPositionY(parent_node,(108+10)*math.floor((index-1)/self.col_num)-118)
- -- end
- -- local pos_y = (108+10)*math.floor((index-1)/self.col_num)-118
- -- self.pos_id = TweenLite.to(self, parent_node, TweenLite.UiAnimationType.ANCHORED_POSY, pos_y, 0.2, callback)
- -- end
- -- if len >= index then
- -- if self.item_list[index] then
- -- self.item_list[index]:SetVisible(true,nil,true)
- -- end
- -- else
- -- self.scroll_mask_obj:SetActive(false)
- -- if self.award_timer_id then
- -- GlobalTimerQuest:CancelQuest(self.award_timer_id)
- -- self.award_timer_id = nil
- -- end
- -- end
- -- end
- -- if not self.award_timer_id then
- -- self.award_timer_id = GlobalTimerQuest:AddPeriodQuest(countDown,0.15)
- -- end
- -- else
- -- if self.award_timer_id then
- -- GlobalTimerQuest:CancelQuest(self.award_timer_id)
- -- self.award_timer_id = nil
- -- end
- -- for k,v in pairs(self.item_list) do
- -- v:SetVisible(true,nil,true)
- -- end
- -- end
- end
-
- function ComSpecialTaskRewardView:UpdateTime( )
- local time = self.delay_time
- local function countDown()
- if self._use_delete_method then return end
- --if not data then return end
- time = time - 1
- if time > 0 then
- self.time_text_tmp.text = "点击任意处继续"..HtmlColorTxt("("..time.."s)", ColorUtil.WHITE_DARK)
- else
- self:Close()
- end
- end
- countDown()
- if not self.timer_id then
- self.timer_id = GlobalTimerQuest:AddPeriodQuest(countDown,1)
- end
- end
|