|
-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 社团拼单结算界面
|
|
-- *>
|
|
GuildSpellListRewardView = GuildSpellListRewardView or BaseClass(BaseView)
|
|
local GuildSpellListRewardView = GuildSpellListRewardView
|
|
|
|
function GuildSpellListRewardView:__init()
|
|
self.base_file = "guild"
|
|
self.layout_file = "GuildSpellListRewardView"
|
|
self.layer_name = "Activity"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.change_scene_close = true
|
|
self.click_bg_toClose = true
|
|
self.blur_activity_bg = true
|
|
self.use_show_anim = true
|
|
self.use_hide_anim = true
|
|
self.award_list = {}
|
|
self.auto_close_time = 20
|
|
self.model = GuildModel: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 GuildSpellListRewardView:Open(result_data)
|
|
self.result_data = result_data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function GuildSpellListRewardView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:raw",
|
|
"reward_scroll",
|
|
"reward_scroll/Viewport/reward_con",
|
|
"mem_num:tmp", "sl_type:tmp", "profit_pec:tmp", "close_timer:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("guild_sl_reward_bg"))
|
|
end
|
|
|
|
function GuildSpellListRewardView:AddEvent()
|
|
|
|
end
|
|
|
|
function GuildSpellListRewardView:UpdateView()
|
|
local sl_cfg = Config.Guildorder[self.result_data.cfg]
|
|
self.mem_num_tmp.text = string.format("%s人",self.result_data.num)
|
|
self.sl_type_tmp.text = string.format("<color=%s>%s</color>", GuildModel.SpellListColor[sl_cfg.color], Trim(sl_cfg.name))
|
|
-- 拼单收益率
|
|
local sl_data = self.model:GetCurSelectedSpellListData()
|
|
local role_id = RoleManager.Instance.mainRoleInfo.role_id
|
|
local base_reward = self.model:GetGuildKvByKey("base_reward")
|
|
|
|
local buff_kind = OperateActivityModel.MaterialSubmitBuffKind.GUILD_SPORT --触发加成后,玩家赏金幻魔/专属幻魔掉落概率+100%
|
|
local buff_cfg,buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(buff_kind)
|
|
-- buff_info = {etime = TimeUtil:getServerTime( )+300,used = {{kdata=1,vdata = 0}}}
|
|
-- buff_cfg = {data = 100}
|
|
local have_base_act_ridio = 0--是否有活动基础加成 一个加一倍
|
|
if buff_cfg and buff_info then
|
|
local sec = buff_info.etime - TimeUtil:getServerTime( )
|
|
if sec > 0 then
|
|
have_base_act_ridio = buff_cfg.data
|
|
end
|
|
end
|
|
|
|
self.profit_ratio = base_reward and base_reward.val or 0 -- 基础收益率
|
|
local role_num = 0
|
|
if sl_data then
|
|
sl_data.teams = sl_data.teams or {}
|
|
for k, v in pairs(sl_data.teams) do
|
|
if v.role_id ~= role_id then
|
|
|
|
--宠物生活技能 拼单邀请社团助手时额外增加收益
|
|
local ai_ratio = sl_cfg.ai_ratio
|
|
local life_skill_active = PetModel:getInstance():IsLifeSkillActived(PetConst.LifeSkill.GuildSpellAssitRewardUp)
|
|
local life_skill_ratio = PetModel:getInstance():GetPetLifeSkillRatio(PetConst.LifeSkill.GuildSpellAssitRewardUp)
|
|
if life_skill_active then
|
|
ai_ratio = ai_ratio + life_skill_ratio
|
|
end
|
|
|
|
self.profit_ratio = self.profit_ratio + (v.role_id < 10 and ai_ratio or sl_cfg.people_ratio)
|
|
role_num = role_num + 1
|
|
end
|
|
end
|
|
end
|
|
local buff_str = have_base_act_ridio>0 and string.format("<color=%s>(+%s%%)</color>",ColorUtil.YELLOW_DARK,have_base_act_ridio*role_num) or ""
|
|
self.have_base_act_ridio = have_base_act_ridio*role_num
|
|
self.profit_pec_tmp.text = string.format("<color=%s>%s%%</color>%s", ColorUtil.GREEN_DARK, self.profit_ratio, buff_str)
|
|
|
|
self:UpdateRewards(stringtotable(sl_cfg.awards), self.award_list, self.reward_scroll, self.reward_con)
|
|
self:StartAutoCloseTimer()
|
|
end
|
|
|
|
-- 加载奖励 data:数据 list:节点列表 scrollRect:滚动容器 node:滚动容器内的content
|
|
function GuildSpellListRewardView:UpdateRewards(data, list, scrollRect, node)
|
|
if not list or not scrollRect or not node then return end
|
|
data = data or {}
|
|
-- 隐藏多余的奖励item
|
|
for k, v in ipairs(list) do
|
|
v:SetVisible(false)
|
|
end
|
|
local count = #data
|
|
local offer_x = 8
|
|
for k, v in ipairs(data) do
|
|
list[k] = list[k] or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, node)
|
|
|
|
list[k]:SetPosition((78+offer_x)*(k - 1), -2)
|
|
list[k]:SetItemSize(78, 78)
|
|
list[k]:SetVisible(true)
|
|
local typeId, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
|
|
print("huangcong:GuildSpellListRewardView [start:121] :", self.profit_ratio,self.have_base_act_ridio)
|
|
list[k]:SetData(typeId, math.floor(v[3] * (self.profit_ratio + self.have_base_act_ridio) * 0.01), nil, nil, lock)
|
|
end
|
|
node.sizeDelta = Vector2((78+offer_x) * count, 88)
|
|
-- 做居中效果判断
|
|
local sum_x = (78+offer_x) * count
|
|
local size_x = scrollRect.sizeDelta.x
|
|
if sum_x < size_x then
|
|
local offset_x = (size_x - sum_x)/2
|
|
for i=1, TableSize(list) do
|
|
local pos = list[i]:GetAnchoredPosition()
|
|
list[i]:SetAnchoredPosition(pos.x + offset_x, pos.y)
|
|
end
|
|
end
|
|
-- 如果奖励没有超框,则不给滚动,空表也可以避免横向滚动
|
|
scrollRect:GetComponent(typeof(UnityEngine.UI.ScrollRect)).enabled = sum_x >= size_x
|
|
end
|
|
|
|
function GuildSpellListRewardView:StartAutoCloseTimer( )
|
|
local end_time = TimeUtil:getServerTime() + self.auto_close_time
|
|
self:CleanAutoCloseTimer()
|
|
local function autoCloseFunc()
|
|
local left_time = end_time - TimeUtil:getServerTime()
|
|
if left_time > 0 then
|
|
self.close_timer_tmp.text = string.format("<color=%s>%s</color>秒后自动关闭", ColorUtil.GREEN_DARK, left_time)
|
|
else
|
|
self:Close()
|
|
end
|
|
end
|
|
self.auto_close_func_id = GlobalTimerQuest:AddPeriodQuest(autoCloseFunc, 0.5, -1)
|
|
autoCloseFunc()
|
|
end
|
|
|
|
function GuildSpellListRewardView:CleanAutoCloseTimer( )
|
|
if self.auto_close_func_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_close_func_id)
|
|
self.auto_close_func_id = nil
|
|
end
|
|
end
|
|
|
|
function GuildSpellListRewardView:DestroySuccess( )
|
|
for k, v in pairs(self.award_list) do
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
|
|
v = nil
|
|
end
|
|
self.award_list = nil
|
|
self:CleanAutoCloseTimer()
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40068) -- 关闭界面时统一请求一次最新的协助信息
|
|
-- self.model:OpenGuildSLThankView(self.result_data.order)
|
|
end
|