源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

320 rivejä
9.2 KiB

GodActivityResultView = GodActivityResultView or BaseClass(BaseView)
local GodActivityResultView = GodActivityResultView
function GodActivityResultView:__init()
self.base_file = "godActivity"
self.layout_file = "GodActivityResultView"
self.layer_name = "Activity"
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 = false --是否要显示顶部的金钱栏
self.blur_activity_bg = true
self.use_show_anim = true
self.use_hide_anim = true
self.is_set_zdepth = true
self.model = GodModel:getInstance()
self.item_list = {}
self.start_pos_x = 0
self.start_pos_y = 0
self.draw_num_type = 0 --结算数量类型 1|单抽 2|10连
self.last_draw_time = 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 GodActivityResultView:Open(data)
self.pool_type = data.pool_type
self.draw_num_type = data.type
self.data = data
BaseView.Open(self)
end
function GodActivityResultView:LoadSuccess()
local nodes = {
"resultBg:img:obj",
"itemCon:obj",
"ScrollView", "ScrollView/Viewport/Content", "ScrollView/Viewport:img",
"visCon:obj",
"visCon/confirmBtn:obj",
"visCon/againBtn:obj",
"visCon/costIcon:img",
"visCon/costPrice:tmp",
"visCon/againBtn/againText:tmp",
"scoreNum:tmp",
"effectCon:obj",
"visCon/lightEffect",
}
self:GetChildren(nodes)
self.visCon_obj:SetActive(true)
self.confirmBtn_obj:SetActive(true)
SetLocalPosition(self.transform, 0, 0,-1000)
local function bg_back_func( ... )
self.itemCon_obj:SetActive(false)
self.awarditem = CapsuleEggAwardItem.New(self.itemCon)
lua_resM:setOutsideImageSprite(self, self.resultBg_img, GameResPath.GetCapsuleEggRes("capsule_egg_result_shine_837_630"))
if self.need_refreshData then
self:UpdateView(self.pool_type)
end
end
if self.background_wnd then
bg_back_func()
else
self.bg_back_func = bg_back_func
end
SetAnchoredPosition(self.lightEffect,0,-40)
self:AddUIEffect("ui_jihuoxinxitong01", self.lightEffect, self.layer_name, nil, 1.2, true,nil,nil, nil, nil,nil)
end
function GodActivityResultView:AddEvent()
local on_click = function ( click_obj )
if self.confirmBtn_obj == click_obj then--关闭界面
self:Close()
-- elseif self.againBtn_obj == click_obj then--再来
-- if TimeUtil:getServerTimeMs()/1000 - self.last_draw_time > 1 then
-- self.last_draw_time = TimeUtil:getServerTimeMs()/1000
-- self:LuckStart()
-- end
end
end
AddClickEvent(self.confirmBtn_obj, on_click)
-- AddClickEvent(self.againBtn_obj, on_click)
end
function GodActivityResultView:OpenSuccess()
self:UpdateView(self.pool_type)
end
function GodActivityResultView:UpdateView(pool_type)
self.pool_type = pool_type
if self.is_loaded then
self.need_refreshData = false
else
self.need_refreshData = true
return
end
local award_data = {}
local debug_test = false
if debug_test then
local temp_data = {}
local tt = {0,230003,5}
for i=1,10 do
table.insert(temp_data,tt)
end
award_data = temp_data
else
award_data = self.data.award
end
self.reward_list = {}
for k,v in pairs(award_data) do
table.insert(self.reward_list,{gtype_id = v[2],goods_num = v[3]})
end
self:Reset()
if not self.reward_list or #self.reward_list == 0 then
return
end
local reward_count = #self.reward_list
if reward_count == 1 then
self.draw_num_type = 1
self.againText_tmp.text = "再来1次"
self.scoreNum_tmp.text = 1
elseif reward_count>1 and reward_count<=10 then
self.draw_num_type = 2
self.againText_tmp.text = "再来10次"
self.scoreNum_tmp.text = 10
end
-- self:UpdateCost()
self:UpdateRewardBoxes()
end
function GodActivityResultView:Reset( )--重置
if self.awarditem then
self.awarditem:StopAction()
self.awarditem:SetAwardItemVis(false)
end
self.Content.anchoredPosition = Vector2(self.start_pos_x,self.start_pos_y)
for k,v in pairs(self.item_list) do
v:SetAwardItemVis(false)
v:StopAction()
end
end
function GodActivityResultView:UpdateRewardBoxes()
local reward_count = #self.reward_list
if reward_count == 1 then
self.itemCon_obj:SetActive(true)
self.awarditem:SetData(self.reward_list[1],1)
self.awarditem:StartAction(1)
return
end
local x = 0
local y = 0
for i = 1, reward_count do
local item = self.item_list[i]
if not item then
item = CapsuleEggAwardItem.New(self.Content)
self.item_list[i] = item
end
item:SetData(self.reward_list[i],i)
x = (84 + 42) * ((i-1)%5)+5
y = -(84 + 30)* math.floor((i-1)/5)-15
item:SetPosition(x,y)
item:StartAction(i)
end
self.Content.sizeDelta = Vector2(0, (84 + 30)* math.floor(reward_count/5)+15)
end
--[[function GodActivityResultView:UpdateCost( )
local costIcon_res = 0
local cost_ticket_num_list = self.model:GetCostTicketNumList()
if self.draw_num_type == 1 then
costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,1)
if cost_ticket_num_list[self.pool_type][1] < 1 then
self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][1])
else
self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][1])
end
elseif self.draw_num_type == 2 then
if self.model:GetCostTicketNumList()[self.pool_type][2] > 0 then
costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,10)
if cost_ticket_num_list[self.pool_type][2] < 1 then
self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][2])
else
self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][2])
end
else
costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,1)
if cost_ticket_num_list[self.pool_type][1] < 9 then
self.costPrice_tmp.text = string.format("<%s>%s</color>/9", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][1])
else
self.costPrice_tmp.text = string.format("<%s>%s</color>/9", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][1])
end
end
end
lua_resM:setOutsideImageSprite(self, self.costIcon_img, GameResPath.GetGoodsIcon(costIcon_res),true)
end--]]
--[[function GodActivityResultView:LuckStart( )
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.pool_type == 1 then
tickets_goods_type_id = 102305
elseif self.pool_type == 2 then
tickets_goods_type_id = 102308
elseif self.pool_type == 3 then
tickets_goods_type_id = 102311
end
local tickets_price = Config.Goodsprice[tickets_goods_type_id].price
if self.draw_num_type == 1 then
if ticket_num_list[self.pool_type][1] >= 1 then--有单抽券直接抽
self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
return
else--补齐
cost_price = tickets_price
end
elseif self.draw_num_type == 2 then
if ticket_num_list[self.pool_type][2] >= 1 then
self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
return
else
if ticket_num_list[self.pool_type][1] >= 9 then
self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
return
else
cost_price = (9-ticket_num_list[self.pool_type][1])*tickets_price
end
end
end
local function close_callback( ... )
self:Close()
end
local function ok_callback()
if GoodsModel:getInstance():IsJinEnough(cost_price) then
self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
return
else
local qc_data = {
price = cost_price,
close_callback = close_callback,
}
GlobalEventSystem:Fire(EventName.OPEN_RECHARGE_TIP_VIEW, true, qc_data)
end
end
local function toggle_function( flag )
self.model._again_draw_no_double_check = flag
end
local toggle_tip_data = {
gold_ab_res = price_asset,
gold_res = price_icon,
price = cost_price,
insufficientText = "",
priceText = string.format("<color=#fdffc2>%s</color> 补齐所需的单抽券",cost_price),
titleText = "提示",
ok_callback = ok_callback,
toggle_function = toggle_function,
is_complex_ok_callback = true,
jump_recharge_callback = close_callback,
}
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
ok_callback()
end
end--]]
function GodActivityResultView:DestroySuccess( )
if self.awarditem then
self.awarditem:DeleteMe()
self.awarditem = nil
end
for i,item in pairs(self.item_list) do
item:DeleteMe()
item = nil
end
self.item_list = {}
self:ClearUIEffect(self.lightEffect)
self:ClearUIEffect(self.effectCon)
end