|
-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 经验快车挂机奖励领取界面
|
|
-- *>
|
|
ExpHangUpReceiveView = ExpHangUpReceiveView or BaseClass(BaseView)
|
|
local ExpHangUpReceiveView = ExpHangUpReceiveView
|
|
local Config_Exp = Config.Exp
|
|
|
|
function ExpHangUpReceiveView:__init()
|
|
self.base_file = "expDun"
|
|
self.layout_file = "ExpHangUpReceiveView"
|
|
self.layer_name = "Top"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.change_scene_close = true
|
|
self.is_set_zdepth = true
|
|
self.open_guide_close = true
|
|
self.last_time = nil -- 上次领取放置挂机的时间(只拿一次)
|
|
self.main_role = RoleManager.Instance.mainRoleInfo
|
|
self.can_click_receive_btn = true
|
|
-- 只拿打开界面时的经验值
|
|
self.cur_lv = self.main_role.level
|
|
self.cur_exp = self.main_role.exp
|
|
self.total_lv = TableSize(Config_Exp)
|
|
self.model = ExpDunModel:getInstance()
|
|
self.dun_model = BaseDungeonModel:getInstance()
|
|
-- 查询放置挂机奖励内容
|
|
-- self.dun_model:Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61050, 0, 0)
|
|
|
|
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 ExpHangUpReceiveView:Open(reward_list)
|
|
self.reward_list = reward_list
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function ExpHangUpReceiveView:LoadSuccess()
|
|
local nodes = {
|
|
"window:raw", "close_btn:obj",
|
|
-- 领取按钮
|
|
"receive_btn:obj:img", "receive_btn/receive_btn_red:obj",
|
|
-- 奖励滚动容器
|
|
"reward_scroll", "reward_scroll/Viewport/reward_con",
|
|
-- 奖励预览滚动容器
|
|
"pre_reward_scroll", "pre_reward_scroll/Viewport/pre_reward_con",
|
|
-- 挂机相关数值ui
|
|
"hang_time:tmp", "dun_lv:tmp", "cur_efficient:tmp",
|
|
-- 经远表现相关节点
|
|
"expect_con",
|
|
"expect_con/expect_icon:img",
|
|
"expect_con/expect_lb1:tmp",
|
|
"expect_con/expect_lb2:tmp",
|
|
"expect_con/expect_lb3:tmp",
|
|
|
|
"fill_basic:obj:img",
|
|
"fill_basic/fill_add:img",
|
|
"fill_basic/fill_basic_end:obj",
|
|
|
|
-- 离线卡相关
|
|
"extra_time_btn:obj", "extra_time_btn/extra_time_btn_red:obj",
|
|
"extra_time:tmp",
|
|
"extra_time_con:obj", -- 离线道具使用界面
|
|
"extra_time_con/extra_mask:obj",
|
|
"extra_time_con/extra_itemcon",
|
|
"extra_time_con/extra_item_useBtn:obj:img", "extra_time_con/extra_item_useBtn/extra_item_useBtn_red:obj",
|
|
"extra_time_con/extra_item_getwayBtn:obj:img",
|
|
"extra_time_con/extra_item_num:tmp",
|
|
"extra_time_con/extra_item_name:tmp",
|
|
|
|
"received_tips:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
self.extra_item_useBtn_lb_tmp = self:GetChild("extra_time_con/extra_item_useBtn/Text"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
self.receive_btn_lb = self:GetChild("receive_btn/Text"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
-- 离线挂机加成卡相关
|
|
self.extra_awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.extra_itemcon)
|
|
self.extra_awardItem:SetAnchoredPosition(0, 0)
|
|
self.extra_awardItem:SetItemSize(62, 62)
|
|
self.extra_awardItem:SetVisible(true)
|
|
self.extra_awardItem:SetData(ExpDunModel.OfflineGoodsId)
|
|
|
|
self.extra_item_name_tmp.text = GoodsModel:getInstance():getGoodsName(ExpDunModel.OfflineGoodsId, true)
|
|
self.received_tips_tmp.color = ColorUtil:ConvertHexToRGBColor("a9c1e1")
|
|
self.received_tips_tmp.fontSize = 18
|
|
lua_resM:setOutsideRawImage(self, self.window_raw, GameResPath.GetViewBigBg("exp_hangup_receive_bg"))
|
|
end
|
|
|
|
function ExpHangUpReceiveView:AddEvent()
|
|
local function click_event(target, x, y)
|
|
if target == self.close_btn_obj then
|
|
self:Close()
|
|
elseif target == self.extra_mask_obj then -- 关闭离线时间效率提升道具使用界面
|
|
self.extra_time_con_obj:SetActive(false)
|
|
elseif target == self.extra_time_btn_obj then -- 弹出离线时间效率提升道具使用界面
|
|
local activeSelf = self.extra_time_con_obj.activeSelf
|
|
self.extra_time_con_obj:SetActive(not activeSelf)
|
|
elseif target == self.extra_item_useBtn_obj then -- 使用离线时间卡道具
|
|
self:OnExtraItemUseBtnClicked(x, y)
|
|
elseif target == self.extra_item_getwayBtn_obj then -- 使用离线时间效率提升道具
|
|
-- 弹出获取途径
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(ExpDunModel.OfflineGoodsId, x, y, nil, nil, nil, false, true)
|
|
elseif target == self.receive_btn_obj then
|
|
if self.can_click_receive_btn then
|
|
-- 领取奖励
|
|
self.dun_model:Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61050, 1, 0)
|
|
self:Close()
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.close_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
|
|
AddClickEvent(self.extra_mask_obj, click_event)
|
|
AddClickEvent(self.extra_time_btn_obj, click_event)
|
|
AddClickEvent(self.extra_item_useBtn_obj, click_event)
|
|
AddClickEvent(self.extra_item_getwayBtn_obj, click_event)
|
|
AddClickEvent(self.receive_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
|
|
|
|
-- 当挂机效率更新时刷新一次
|
|
local function on_update_hangup_ratio()
|
|
self:UpdateHangUpData()
|
|
end
|
|
self:BindEvent(self.model, ExpDunModel.UPDATE_HANGUP_RATIO, on_update_hangup_ratio)
|
|
local function on_update_hangup_data()
|
|
self:UpdateHangUpData(true)
|
|
end
|
|
self:BindEvent(self.model, ExpDunModel.UPDATE_HANGUP_RECEIVE_TIME, on_update_hangup_data)
|
|
|
|
-- 领取成功后,播放经验值动画
|
|
local function play_exp_action()
|
|
-- 改为直接关闭界面,不需要动画了
|
|
-- self:UpdateExpAction(true)
|
|
-- self:UpdateReward(false)
|
|
end
|
|
self:BindEvent(self.model, ExpDunModel.SHOW_HANGUP_ACTION, play_exp_action)
|
|
|
|
local function updata_buff_state(id)
|
|
if id == KfActivityModel.TabID.MaterialSubmit and self.is_loaded then
|
|
self:UpdateHangUpData()
|
|
end
|
|
end
|
|
self:BindEvent(KfActivityModel:getInstance(), KfActivityModel.ANS_UPDATE_VIEW, updata_buff_state)
|
|
|
|
local function update_offline_red(red_type)
|
|
if not red_type or red_type == ExpDunModel.Red_Type.Offline then
|
|
self:UpdateOfflineTimeData()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, ExpDunModel.UPDATE_EXP_RED_BY_REDTYPE, update_offline_red)
|
|
end
|
|
|
|
function ExpHangUpReceiveView:OpenSuccess()
|
|
self:UpdatePerRewardData()
|
|
self:UpdateHangUpData()
|
|
self:UpdateExpAction(false)
|
|
self:UpdateExpWithoutRewardList()
|
|
self:UpdateReward(true)
|
|
self:UpdateOfflineTimeData()
|
|
-- 加载完之后,尝试更新协议过来的缓存
|
|
-- self.model:UpdateHangUpCache()
|
|
end
|
|
|
|
-- 加载预览的奖励内容
|
|
function ExpHangUpReceiveView:UpdatePerRewardData( )
|
|
local data = stringtotable(self.model:GetExpDunConfig("show_rewards").value)
|
|
self.pre_reward_item_creator = self.pre_reward_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = data,
|
|
item_con = self.pre_reward_con,
|
|
scroll_view = self.pre_reward_scroll,
|
|
obj_pool_type = UIObjPool.UIType.AwardItem,
|
|
item_width = 62,
|
|
start_x = 3.5,
|
|
start_y = -3,
|
|
space_x = 8,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
on_update_item = function(item, i, v)
|
|
local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
|
|
item:SetData(goods_Id, v[3] , nil, nil, lock)
|
|
item:SetItemSize(62, 62)
|
|
end,
|
|
}
|
|
self.pre_reward_item_creator:UpdateItems(info)
|
|
end
|
|
|
|
function ExpHangUpReceiveView:UpdateHangUpData(refresh)
|
|
-- 创建挂机时间计时器
|
|
if refresh then
|
|
self.last_time = self.model:GetHangUpReceiveTime()
|
|
else
|
|
self.last_time = self.last_time or self.model:GetHangUpReceiveTime()
|
|
end
|
|
local time_max = self.model:GetHangupResourceLimitTime()
|
|
local contain_time = self.model:GetHangUpContainTimeData()
|
|
-- local pass_time = TimeUtil:getServerTime() - self.last_time
|
|
local time_str = ""
|
|
if self.last_time > 0 then
|
|
time_str = string.format("挂机时间:<color=#2cf86f>%s</color>",
|
|
contain_time < time_max * 3600 and TimeUtil:convertTime(contain_time) or ("已满".. time_max .. "小时"))
|
|
else
|
|
time_str = "挂机时间:<color=#2cf86f>00:00:00</color>"
|
|
end
|
|
|
|
self.hang_time_tmp.text = time_str
|
|
|
|
-- 设置关卡信息
|
|
local wave = self.model:GetCurrentWave()
|
|
self.dun_lv_tmp.text = string.format("关卡:<color=#2cf86f>%s</color>", self.model:GetWaveStr(wave))
|
|
-- 设置经验值
|
|
if self.reward_list then
|
|
-- 通过最终奖励中的内容筛选出经验值数据
|
|
local normal_exp = 0 -- 挂机经验 离线挂机经验
|
|
for k, v in ipairs(self.reward_list) do
|
|
-- if v.sp_type == 1 then -- 挂机经验
|
|
if v.goods_id == 100007 or v.goods_type == 5 then
|
|
normal_exp = normal_exp + v.num
|
|
end
|
|
end
|
|
-- 设置挂机效率信息 万分数,需除以100转化为百分数
|
|
local ratio = self.model:GetExpHangUpRatio()
|
|
|
|
local buff_kind = OperateActivityModel.MaterialSubmitBuffKind.ADVENTURE_EXP_UP--触发加成后,玩家每分钟放置冒险经验收益提升100%(增对初始数值计算)
|
|
local buff_cfg,buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(buff_kind)
|
|
local buff_str = ""
|
|
-- buff_info = {etime = TimeUtil:getServerTime( )+300}
|
|
-- buff_cfg = {data = 100}
|
|
if buff_cfg and buff_info then
|
|
local sec = buff_info.etime - TimeUtil:getServerTime( )
|
|
if sec > 0 then
|
|
self:ActBuffTimeLate(sec)
|
|
buff_str = "+"..buff_cfg.data.."%活动"
|
|
end
|
|
end
|
|
local has_ratio_str = ratio == 10000 and "" or string.format("(+%s%s)", (ratio / 100) .. "%",buff_str)
|
|
|
|
self.cur_efficient_tmp.text = string.format("经验收益:<color=#2cf86f>%s%s</color>",
|
|
WordManager:ConvertNum1(normal_exp, true),
|
|
has_ratio_str)
|
|
else
|
|
self.cur_efficient_tmp.text = "经验收益:<color=#2cf86f>未满1小时</color>"
|
|
end
|
|
end
|
|
|
|
--活动BUFF时间倒计时
|
|
function ExpHangUpReceiveView: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:UpdateHangUpData()
|
|
end
|
|
end
|
|
if not self.act_buff_timer_id then
|
|
self.act_buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
|
|
end
|
|
onTimer()
|
|
else
|
|
self:UpdateHangUpData()
|
|
end
|
|
end
|
|
end
|
|
|
|
function ExpHangUpReceiveView:UpdateExpAction(show_anim)
|
|
if not self.reward_list then return end
|
|
local cur_lv = self.cur_lv
|
|
local cur_exp = self.cur_exp
|
|
local cur_percentage = cur_exp / Config_Exp[cur_lv].exp
|
|
local target_percentage = 0
|
|
-- self.expect_lb2_tmp.text = string.format("%s(%.2f%%)", cur_lv, cur_percentage * 100)
|
|
self.expect_lb1_tmp.text = show_anim and "等级提升了:" or "预计等级提升:"
|
|
self.expect_lb2_tmp.text = show_anim and "" or string.format("%s", cur_lv)
|
|
-- 计算本次领取能拿到多少经验
|
|
local add_exp = 0
|
|
for k, v in ipairs(self.reward_list) do
|
|
if v.goods_id == 100007 or v.goods_type == 5 then -- 经验值
|
|
add_exp = add_exp + v.num
|
|
end
|
|
end
|
|
-- 递归计算能升多少级
|
|
local add_lv = 0
|
|
local function cul_addlv_and_percentage()
|
|
local added_exp = cur_exp + add_exp
|
|
if Config_Exp[cur_lv + add_lv] and added_exp > Config_Exp[cur_lv + add_lv].exp then
|
|
target_percentage = target_percentage + 1
|
|
add_exp = added_exp - Config_Exp[cur_lv + add_lv].exp
|
|
add_lv = add_lv + 1
|
|
cur_exp = 0
|
|
cul_addlv_and_percentage()
|
|
else
|
|
cur_exp = added_exp
|
|
-- 等级容错
|
|
local _lv = cur_lv + add_lv <= self.total_lv and cur_lv + add_lv or self.total_lv
|
|
local last_percentage = cur_exp / Config_Exp[_lv].exp
|
|
target_percentage = target_percentage + last_percentage
|
|
end
|
|
end
|
|
cul_addlv_and_percentage()
|
|
-- self.expect_lb3_tmp.text = string.format("%s(%.2f%%)",
|
|
-- cur_lv + add_lv,
|
|
-- cur_exp / Config_Exp[cur_lv + add_lv].exp * 100)
|
|
self.expect_lb3_tmp.text = string.format("%s", cur_lv + add_lv)
|
|
-- 先对齐文本节点
|
|
self.expect_icon_img.enabled = not show_anim
|
|
local len1 = self.expect_lb1_tmp.preferredWidth
|
|
local len2 = self.expect_lb2_tmp.preferredWidth + 20
|
|
local len3 = show_anim and 0 or (self.expect_icon.sizeDelta.x + 20)
|
|
local len4 = self.expect_lb3_tmp.preferredWidth
|
|
local offset_x = (self.expect_con.sizeDelta.x - len1 - len2 - len3 - len4 ) / 2
|
|
SetAnchoredPositionX(self.expect_lb1, offset_x)
|
|
SetAnchoredPositionX(self.expect_lb2, self.expect_lb1.anchoredPosition.x + len1)
|
|
SetAnchoredPositionX(self.expect_icon, self.expect_lb2.anchoredPosition.x + len2)
|
|
SetAnchoredPositionX(self.expect_lb3, self.expect_icon.anchoredPosition.x + len3)
|
|
-- 初始节点填充
|
|
local max_len = self.fill_basic.sizeDelta.x
|
|
self.fill_basic_img.fillAmount = cur_percentage
|
|
self.fill_basic_end_obj:SetActive(true)
|
|
SetAnchoredPositionX(self.fill_basic_end, max_len * cur_percentage - self.fill_basic_end.sizeDelta.x)
|
|
SetAnchoredPositionX(self.fill_add, max_len * cur_percentage)
|
|
-- 创建动画
|
|
local add_percentage = target_percentage - cur_percentage
|
|
if show_anim then -- 播放经验值条的动画
|
|
SetSizeDeltaX(self.fill_add, 0)
|
|
if add_percentage > 0 then
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.fill_add)
|
|
local function action_percentage_func(percent)
|
|
percent = percent - 1.0
|
|
local real_pec = percent * percent * percent * percent * percent + 1
|
|
local final_percentage = cur_percentage + add_percentage * real_pec
|
|
if final_percentage < 1 then
|
|
SetSizeDeltaX(self.fill_add, (final_percentage - cur_percentage) * max_len)
|
|
else
|
|
-- 如果进度条大于0了,则去掉整数部分,将原来的进度条进度置0
|
|
local _, minus_part = math.modf(final_percentage);
|
|
self.fill_basic_img.fillAmount = 0
|
|
SetAnchoredPositionX(self.fill_add, 0)
|
|
SetSizeDeltaX(self.fill_add, minus_part * max_len)
|
|
if self.fill_basic_end_obj.activeSelf then
|
|
self.fill_basic_end_obj:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
local action_percentage = cc.CustomUpdate.New(2, action_percentage_func)
|
|
cc.ActionManager:getInstance():addAction(action_percentage, self.fill_add)
|
|
end
|
|
else -- 根据实际经验塞满进度条,满了不溢出
|
|
local final_percentage = cur_percentage + add_percentage
|
|
final_percentage = final_percentage > 1 and 1 or final_percentage
|
|
SetSizeDeltaX(self.fill_add, (final_percentage - cur_percentage) * max_len)
|
|
end
|
|
|
|
-- 如果是主动领取播放动画,则需要强行把按钮置灰
|
|
if show_anim then
|
|
SetButtonGray(self.receive_btn_img, nil, true)
|
|
SetTMPSharedMaterial(self.receive_btn_lb, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
|
|
self.can_click_receive_btn = false
|
|
self.receive_btn_red_obj:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function ExpHangUpReceiveView:UpdateExpWithoutRewardList( )
|
|
if self.reward_list then return end
|
|
local cur_lv = self.cur_lv
|
|
local cur_exp = self.cur_exp
|
|
local cur_percentage = cur_exp / Config_Exp[cur_lv].exp
|
|
local target_percentage = 0
|
|
-- self.expect_lb2_tmp.text = string.format("%s(%.2f%%)", cur_lv, cur_percentage * 100)
|
|
self.expect_lb1_tmp.text = "当前等级:"
|
|
self.expect_lb2_tmp.text = string.format("%s", cur_lv)
|
|
self.expect_lb3_tmp.text = “
|
|
-- 先对齐文本节点
|
|
self.expect_icon_img.enabled = false
|
|
local len1 = self.expect_lb1_tmp.preferredWidth
|
|
local len2 = self.expect_lb2_tmp.preferredWidth + 20
|
|
local len3 = 0
|
|
local len4 = self.expect_lb3_tmp.preferredWidth
|
|
local offset_x = (self.expect_con.sizeDelta.x - len1 - len2 - len3 - len4 ) / 2
|
|
SetAnchoredPositionX(self.expect_lb1, offset_x)
|
|
SetAnchoredPositionX(self.expect_lb2, self.expect_lb1.anchoredPosition.x + len1)
|
|
SetAnchoredPositionX(self.expect_icon, self.expect_lb2.anchoredPosition.x + len2)
|
|
SetAnchoredPositionX(self.expect_lb3, self.expect_icon.anchoredPosition.x + len3)
|
|
-- 初始节点填充
|
|
self.fill_basic_img.fillAmount = cur_percentage
|
|
self.fill_basic_end_obj:SetActive(false)
|
|
SetAnchoredPositionX(self.fill_add, 0)
|
|
SetSizeDeltaX(self.fill_add, 0)
|
|
-- 置灰领取按钮
|
|
SetButtonGray(self.receive_btn_img, nil, true)
|
|
SetTMPSharedMaterial(self.receive_btn_lb, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
|
|
self.can_click_receive_btn = false
|
|
self.receive_btn_red_obj:SetActive(false)
|
|
end
|
|
|
|
function ExpHangUpReceiveView:UpdateReward(show_rewards)
|
|
if self.reward_list then
|
|
self.reward_item_creator = self.reward_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = show_rewards and self.reward_list or {},
|
|
item_con = self.reward_con,
|
|
scroll_view = self.reward_scroll,
|
|
item_class = ExpHangupAwardItem,
|
|
item_width = 78,
|
|
item_height = 78,
|
|
start_x = 5,
|
|
start_y = -4,
|
|
space_x = 30,
|
|
space_y = 8,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
on_update_item = function(item, i, v)
|
|
item:SetData(v)
|
|
end,
|
|
}
|
|
self.reward_item_creator:UpdateItems(info)
|
|
self.received_tips_tmp.text = show_rewards and "" or "奖励已领,待会再来吧~"
|
|
else
|
|
self.received_tips_tmp.text = "累计时间满1小时后即可领取奖励"
|
|
end
|
|
end
|
|
|
|
-- 更新离线时间加成的相关信息
|
|
function ExpHangUpReceiveView:UpdateOfflineTimeData( )
|
|
local offline_exp, rest_offline_time = self.model:GetHangUpOfflineData()
|
|
local time_limit = self.model:GetExpDunConfig("time_limit").value
|
|
self.extra_time_tmp.text = string.format("剩余离线挂机时间:<color=%s>%s小时</color>/<color=#fdffc2>%s小时</color>",
|
|
rest_offline_time > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, math.ceil(rest_offline_time / 3600),
|
|
math.ceil(time_limit / 3600))
|
|
SetAnchoredPositionX(self.extra_time_btn, -74.5 + self.extra_time_tmp.preferredWidth + 30)
|
|
local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(ExpDunModel.OfflineGoodsId)
|
|
self.extra_item_num_tmp.text = string.format("当前拥有:<color=%s>%s</color>",
|
|
goods_num > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, goods_num)
|
|
-- 顺带更新红点表现
|
|
local offline_red = self.model:GetExpRedByRedType(ExpDunModel.Red_Type.Offline)
|
|
self.extra_time_btn_red_obj:SetActive(offline_red)
|
|
self.extra_item_useBtn_red_obj:SetActive(offline_red)
|
|
-- 根据剩余时间和道具数量更新使用道具按钮显示和灰化情况
|
|
self.extra_item_getwayBtn_obj:SetActive(goods_num <= 0) -- 获取途径按钮
|
|
self.extra_item_useBtn_obj:SetActive(goods_num > 0) -- 使用按钮
|
|
if goods_num > 0 then
|
|
local btn_gray = time_limit - rest_offline_time < 3600
|
|
SetImageGray(self.extra_item_useBtn_img, btn_gray)
|
|
SetTMPSharedMaterial(self.extra_item_useBtn_lb_tmp, btn_gray
|
|
and ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn
|
|
or ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
|
|
end
|
|
-- 需要默认打开离线挂机节点
|
|
if self.need_show_offline_con then
|
|
self.extra_time_con_obj:SetActive(true)
|
|
self.need_show_offline_con = false
|
|
end
|
|
end
|
|
|
|
-- 点击离线加成道具使用按钮回调
|
|
function ExpHangUpReceiveView:OnExtraItemUseBtnClicked(x, y)
|
|
local goods_id = ExpDunModel.OfflineGoodsId
|
|
local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(goods_id)
|
|
if goods_num > 0 then
|
|
local offline_exp, rest_offline_time = self.model:GetHangUpOfflineData()
|
|
local callback = function()
|
|
local goods_list = GoodsModel:getInstance():GetTypeGoods(goods_id)
|
|
if TableSize(goods_list) > 0 then
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT, 15050, goods_list[1].goods_id, goods_list[1].type_id, 1)
|
|
end
|
|
end
|
|
local time_limit = self.model:GetExpDunConfig("time_limit").value
|
|
if time_limit - rest_offline_time < 3600 then -- 时间基本满了,不给充能
|
|
Message.show("时间已满,无需使用", "fault")
|
|
elseif time_limit - rest_offline_time >= 3600 and time_limit - rest_offline_time < 7200 then -- 充一次会溢出,二次确认
|
|
local ask_str = "使用后,部分时间将溢出。\n是否使用?"
|
|
Alert.show(ask_str, Alert.Type.Two, callback, nil, "确定", "取消")
|
|
else
|
|
callback()
|
|
end
|
|
else
|
|
-- 弹出获取途径
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(goods_id, x, y, nil, nil, nil, false, true)
|
|
end
|
|
end
|
|
|
|
function ExpHangUpReceiveView:DestroySuccess( )
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.fill_add)
|
|
self.model:ClearHangupLoginCallbackId()
|
|
if self.act_buff_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.act_buff_timer_id)
|
|
self.act_buff_timer_id = nil
|
|
end
|
|
if self.extra_awardItem then
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.extra_awardItem)
|
|
self.extra_awardItem = nil
|
|
end
|
|
end
|