源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

532 wiersze
23 KiB

-- <*
-- @Author: Saber
-- @Description: 圣物系统抽奖结算界面
-- *>
PsionicDrawResultView = PsionicDrawResultView or BaseClass(BaseView)
local PsionicDrawResultView = PsionicDrawResultView
local PsionicConst = PsionicConst
function PsionicDrawResultView:__init()
self.base_file = "psionic"
self.layout_file = "PsionicDrawResultView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.is_set_zdepth = true
self.blur_activity_bg = true
self.use_show_anim = true
self.use_hide_anim = true
self.max_num = 10
self.item_list = {}
-- 抽卡消耗缓存
self.cost_cache = {}
self.cost_cache[PsionicConst.DrawPoolType.Normal] = {}
self.cost_cache[PsionicConst.DrawPoolType.Deep] = {}
self.is_animating = false
self.can_close_view = false
self.model = PsionicModel:getInstance()
self.goods_model = GoodsModel:getInstance()
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:UpdateView()
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function PsionicDrawResultView:Open(data)
self.data = data
BaseView.Open(self)
end
-- 重新抽奖后重新加载界面数据
function PsionicDrawResultView:ReOpenView(data)
self.data = data
self:UpdateView()
end
function PsionicDrawResultView:LoadSuccess()
local nodes = {
"click_bg:obj",
"bg:obj:raw",
"title:obj",
"skip_btn:obj",
"box_con",
"light_con:obj",
"award_con",
"btn_con:cg",
"btn_con/draw_one_btn:obj",
"btn_con/draw_ten_btn:obj",
"btn_con/cost_icon1:img",
"btn_con/cost_icon2:img",
"btn_con/cost1:tmp",
"btn_con/cost2:tmp",
"btn_con/draw_tip:tmp",
-- "btn_con/draw_btn:obj",
-- "btn_con/draw_btn/draw_lb:tmp",
-- "btn_con/confirm_btn:obj",
}
self:GetChildren(nodes)
SetAnchoredPositionY(self.light_con, -45)
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("ps_draw_result_bg"), false)
-- 提前预载配置
self.normal_cfg = Config.Nucleonpool[1]
self.deep_cfg = Config.Nucleonpool[2]
-- self:AddUIEffect("ui_jihuoxinxitong01", self.light_con, self.layer_name, nil, 1.2, true,nil,nil, nil, nil,nil)
end
function PsionicDrawResultView:AddEvent()
local function click_event(target)
if target == self.draw_one_btn_obj then
self:OnDrawBtnClick(PsionicConst.DrawNumType.OneDraw)
elseif target == self.draw_ten_btn_obj then
self:OnDrawBtnClick(PsionicConst.DrawNumType.TenDraw)
elseif target == self.click_bg_obj or target == self.bg_obj then -- 关闭遮罩
if self.can_close_view then
self:Close()
end
elseif target == self.skip_btn_obj then -- 跳过动画
self:SkipAllAnim()
end
-- if target == self.confirm_btn_obj then
-- self:Close()
-- elseif target == self.draw_btn_obj then
-- self:OnDrawBtnClick()
-- end
end
AddClickEvent(self.draw_one_btn_obj, click_event)
AddClickEvent(self.draw_ten_btn_obj, click_event)
AddClickEvent(self.click_bg_obj, click_event)
AddClickEvent(self.bg_obj, click_event)
AddClickEvent(self.skip_btn_obj, click_event)
-- AddClickEvent(self.confirm_btn_obj, click_event)
-- AddClickEvent(self.draw_btn_obj, click_event)
local function update_draw_data(pool_type) -- 如果对应池子的数据更新,这边也要同步表现
if self.data and self.data.pool == pool_type then
self:UpdateDrawCostDataByType(self.data.pool)
end
end
self:BindEvent(self.model, PsionicConst.UPDATE_DIG_DATA, update_draw_data)
end
function PsionicDrawResultView:UpdateView()
self.data.col_num = 5--限定5了 不能改
self.delay_time = self.data and self.data.delay_time or self.delay_time
self:UpdateDrawCostDataByType(self.data.pool)
self:UpdateDrawTips()
-- self:UpdateDrawBtn()
self:StartDrawAnim()
-- self:UpdateItemList()
end
-- 新版调整 根据池子类型不同,直接更新对应池子的消耗物品信息,并缓存每种情况所需要的花费
function PsionicDrawResultView:UpdateDrawCostDataByType(pool_type)
local cfg_data = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
local pool_data = self.model:GetPsionicDigData(pool_type)
-- 当前是否能免费
local can_free = pool_data and pool_data.remain > 0 and pool_data.rtime - TimeUtil:getServerTime() < 0 or false
-- 获取抽奖券数
local single_ticket_num = self.goods_model:GetTypeGoodsNum(cfg_data.one)
local ten_ticket_num = self.goods_model:GetTypeGoodsNum(cfg_data.ten)
local one_cost = stringtotable(cfg_data.cost)[1]
local ten_cost = stringtotable(cfg_data.pay)[1]
-- 单抽券价格
local single_ticket_price = tonumber(one_cost[3])
local single_ticket_price_type = tonumber(one_cost[1])
local one_cost_icon_asset, one_cost_icon_name = WordManager:GetCommonMoneyIcon(single_ticket_price_type)
local ten_cost_icon_asset, ten_cost_icon_name = WordManager:GetCommonMoneyIcon(ten_cost[1])
if pool_type == PsionicConst.DrawPoolType.Normal then -- 普通池子默认展示红钻,有单抽券时显示单抽券
-- 单抽
-- 没有抽奖券的情况
if can_free then
lua_resM:setImageSprite(self, self.cost_icon1_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
self.cost1_tmp.text = "免费"
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {free = true} -- 免费,可以直接抽
-- 有抽奖券,则加载为抽奖券的图标
elseif single_ticket_num > 0 then
lua_resM:setImageSprite(self, self.cost_icon1_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
self.cost1_tmp.text = string.format("<color=%s>%s</color>/1",
single_ticket_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
single_ticket_num)
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {goods_id = cfg_data.one} -- 构造数据,扣除道具
else -- 显示为钻石付费
lua_resM:setImageSprite(self, self.cost_icon1_img, one_cost_icon_asset, one_cost_icon_name, true)
self.cost1_tmp.text = single_ticket_price
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {price_type = single_ticket_price_type, cost = single_ticket_price} -- 构造数据,扣除金额
end
-- 十连
-- 有十连券,则加载为十连券的图标
if ten_ticket_num > 0 then
lua_resM:setImageSprite(self, self.cost_icon2_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_2", true)
self.cost2_tmp.text = string.format("<color=%s>%s</color>/1", ColorUtil.GREEN_DARK, ten_ticket_num)
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.ten} -- 构造数据,表现为扣除道具
-- 有单抽券,则加载为单抽券,并显示出所需个数相关表现
elseif single_ticket_num > 0 then
lua_resM:setImageSprite(self, self.cost_icon2_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
self.cost2_tmp.text = string.format("<color=%s>%s</color>/9",
single_ticket_num >= 9 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
single_ticket_num)
if single_ticket_num >= 9 then -- 单抽券数量足够,表现为扣除道具
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.one} -- 构造数据,表现为扣除道具
else -- 单抽不足,算出差价,表现为补齐单抽
local need_cost = single_ticket_price * (9 - single_ticket_num)
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,扣除金额
end
-- 普通池子没抽奖券展示红钻
else
lua_resM:setImageSprite(self, self.cost_icon2_img, ten_cost_icon_asset, ten_cost_icon_name, true)
local need_cost = single_ticket_price * 9
self.cost2_tmp.text = need_cost
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,表现为扣除金额
end
else -- 高级池子默认展示道具
-- 单抽
lua_resM:setImageSprite(self, self.cost_icon1_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
-- 免费单抽
if can_free then
self.cost1_tmp.text = "免费"
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {free = true} -- 构造数据,表现为扣除金额
-- 有抽奖券,则加载为抽奖券的图标
else
self.cost1_tmp.text = string.format("<color=%s>%s</color>/1",
single_ticket_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
single_ticket_num)
if single_ticket_num > 0 then
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {goods_id = cfg_data.one} -- 构造数据,扣除道具
else
self.cost_cache[pool_type][PsionicConst.DrawNumType.OneDraw] = {price_type = single_ticket_price_type, cost = single_ticket_price} -- 构造数据,扣除金额
end
end
-- 十连
-- 有十连券,就展示十连券的表现
if ten_ticket_num > 0 then
lua_resM:setImageSprite(self, self.cost_icon2_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_2", true)
self.cost2_tmp.text = string.format("<color=%s>%s</color>/1", ColorUtil.GREEN_DARK, ten_ticket_num)
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.ten} -- 构造数据,表现为扣除道具
-- 有单抽券,则加载为单抽券,并显示出所需个数相关表现
else
lua_resM:setImageSprite(self, self.cost_icon2_img, "psionic_asset", "psionic_dig_icon"..pool_type.."_1", true)
self.cost2_tmp.text = string.format("<color=%s>%s</color>/9",
single_ticket_num >= 9 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
single_ticket_num)
if single_ticket_num >= 9 then -- 单抽券满足
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {goods_id = cfg_data.one} -- 构造数据,表现为扣除道具
else
local need_cost = single_ticket_price * (9 - single_ticket_num)
self.cost_cache[pool_type][PsionicConst.DrawNumType.TenDraw] = {price_type = single_ticket_price_type, cost = need_cost} -- 构造数据,扣除金额
end
end
end
end
function PsionicDrawResultView:UpdateDrawTips( )
if self.data then
-- 遍历属性找到当中符合相应池子配置条件的颜色的数量,并计算出保底数
local cfg_data = self.data.pool == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
local rule_cfg = stringtotable(cfg_data.rule)[1]
local color, num = tonumber(rule_cfg[1]), tonumber(rule_cfg[2])
local str = ""
for k, v in ipairs(self.data.show_awards) do
if v.color == color then
str = string.format("再抽 <color=%s>%s</color> 次必出橙色品质圣物", ColorUtil.GREEN_DARK, num - v.times)
break
end
end
self.draw_tip_tmp.text = str
end
end
----------------
-- 开始抽奖动画 --
----------------
function PsionicDrawResultView:StartDrawAnim( )
self:InitViewNodes()
self:UpdateBoxModel()
end
-- 初始化节点
function PsionicDrawResultView:InitViewNodes( )
-- 隐藏背景和标题
self.bg_obj:SetActive(false)
self.title_obj:SetActive(false)
-- self.light_con_obj:SetActive(false)
self:ClearUIEffect(self.light_con)
self.can_close_view = false
-- 清除模型
lua_resM:clearRoleMode(self)
-- 隐藏节点
self:ClearAwardItemCreator()
for k,v in pairs(self.item_list) do
v:SetVisible(false, nil, true)
end
-- 隐藏按钮
self.btn_con_cg.alpha = 0
self.btn_con_cg.blocksRaycasts = false
-- 显示跳过按钮
self.skip_btn_obj:SetActive(true)
end
-- 创建宝箱模型
function PsionicDrawResultView:UpdateBoxModel( )
-- 容错处理,防止模型加载不出来导致后面的表现看不见
self:DelayShowRewardAnim(4)
local data = {
father_node = self,
transform = self.box_con,
layer_name = self.layer_name,
fashion_type = FuncOpenModel.TypeId.OtherGoods,
figure_id = PsionicConst.DrawShowModel[self.data.pool],
scale = 255 * 1.4,
can_rotate = false,
action_name_list = {"show"},
position = Vector3(0, -120, -1000),
rotate = Vector3(0, 0, 0),
ui_model_type = UIModelCommon.ModelType.Model,
callBack = function()
-- 模型加载出来之后,停止容错的倒计时,使用模型回调产生的倒计时
self:DelayShowRewardAnim(2.5)
end,
}
FuncOpenModel:getInstance():SetModelRes(data)
end
-- 延迟展示奖励和按钮等的表现
function PsionicDrawResultView:DelayShowRewardAnim(delay_time)
self:ClearShowRewardDelayId()
self.is_animating = true
local function delay_show_reward_func( )
lua_resM:clearRoleMode(self)
-- 取消隐藏背景和标题
self.bg_obj:SetActive(true)
self.title_obj:SetActive(true)
-- self.light_con_obj:SetActive(true)
self:AddUIEffect("ui_jihuoxinxitong01", self.light_con, self.layer_name, nil, 1.2, true,nil,nil, nil, nil,nil)
-- 加载奖励内容
self:UpdateItemList()
-- 延时x秒显示按钮
self:DelayShowBtnCon(0.5)
-- 隐藏跳过按钮
self.skip_btn_obj:SetActive(false)
end
self.delay_show_reward_id = setTimeout(delay_show_reward_func, delay_time)
end
function PsionicDrawResultView:DelayShowBtnCon(delay_time)
self:ClearShowBtnConId()
local function delay_show_btn_con_func( )
local function btn_con_alpha_anim_callback()
self.is_animating = false
end
self.btn_con_alpha_id = TweenLite.to(self, self.btn_con, TweenLite.UiAnimationType.ALPHA_ALL, 1, 0.3, btn_con_alpha_anim_callback)
self.btn_con_cg.blocksRaycasts = true
end
self.delay_show_btn_con_id = setTimeout(delay_show_btn_con_func, delay_time)
-- 到了展示按钮的时候就可以关闭界面了
self.can_close_view = true
end
function PsionicDrawResultView:ClearShowRewardDelayId( )
if self.delay_show_reward_id then
GlobalTimerQuest:CancelQuest(self.delay_show_reward_id)
self.delay_show_reward_id = nil
end
end
function PsionicDrawResultView:ClearShowBtnConId( )
if self.delay_show_btn_con_id then
GlobalTimerQuest:CancelQuest(self.delay_show_btn_con_id)
self.delay_show_btn_con_id = nil
end
if self.btn_con_alpha_id then
TweenLite.Stop(self.btn_con_alpha_id)
self.btn_con_alpha_id = nil
end
end
-- 跳过所有动画
function PsionicDrawResultView:SkipAllAnim( )
self.skip_btn_obj:SetActive(false)
self.is_animating = false
self.can_close_view = true
lua_resM:clearRoleMode(self)
-- 取消隐藏背景和标题
self.bg_obj:SetActive(true)
self.title_obj:SetActive(true)
self:AddUIEffect("ui_jihuoxinxitong01", self.light_con, self.layer_name, nil, 1.2, true,nil,nil, nil, nil,nil)
-- 加载奖励内容
self:UpdateItemList(true)
self:ClearShowRewardDelayId()
self:ClearShowBtnConId()
self.btn_con_cg.blocksRaycasts = true
self.btn_con_cg.alpha = 1
end
----------------
----------------
function PsionicDrawResultView:UpdateItemList(skip_anim)
for k,v in pairs(self.item_list) do
v:SetVisible(false, nil, true)
end
self.col_num = self.data.col_num or self.col_num
local item_list = self.data.award
if not item_list or TableSize(item_list) == 0 then return end
local len = #item_list
local i = 0
local x, y, v, grade_cfg
local function frame_count_creator()
-- 累加迭代
i = i + 1
if len >= i then
v = item_list[i]
local item = self.item_list[i]
if item == nil then
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.award_con)
item:SetItemSize(78, 78)
self.item_list[i] = item
end
if len == 1 then
local con_size = self.award_con.sizeDelta
item:SetAnchoredPosition(261, -76)
else
x = (78 + 49) * ((i - 1) % 5) + 7
y = -(78 + 35) * math.floor((i - 1) / 5) - 20.5
item:SetAnchoredPosition(x, y)
end
item:SetGoodsVo(v[4])
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(true, nil, true)
else
self:ClearAwardItemCreator()
end
end
self.award_creator_id = GlobalTimerQuest:AddPeriodQuest(frame_count_creator, skip_anim and 0 or 0.1)
end
function PsionicDrawResultView:ClearAwardItemCreator( )
if self.award_creator_id then
GlobalTimerQuest:CancelQuest(self.award_creator_id)
self.award_creator_id = nil
end
end
-- 抽奖按钮点击逻辑 pool_type:奖池类型 opty:次数类型
-- 消耗顺序:免费次数(单抽)> 单抽/十连券 > 红钻/彩钻
function PsionicDrawResultView:OnDrawBtnClick(opty)
if not self.data then return end
local pool_type = self.data.pool
local cost_data = self.cost_cache[pool_type][opty]
if not cost_data then return end
local price_asset, price_icon, price_color
local price_type, cost_price
local priceText = ""
local insufficientText = nil
local special_icon_data = nil
local cfg_data = pool_type == PsionicConst.DrawPoolType.Normal and self.normal_cfg or self.deep_cfg
local function ok_callback()
self.model:Fire(PsionicConst.REQUEST_CCMD_EVENT, 13911, pool_type, opty)
end
if cost_data.free then -- 免费抽,直接冲
ok_callback()
return
end
local cost_goods_name = self.goods_model:getGoodsName(cfg_data.one, true)
-- 使用抽奖券的情况,提示后直接使用
if cost_data.goods_id then
special_icon_data = true
price_asset = "psionic_asset"
price_icon = "psionic_dig_icon" .. pool_type .. "_" .. opty
price_type = 0
if cost_data.goods_id == cfg_data.one then -- 单抽券需要区分抽奖次数,十连券每次消耗1张
cost_price = opty == PsionicConst.DrawNumType.TenDraw and 9 or 1
else
cost_price = 1
end
price_color = self.goods_model:GetGoodsColor(cost_data.goods_id)
priceText = string.format("<color=%s>%s</color> %s %s寻宝%s次?", price_color, cost_price, cost_goods_name,
pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
else -- 需要使用钻石补足的情况
price_type = cost_data.price_type
cost_price = cost_data.cost
price_asset, price_icon = WordManager:GetCommonMoneyIcon(price_type)
-- price_color = WordManager.GetGoodsColor(pool_type == PsionicConst.DrawPoolType.Deep and 4 or 3)
price_color = ColorUtil.YELLOW_DARK
if pool_type == PsionicConst.DrawPoolType.Deep then -- 统一用抽奖券表现
insufficientText = string.format("%s 不足", cost_goods_name)
priceText = string.format("<color=%s>%s</color> 补齐 %s %s寻宝%s次?", price_color, cost_price, cost_goods_name,
pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
else
priceText = string.format("<color=%s>%s</color> %s寻宝%s次?", price_color, cost_price,
pool_type == PsionicConst.DrawPoolType.Deep and "深度" or "普通",
opty == PsionicConst.DrawNumType.TenDraw and 10 or 1)
end
end
local function use_function( toggle_tip_data, call_fun_sum )
if not self.model._dont_check_psionic_draw_tip[pool_type] then
GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
else
call_fun_sum()
end
end
local data = {
insufficientText = insufficientText,
special_icon_data = special_icon_data,
gold_type = price_type,
cost_price = cost_price,
ok_callback = ok_callback,
togglePriceStr = priceText,
use_function = use_function,
toggle_function = function(flag)
self.model._dont_check_psionic_draw_tip[pool_type] = flag
end,
recharge_open_call_back = function()
self:Close()
end,
}
CustomActivityModel:getInstance():BuyTips(data)
end
function PsionicDrawResultView:DestroySuccess( )
self:ClearShowRewardDelayId()
self:ClearShowBtnConId()
self:ClearAwardItemCreator()
lua_resM:clearRoleMode(self)
self:ClearUIEffect(self.light_con)
for i,item in pairs(self.item_list) do
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, item)
end
self.item_list = {}
ItemUseModel:getInstance():ShowItemUseView( )
end