CapsuleEggView = CapsuleEggView or BaseClass(BaseView) local CapsuleEggView = CapsuleEggView function CapsuleEggView:__init() self.base_file = "capsuleEgg" self.layout_file = "CapsuleEggView" self.layer_name = "UI" self.destroy_imm = true self.use_background = true self.change_scene_close = true self.hide_maincancas = true --是否隐藏主界面 self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = true --是否要显示顶部的金钱栏 self.ten_buff_offer = 100--默认不打折 self.close_fog = true self.is_set_zdepth = true self.need_culling_mask_ground = true --打开界面是否需要摄像机剔除ground层 self.blur_activity_bg = true self.use_show_anim = true self.use_hide_anim = true self:AddPreLoadList("capsuleEgg", {"CapsuleEggRecordItem"}) self.mainVo = RoleManager.Instance.mainRoleInfo self.model = CapsuleEggModel:getInstance() self.reward_item_list = {} self.cache_record_list = {} -- 当前页签的节点数据比上个页签少的时候,把多余的节点存进来 self.show_item_list = {} self.label_list = {} self.current_pool_type = nil self.last_draw_time_1 = 0 self.last_draw_time_10 = 0 self.last_draw_time_50 = 0 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 CapsuleEggView:Open(index) self.current_pool_type = index or CapsuleEggConst.PoolType.Dragon BaseView.Open(self) end function CapsuleEggView:LoadSuccess() local nodes = { "bg:raw","titleImg:img", "sloganImg:img", "costIcon3:img", "costIcon1:img", "costIcon2:img", --花费货币图标 "costPrice1:tmp", "costPrice3:tmp", "costPrice2:tmp", "closeBtn:obj", --奖品栏 "awardCon/award7", "awardCon/award3", "awardCon/award5", "awardCon/award2", "awardCon/award8", "awardCon/award1", "awardCon/award9", "awardCon/award4", "awardCon/award6", "awardCon/award10", "drawBtn_1:obj", "drawBtn_10:obj", "drawBtn_50:obj", --抽奖按钮 "recordCon/recordScrollView/Viewport/Content", "recordCon/recordScrollView:obj", "recordCon/recordBg:img", "countDown:tmp",--免费倒计时 "drawBtn_1/drawBtnText:tmp", "drawBtn_1/drawRed1:obj", "drawBtn_50/drawRed50:obj", "drawBtn_10/drawRed10:obj", "helpBtn:obj", "probBtn:obj", "rewardBtn:obj", "rewardBtn/rewardRed:obj", "recordCon", "recordCon/recordTips:tmp", "awardCon/award_scroll/Viewport/award_con", "awardCon/award_scroll", "rewardcountDown:tmp", "con_money:obj", --打折BUFF节点 "tenBuffText:tmp", "fiftyBuffText:tmp", "costPriceOfferLine3:obj", "costPriceOffer3:tmp", "costPriceOfferLine2:obj", "costPriceOffer2:tmp", --龙神常驻BUFF节点 "buffBtn:obj:img", "buffTimeText:tmp", "buffTipImg:obj", --不足十连提示气泡 "tenTips:obj", "tenTips/tenTipsGetBtn:obj", "tenTips/tenTipsLeftNum:tmp", "rewardPreviewBtn:obj", --幸运值 "luckyCon/luckyProgressLb:tmp", "luckyCon/luckyAdditionLb:tmp", "luckyCon/luckySlider:img", } self:GetChildren(nodes) self.reward_con_list = {} for i=1,10 do self.reward_con_list[i] = self["award"..i] end lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("capsule_egg_bg_1280_720")) -- lua_resM:setOutsideImageSprite(self, self.recordBg_img, GameResPath.GetCapsuleEggRes("capsule_egg_record_bg")) SetSizeDelta(self.transform, ScreenWidth, ScreenHeight) self:SetIpxMode() local function bg_back_func( ... ) if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend")) end self:MoveUIToBack(self.bg_raw) end if self.background_wnd then bg_back_func() else self.bg_back_func = bg_back_func end if not self.money_view then self.money_view = UIMoneyView.New(self.con_money) self.money_view:SetPosition(0,0) self.money_view:SetData() self.money_view:ChangeShowFlag("capsuleegg", 102305) end end function CapsuleEggView:AddEvent() local on_click = function ( click_obj ) if self.closeBtn_obj == click_obj then--关闭界面 self:Close() elseif self.rewardBtn_obj == click_obj then --奖励预览 self.model:Fire(CapsuleEggConst.OPEN_CAPSULE_EGG_REWARD_VIEW, current_pool_type) elseif self.drawBtn_1_obj == click_obj then--单抽 CustomActivityModel:getInstance():SetGoodsCanFly(false) if TimeUtil:getServerTimeMs()/1000 - self.last_draw_time_1 > 1 then self.last_draw_time_1 = TimeUtil:getServerTimeMs()/1000 self:StartDraw(1) end elseif self.drawBtn_10_obj == click_obj then--十连 CustomActivityModel:getInstance():SetGoodsCanFly(false) if TimeUtil:getServerTimeMs()/1000 - self.last_draw_time_10 > 1 then self.last_draw_time_10 = TimeUtil:getServerTimeMs()/1000 self:StartDraw(10) end elseif self.drawBtn_50_obj == click_obj then--五十连 if TimeUtil:getServerTimeMs()/1000 - self.last_draw_time_50 > 1 then self.last_draw_time_50 = TimeUtil:getServerTimeMs()/1000 self:StartDraw(50) end elseif self.helpBtn_obj == click_obj then EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 17000) elseif self.probBtn_obj == click_obj then Message.show("概率公式待完善") elseif self.tenTipsGetBtn_obj == click_obj then UIToolTipMgr:getInstance():AppendGoodsTips(102305, nil, nil,nil,nil,nil,nil,true,true) elseif self.rewardPreviewBtn_obj == click_obj then self.model:Fire(CapsuleEggConst.OPEN_CAPSULE_EGG_REWARD_PRE_VIEW,self.current_pool_type) elseif self.buffBtn_obj == click_obj then--龙神常驻BUFF按钮 local buff_kind = OperateActivityModel.MaterialSubmitBuffKind.EGG_LUCKY_NUM --触发加成后,龙神宝库前2次10连抽享受八折优惠(十连券不计入) local buff_cfg,buff_info,dot = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(buff_kind) if buff_cfg and buff_info then local abs_pos = click_obj.transform:TransformPoint(Vector3.zero) local sub_type = CustomActivityModel:getInstance():getActMinSubType(CustomActivityModel.CustomActBaseType.MATERIAL_SUBMIT) local act_list = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.MATERIAL_SUBMIT, sub_type) if act_list then local buff_data = nil for k,v in pairs(act_list.condition_list) do--[{role_lv,80},{sub,1},{cost,30},{group,5}] if v[1] == "suit" then--全服进度套件ID buff_data = OperateActivityModel:getInstance():GetMaterialSubmitServerCfg(tonumber(v[2]),dot) break end end if buff_data then local data = { sub_type = sub_type, buff_data = buff_data, pos_x = abs_pos.x, pos_y = abs_pos.y, is_outside = true, } OperateActivityModel:getInstance():Fire(OperateActivityModel.OPEN_MATERIAL_SUBMIT_BUFF_VIEW,data) end end end end end AddClickEvent(self.closeBtn_obj, on_click) AddClickEvent(self.drawBtn_1_obj, on_click) AddClickEvent(self.drawBtn_10_obj, on_click) AddClickEvent(self.drawBtn_50_obj, on_click) AddClickEvent(self.helpBtn_obj, on_click) AddClickEvent(self.probBtn_obj, on_click) AddClickEvent(self.rewardBtn_obj, on_click) AddClickEvent(self.tenTipsGetBtn_obj, on_click) AddClickEvent(self.rewardPreviewBtn_obj, on_click) AddClickEvent(self.buffBtn_obj, on_click) --刷新倒计时 local function on_update_count_down(pool_type) if pool_type == self.current_pool_type then self:UpdataFreeTimeInfo() end end self:BindEvent(self.model,CapsuleEggConst.UPDATE_CAPSULE_EGG_FREE_COUNT_DOWN,on_update_count_down) --刷新全服记录 local function on_update_record(pool_type) if pool_type == self.current_pool_type then self:UpdateASRecord() end end self:BindEvent(self.model,CapsuleEggConst.UPDATE_SERVER_RECORD,on_update_record) local function on_ans_update_red_dot() self:UpdateRed() self:UpdateCost() end self:BindEvent(self.model, CapsuleEggConst.ANS_UPDATE_RED_DOT, on_ans_update_red_dot) local function on_goods_num_update() self:UpdateCost() self:UpdateTenTipsShow() end self:BindEvent(self.model, CapsuleEggConst.UPDATE_CPASULE_EGG_GOODS_NUM, on_goods_num_update) local function updata_buff_state(id) if id == KfActivityModel.TabID.MaterialSubmit and self.is_loaded then self:UpdateCost() end end self:BindEvent(KfActivityModel:getInstance(), KfActivityModel.ANS_UPDATE_VIEW, updata_buff_state) local function onOrientationChange() self:SetIpxMode() end self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange) local function on_update_lucky_num() if not self.is_loaded then return end if self._use_delete_method then return end self:UpdateLuckyCon() end self:BindEvent(self.model, CapsuleEggConst.UPDATE_CAPSULE_SERVER_LUCKY, on_update_lucky_num) end function CapsuleEggView:SetIpxMode( ) if ClientConfig.iphone_x_model then self.closeBtn.anchoredPosition = Vector2(-8-ClientConfig.iphone_x_offset_right, 335) self.titleImg.anchoredPosition = Vector2(-48+ClientConfig.iphone_x_offset_left, 306) -- self.recordCon.anchoredPosition = Vector2(0+ClientConfig.iphone_x_offset_left, -278) -- self.rewardBtn.anchoredPosition = Vector2(-101-ClientConfig.iphone_x_offset_right, -280) -- self.rewardcountDown.anchoredPosition = Vector2(-85-ClientConfig.iphone_x_offset_right, -326) end end function CapsuleEggView:SetJinValue() if self.is_loaded then self.num_1_tmp.text = WordManager:ConvertNum(self.mainVo.jin) end end function CapsuleEggView:OpenSuccess() self:UpdateRed() self:SwitchTab(self.current_pool_type) end function CapsuleEggView:SwitchTab( index ) -- if index == self.current_pool_type then return end self.current_pool_type = index self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17000,self.current_pool_type) self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17001,self.current_pool_type) lua_resM:setOutsideImageSprite(self, self.titleImg_img, GameResPath.GetCapsuleEggRes("capsule_egg_draw_type_title_"..self.current_pool_type),true) lua_resM:setOutsideImageSprite(self, self.sloganImg_img, GameResPath.GetCapsuleEggRes("capsule_egg_slogan_"..self.current_pool_type),true) self:UpdateRewardCon() self:UpdateASRecord() self:UpdataFreeTimeInfo() self:UpdateCost() self:UpdateResetTime() self:UpdateLuckyCon() self:UpdateTenTipsShow() end --全服概率展示 function CapsuleEggView:UpdateLuckyCon( ) local server_lucky = self.model:GetServerlucky(self.current_pool_type) if self.have_act_buff_lucky_num then server_lucky = 999 end local max_server = 999 self.luckyProgressLb_tmp.text = server_lucky.."/"..max_server self.luckySlider_img.fillAmount = server_lucky/max_server local cfg = self.model.capsule_egg_kv_cfg["server_lucky_value"] if cfg then local lucky_addition_list = stringtotable(cfg.value) local lucky_addition = lucky_addition_list[1][2] for i,v in ipairs(lucky_addition_list) do if server_lucky >= v[1] then lucky_addition = v[2] end end self.luckyAdditionLb_tmp.text = "+"..lucky_addition.."%" end end --显示奖品 function CapsuleEggView:UpdateRewardCon( ) local reward_cfg = self.model:GetRewardCfg(self.current_pool_type) for k,v in pairs(self.reward_item_list) do v:SetVisible(false) end for i=1,10 do local item = self.reward_item_list[i] if not item then -- item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.reward_con_list[i]) item = CapsuleEggShowAwardItem.New(self.reward_con_list[i]) self.reward_item_list[i] = item end local award_item_size = CapsuleEggConst.AwardItemSize[i] -- item:SetItemSize(award_item_size, award_item_size) item:SetVisible(true) local goods_type_id = reward_cfg[i][2] item:SetData(goods_type_id,i) end local sub_reward_cfg = {} for i,v in ipairs(reward_cfg) do if i > 10 then table.insert(sub_reward_cfg, v) end end -- for i,v in ipairs(self.show_item_list) do -- v:SetVisible(false) -- end -- for i,v in ipairs(sub_reward_cfg) do -- local item = self.show_item_list[i] -- if not item then -- item = CapsuleEggShowAwardItemTwo.New(self.award_con, nil, self.layer_name) -- self.show_item_list[i] = item -- item:SetAnchoredPosition((70 + 18) * (i - 1), 0 ) -- end -- item:SetVisible(true) -- item:SetData(v[2]) -- end -- SetSizeDelta(self.award_con, #sub_reward_cfg * (70 + 18), 84) end --刷新全服记录 function CapsuleEggView:UpdateASRecord( ) local record_list = self.model:GetAllRecordList(self.current_pool_type) local x1 = self.model:GetStickRecordList(self.current_pool_type) local x2 = self.model:GetNormalRecordList(self.current_pool_type) -- 创建的时候要暂停动画 self:StopTextAction() local del_num = 0 for k = #self.cache_record_list, 1, -1 do self.label_list[#self.label_list+1] = table.remove(self.cache_record_list, k) end for k,v in pairs(self.label_list) do v:SetVisible(false) end if #record_list == 0 then self.recordTips_tmp.text = "暂无全服记录" self.recordScrollView_obj:SetActive(false) else self.recordTips_tmp.text = "" self.recordScrollView_obj:SetActive(true) end local node_height = self.recordScrollView.sizeDelta.y local height = 0 local item self.record_count = 0 for k, v in ipairs(record_list) do if k > self.model.max_record_count then break end item = self.label_list[k] if not item then item = CapsuleEggRecordItem.New(self.Content) self.label_list[k] = item end item:SetAnchoredPosition(5, -height) item:SetVisible(true) height = height + item:SetData(v) self.record_count = self.record_count + 1 end if self.record_count < #self.label_list then for i = #self.label_list, self.record_count + 1, -1 do self.cache_record_list[#self.cache_record_list+1] = table.remove(self.label_list, i) end end SetSizeDeltaY(self.Content, height) if height > node_height then self:StartTextAction() end end function CapsuleEggView:StartTextAction()--开始轮播动画 self:StopTextAction() local time = 1 local function func() self:UpdateTextPos() self:Movetext() end self.time_id = GlobalTimerQuest:AddPeriodQuest(func,time,-1) end function CapsuleEggView:StopTextAction() if self.time_id then GlobalTimerQuest:CancelQuest(self.time_id) self.time_id = nil end self:StopMove() end function CapsuleEggView:Movetext() local text = self.label_list[1] local move_height = text:GetAnchoredPosition().y move_height = move_height > 0 and 0 or move_height for k,text in pairs(self.label_list) do text:StartAction(move_height) end end function CapsuleEggView:StopMove() for k,text in pairs(self.label_list) do text:StopAction() end end function CapsuleEggView:UpdateTextPos() local delete_index={} local height = 0 for i=1,self.record_count do local text = self.label_list[i] if text then local vis = text:GetVisible() local h = text:GetRecordHeight() local y = text:GetAnchoredPosition().y height = height + (vis and h or 0) if y + h > 40 and vis then table.insert(delete_index,i) end end end local del_num=0 local t = {} for i,v in ipairs(delete_index) do local index= v-del_num local text = table.remove(self.label_list,index) t[#t+1] = text del_num=del_num+1 end for i=1,#t do local text = t[i] text:SetAnchoredPosition(5,-height) table.insert(self.label_list , text) end end --刷新免费抽奖时间展示 function CapsuleEggView:UpdataFreeTimeInfo() local next_free_draw = self.model:GetNextFreeDrawTimeByPoolType(self.current_pool_type) if next_free_draw ~= 0 and self.model:GetFreeDrawTimesByPoolType(self.current_pool_type) == 0 then local time = next_free_draw - TimeUtil:getServerTime() self.drawRed1_obj:SetActive(time <= 0) self:UpdateFreeOneLuck() else GlobalTimerQuest:CancelQuest(self.count_down_timer_id) self.count_down_timer_id = nil self.drawRed1_obj:SetActive(true) self.drawBtnText_tmp.text = "本次免费" self.countDown_tmp.text = "" end end function CapsuleEggView:UpdateFreeOneLuck( )--更新免费次数剩余时间 local have_time = self.model:GetNextFreeDrawTimeByPoolType(self.current_pool_type)-TimeUtil:getServerTime() self.countDown_tmp.text = "" GlobalTimerQuest:CancelQuest(self.count_down_timer_id) self.count_down_timer_id = nil if have_time > 0 then self.drawRed1_obj:SetActive(false) local function onTimer() have_time = have_time - 1 if have_time > 0 then self.countDown_tmp.text = string.format("%s 后免费",TimeUtil:timeConvert13(have_time)) self.drawBtnText_tmp.text = "寻宝 1 次" else GlobalTimerQuest:CancelQuest(self.count_down_timer_id) self.count_down_timer_id = nil self.countDown_tmp.text = "" self.drawRed1_obj:SetActive(true) self.drawBtnText_tmp.text = "本次免费" --请求协议刷新一次信息 self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17000,self.current_pool_type) end end onTimer() if not self.count_down_timer_id then self.count_down_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1) end self.drawRed1_obj:SetActive(false) self.drawBtnText_tmp.text = "寻宝 1 次" else self.drawRed1_obj:SetActive(true) self.drawBtnText_tmp.text = "本次免费" end end --开始扭蛋 function CapsuleEggView:StartDraw(times) local ticket_num_list = self.model:GetCostTicketNumList() local price_asset, price_icon = WordManager:GetCommonMoneyIcon(1) local cost_price = 0 local tickets_goods_type_id = 102305 if self.current_pool_type == 1 then tickets_goods_type_id = 102305 elseif self.current_pool_type == 2 then tickets_goods_type_id = 102308 elseif self.current_pool_type == 3 then tickets_goods_type_id = 102311 end local tickets_price = Config.Goodsprice[tickets_goods_type_id].price if times == 1 then if self.model:CanFreeDraw(self.current_pool_type) then--免费抽 self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,1) return else if ticket_num_list[self.current_pool_type][1] >= 1 then--有单抽券直接抽 self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) return else--补齐 cost_price = tickets_price end end elseif times == 10 then if ticket_num_list[self.current_pool_type][2] >= 1 then self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) return else local ten_need_num = math.floor(self.ten_cost_num*self.ten_buff_offer/100 + 0.5)--折扣完后要四舍五入 if ticket_num_list[self.current_pool_type][1] >= ten_need_num then self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) return else cost_price = (ten_need_num -ticket_num_list[self.current_pool_type][1])*tickets_price end end elseif times == 50 then if ticket_num_list[self.current_pool_type][3] >= 1 then self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) return else local fifty_need_num = math.floor(self.fifty_cost_num*self.fifty_buff_offer/100 + 0.5)--折扣完后要四舍五入 if ticket_num_list[self.current_pool_type][1] >= fifty_need_num then self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) return else cost_price = (fifty_need_num-ticket_num_list[self.current_pool_type][1])*tickets_price end end end local function ok_callback( ... ) self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.current_pool_type,times,0) end local function toggle_function( flag ) self.model._again_draw_no_double_check = flag end local function use_function( toggle_tip_data,call_fun_sum ) if not self.model._again_draw_no_double_check and cost_price ~= 0 then GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data) else call_fun_sum() end end local buy_tip_data = { gold_type = 1,--货币类型 cost_price = cost_price,--消耗金额 ok_callback = ok_callback,--成功 toggle_function = toggle_function,--多选 togglePriceStr = string.format("%s 补齐所需的单抽券",cost_price),--提示语 use_function = use_function,--最终调用 } CustomActivityModel:getInstance():BuyTips(buy_tip_data) end function CapsuleEggView:UpdateCost( ) local cost_ticket_num_list = self.model:GetCostTicketNumList() lua_resM:setOutsideImageSprite(self, self.costIcon1_img, GameResPath.GetGoodsIcon(self.model:GetCostTicketGTypeId(self.current_pool_type,1)),true) if cost_ticket_num_list[self.current_pool_type][1] == 0 then self.costPrice1_tmp.text = string.format("<%s>%s/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.current_pool_type][1]) else self.costPrice1_tmp.text = string.format("<%s>%s/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.current_pool_type][1]) end local buff_kind = OperateActivityModel.MaterialSubmitBuffKind.LUCKY_OFFER --是否存在活动加成buff 挑战次数+1 local buff_cfg,buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(buff_kind) -- buff_cfg = {discount = 80,data = 1} -- buff_info = {etime = TimeUtil:getServerTime( )+300,used = {{kdata = 10,vdata=0}}} self.ten_cost_num = 9 local have_time = buff_cfg and buff_cfg.data or 0 local show_offer_obj = false self.ten_buff_offer = 100 local ten_buff_sum_time = 0 if cost_ticket_num_list[self.current_pool_type][2] > 0 then--有十连券 lua_resM:setOutsideImageSprite(self, self.costIcon2_img, GameResPath.GetGoodsIcon(self.model:GetCostTicketGTypeId(self.current_pool_type,10)),true) self.ten_cost_num = 1 if cost_ticket_num_list[self.current_pool_type][2] < 1 then self.costPrice2_tmp.text = string.format("<%s>%s/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.current_pool_type][2]) else self.costPrice2_tmp.text = string.format("<%s>%s/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.current_pool_type][2]) end else if buff_cfg and buff_info then local sec = buff_info.etime - TimeUtil:getServerTime( ) if sec > 0 then self:ActBuffTimeLate(sec) for k,v in pairs(buff_info.used) do if v.kdata == 10 then--十连还有次数 have_time = have_time - v.vdata break end end if have_time > 0 then show_offer_obj = true self.ten_buff_offer = buff_cfg.discount end end end lua_resM:setOutsideImageSprite(self, self.costIcon2_img, GameResPath.GetGoodsIcon(self.model:GetCostTicketGTypeId(self.current_pool_type,1)),true) local lucky_num = show_offer_obj and math.floor(self.ten_cost_num*self.ten_buff_offer/100 + 0.5) or 9 if cost_ticket_num_list[self.current_pool_type][1] < lucky_num then self.costPrice2_tmp.text = string.format("<%s>%s/%s", ColorUtil.RED_DARK, cost_ticket_num_list[self.current_pool_type][1], lucky_num) else self.costPrice2_tmp.text = string.format("<%s>%s/%s", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.current_pool_type][1], lucky_num) end end self.costPriceOffer2_tmp.text = show_offer_obj and self.ten_cost_num or "" self.costPriceOfferLine2_obj:SetActive(show_offer_obj) self.tenBuffText_tmp.text = show_offer_obj and string.format("限时%s%%优惠:%s/%s",self.ten_buff_offer,have_time,buff_cfg.data) or "" local btn2_red_condition_1 = self.model:GetDrawBtnRed(self.current_pool_type,2)--有十连券 local need_one_tickets_can_red = show_offer_obj and math.floor(self.ten_cost_num*self.ten_buff_offer/100 + 0.5) or 9 local btn2_red_condition_2 = cost_ticket_num_list[self.current_pool_type][1] >= need_one_tickets_can_red local btn2_red = btn2_red_condition_1 or btn2_red_condition_2 self.drawRed10_obj:SetActive(btn2_red) self.show_offer_obj = show_offer_obj self.fifty_cost_num = 45 self.fifty_buff_offer = 100 if cost_ticket_num_list[self.current_pool_type][3] > 0 then--有五十连券 lua_resM:setOutsideImageSprite(self, self.costIcon3_img, GameResPath.GetGoodsIcon(self.model:GetCostTicketGTypeId(self.current_pool_type,50)),true) if cost_ticket_num_list[self.current_pool_type][3] < 1 then self.costPrice3_tmp.text = string.format("<%s>%s/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.current_pool_type][3]) else self.costPrice3_tmp.text = string.format("<%s>%s/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.current_pool_type][3]) end self.fifty_cost_num = 1 else lua_resM:setOutsideImageSprite(self, self.costIcon3_img, GameResPath.GetGoodsIcon(self.model:GetCostTicketGTypeId(self.current_pool_type,1)),true) if cost_ticket_num_list[self.current_pool_type][1] < 45 then self.costPrice3_tmp.text = string.format("<%s>%s/45", ColorUtil.RED_DARK, cost_ticket_num_list[self.current_pool_type][1]) else self.costPrice3_tmp.text = string.format("<%s>%s/45", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.current_pool_type][1]) end end local buff_kind = OperateActivityModel.MaterialSubmitBuffKind.EGG_LUCKY_NUM --触发加成后,龙神宝库幸运值持续维持999,抽中不清空 local buff_cfg,buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(buff_kind) -- buff_cfg = {discount = 80,data = 1} -- buff_info = {etime = TimeUtil:getServerTime( )+300,used = {{kdata = 10,vdata=0}}} self.have_act_buff_lucky_num = false if buff_cfg and buff_info then local sec = buff_info.etime - TimeUtil:getServerTime( ) if sec > 0 then self:ActEggLuckyBuffTimeLate(sec) self:UpdateLuckyCon() self.buffBtn_obj:SetActive(true) self.buffTipImg_obj:SetActive(true) self.have_act_buff_lucky_num = true lua_resM:setOutsideImageSprite(self, self.buffBtn_img, GameResPath.GetOperateActImage("ms_buff_btn_kind_6"), true) else self.buffBtn_obj:SetActive(false) self.buffTipImg_obj:SetActive(false) self.buffTimeText_tmp.text = "" end else self.buffBtn_obj:SetActive(false) self.buffTipImg_obj:SetActive(false) self.buffTimeText_tmp.text = "" end end --活动龙神常驻BUFF时间倒计时 function CapsuleEggView:ActEggLuckyBuffTimeLate( sec ) if self.is_loaded then if self.act_egg_sec == sec then return else self.act_egg_sec = sec end if self.act_egg_lucky_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_egg_lucky_buff_timer_id) self.act_egg_lucky_buff_timer_id = nil end local sec = sec or 0 if sec > 0 then local function onTimer() sec = sec - 1 if sec > 0 then self.buffTimeText_tmp.text = TimeUtil:timeConvert33(sec) else if self.act_egg_lucky_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_egg_lucky_buff_timer_id) self.act_egg_lucky_buff_timer_id = nil end self:UpdateCost() self:UpdateLuckyCon() end end if not self.act_egg_lucky_buff_timer_id then self.act_egg_lucky_buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1) end onTimer() else self:UpdateCost() end end end --活动BUFF时间倒计时 function CapsuleEggView:ActBuffTimeLate( sec ) if self.is_loaded then if self.act_sec == sec then return else self.act_sec = sec end if self.act_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_buff_timer_id) self.act_buff_timer_id = nil end local sec = sec or 0 if sec > 0 then local function onTimer() sec = sec - 1 if sec > 0 then else if self.act_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_buff_timer_id) self.act_buff_timer_id = nil end self:UpdateCost() end end if not self.act_buff_timer_id then self.act_buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1) end onTimer() else self:UpdateCost() end end end function CapsuleEggView:DestroySuccess( ) if self.act_egg_lucky_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_egg_lucky_buff_timer_id) self.act_egg_lucky_buff_timer_id = nil end if self.act_buff_timer_id then GlobalTimerQuest:CancelQuest(self.act_buff_timer_id) self.act_buff_timer_id = nil end for k,v in pairs(self.reward_item_list) do v:DeleteMe() end self.reward_item_list = {} if self.count_down_timer_id then GlobalTimerQuest:CancelQuest(self.count_down_timer_id) self.count_down_timer_id = nil end self:StopTextAction() for k,v in pairs(self.label_list) do v:DeleteMe() end self.label_list = {} for k,v in pairs(self.cache_record_list) do v:DeleteMe() end self.cache_record_list = {} if self.timer then GlobalTimerQuest:CancelQuest(self.timer) self.timer = nil end for i,v in ipairs(self.show_item_list) do v:DeleteMe() end if self.money_view then self.money_view:DeleteMe() self.money_view = nil end self.model:CheckHaveSeeRedDot() self:StopTenTipsAnim() end function CapsuleEggView:UpdateRed( ) local btn1_red = self.model:GetFreeDrawTimesByPoolType(self.current_pool_type) > 0 -- local btn2_red = self.model:GetDrawBtnRed(self.current_pool_type,2) -- local btn3_red = self.model:GetDrawBtnRed(self.current_pool_type,3) self.drawRed1_obj:SetActive(btn1_red) -- self.drawRed10_obj:SetActive(btn2_red) -- self.drawRed50_obj:SetActive(btn3_red) self.rewardRed_obj:SetActive(self.model:GetTimeRewardRedDot()) end function CapsuleEggView:UpdateResetTime( ) self.reset_time = self.model:GetTimesRewarResetTime() self.rewardcountDown_tmp.text = "" local function timer_func() local left_time = self.reset_time - TimeUtil:getServerTime() if left_time and left_time > 0 then local str = "" if left_time > 3600 * 24 then str = TimeUtil:qianggouTimeLeft3(left_time, true) else str = TimeUtil:timeConvert11(left_time, false) end self.rewardcountDown_tmp.text = string.format("%s 后重置", str) else self.rewardcountDown_tmp.text = "" self.reset_time = self.model:GetTimesRewarResetTime() end end if not self.timer then self.timer = GlobalTimerQuest:AddPeriodQuest(timer_func, 1) end timer_func() end function CapsuleEggView:Close() --完成引导 local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_CAPSULE_EGG,3) if helpVo then GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo) GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true, true) end BaseView.Close(self) end function CapsuleEggView:UpdateTenTipsShow( ) local cost_ticket_num_list = self.model:GetCostTicketNumList()[self.current_pool_type][1] local ten_cost_ticket_num_list = self.model:GetCostTicketNumList()[self.current_pool_type][2] local lucky_num = self.show_offer_obj and math.floor(self.ten_cost_num*self.ten_buff_offer/100 + 0.5) or 9 local min_num = lucky_num - 3 local max_num = lucky_num - 1 if RoleManager.Instance.mainRoleInfo.level < 9999 and cost_ticket_num_list>=min_num and cost_ticket_num_list<=max_num and ten_cost_ticket_num_list == 0 then self.tenTips_obj:SetActive(true) self.tenTipsLeftNum_tmp.text = string.format("十连抽还差%s张",lucky_num-cost_ticket_num_list) self:TenTipsAnim(0) else self.tenTips_obj:SetActive(false) self:StopTenTipsAnim() SetAnchoredPosition(self.tenTips,342,-289) end end function CapsuleEggView:TenTipsAnim(time) self:StopTenTipsAnim() local call_fun = function () local function onCompleted() self:TenTipsAnim(time) end self.ten_tip_tween_id1 =TweenLite.to(self, self.tenTips,TweenLite.UiAnimationType.POSX,342,1,onCompleted) end local onDelay = function( ) self.ten_tip_tween_id2 =TweenLite.to(self, self.tenTips.transform,TweenLite.UiAnimationType.POSX,355,1,call_fun) end self.ten_tip_timer_id = setTimeout(onDelay, time) end function CapsuleEggView:StopTenTipsAnim( ) if self.ten_tip_tween_id1 then TweenLite.Stop(self.ten_tip_tween_id1) self.ten_tip_tween_id1 = nil end if self.ten_tip_tween_id2 then TweenLite.Stop(self.ten_tip_tween_id2) self.ten_tip_tween_id2 = nil end if self.ten_tip_timer_id then GlobalTimerQuest:CancelQuest(self.ten_tip_timer_id) self.ten_tip_timer_id = nil end end