|
EscortResultView = EscortResultView or BaseClass(BaseView)
|
|
local EscortResultView = EscortResultView
|
|
|
|
function EscortResultView:__init()
|
|
self.base_file = "escort"
|
|
self.layout_file = "EscortResultView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true --全屏界面默认使用这个参数
|
|
--self.hide_maincancas = true --全屏界面需要放开隐藏主UI
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.click_bg_toClose = true
|
|
|
|
self.model = EscortModel:getInstance()
|
|
self.left_time = 10
|
|
self.escort_reward_item = {}
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.switch_callback = function(index)
|
|
self:SwitchTab(index)
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function EscortResultView:Open(data)
|
|
self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function EscortResultView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:raw","bg2:raw","title:raw","reward_con", "tip_text:tmp", "time_text:tmp", "type_text:tmp",
|
|
"ok_btn:obj", "cancel_btn:obj","bg3:raw",
|
|
}
|
|
self:GetChildren(nodes)
|
|
end
|
|
|
|
function EscortResultView:AddEvent()
|
|
local function on_click( target )
|
|
if target == self.ok_btn_obj then
|
|
if self.can_continue then
|
|
self:ClickBtn()
|
|
else
|
|
self.model:FlyToNpc()
|
|
self:Close()
|
|
end
|
|
elseif target == self.cancel_btn_obj then
|
|
if self.can_continue then
|
|
else
|
|
self.model:FlyToNpc()
|
|
end
|
|
self:Close()
|
|
end
|
|
end
|
|
AddClickEvent(self.ok_btn_obj, on_click)
|
|
AddClickEvent(self.cancel_btn_obj, on_click)
|
|
end
|
|
|
|
function EscortResultView:OpenSuccess()
|
|
self:UpdateView()
|
|
self:UpdateLeftTime()
|
|
end
|
|
|
|
function EscortResultView:UpdateView()
|
|
if self.data.result == 1 then
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_1124_549"), false)
|
|
lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetEscortImage("escort_result_type1"), true)
|
|
lua_resM:setOutsideRawImage(self, self.title_raw, GameResPath.GetEscortImage("escort_win"), true)
|
|
lua_resM:setOutsideRawImage(self, self.bg3_raw, GameResPath.GetDungeonImage("dun_result_win_bg1"), true)
|
|
self.type_text_tmp.text = string.format("完美外送获得%s", HtmlColorTxt("完美奖励", "#fdffc2"))
|
|
SetTMPSharedMaterial(self.type_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeTitle)
|
|
else
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_lose_1124_549"), false)
|
|
lua_resM:setOutsideRawImage(self, self.bg3_raw, GameResPath.GetDungeonImage("dun_result_default_bg1"), true)
|
|
lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetEscortImage("escort_result_type3"), true)
|
|
self.type_text_tmp.text = string.format("超时外送获得%s", HtmlColorTxt("超时奖励", "#f558ff"))
|
|
lua_resM:setOutsideRawImage(self, self.title_raw, GameResPath.GetEscortImage("escort_fail"), false)
|
|
SetTMPSharedMaterial(self.type_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkBlueTitle)
|
|
end
|
|
self:UpdateReward()
|
|
local left_time = self.model:GetMaxEscortTimes() - self.model:GetEscortTimes()
|
|
self.cancel_btn_obj:SetActive(true)
|
|
if left_time > 0 then
|
|
self.can_continue = true
|
|
self.tip_text_tmp.text = string.format("剩余 %s 次外送任务,是否继续?", HtmlColorTxt(left_time, ColorUtil.GREEN_DARK))
|
|
else
|
|
self.can_continue = false
|
|
self.cancel_btn_obj:SetActive(false)
|
|
self.tip_text_tmp.text = "今日外送次数已满"
|
|
SetAnchoredPositionX(self.ok_btn, 218)
|
|
SetAnchoredPositionX(self.time_text, 218)
|
|
end
|
|
end
|
|
|
|
function EscortResultView:DestroySuccess( )
|
|
-- self.model:Fire(EscortConst.CHANGE_SCENE)
|
|
if self.escort_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.escort_timer_id)
|
|
self.escort_timer_id = nil
|
|
end
|
|
for i,v in ipairs(self.escort_reward_item) do
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
|
|
end
|
|
self.escort_reward_item = {}
|
|
end
|
|
|
|
function EscortResultView:UpdateLeftTime( )
|
|
local function onExitTimer()
|
|
if self.left_time > 0 then
|
|
self.time_text_tmp.text = string.format("%s秒后自动继续",HtmlColorTxt(self.left_time, ColorUtil.GREEN_DARK))
|
|
else
|
|
GlobalTimerQuest:CancelQuest(self.escort_timer_id)
|
|
self.escort_timer_id = nil
|
|
self:ClickBtn()
|
|
end
|
|
self.left_time = self.left_time - 1
|
|
end
|
|
self.escort_timer_id = GlobalTimerQuest:AddPeriodQuest(onExitTimer, 1, -1)
|
|
onExitTimer()
|
|
end
|
|
|
|
function EscortResultView:UpdateReward( )
|
|
local lv = RoleManager.Instance.mainRoleInfo.level
|
|
local vip_ratio = 0
|
|
local vip = RoleManager.Instance.mainRoleInfo.vip_flag
|
|
if Config.Vipprivilege[vip.."@8"] then
|
|
vip_ratio = Config.Vipprivilege[vip.."@8"].value
|
|
end
|
|
local cfg_exp = Config.Convoyexp
|
|
local convoy_exp = 0
|
|
for i,v in pairsByKeys(cfg_exp) do
|
|
if v.lv_low <= lv and lv <= v.lv_high then
|
|
convoy_exp = v.convoy_exp
|
|
break
|
|
end
|
|
end
|
|
local total_data = {}
|
|
local cfg_data = Config.Convoyobject[self.data.object_id]
|
|
local data = stringtotable(cfg_data.award)
|
|
local double_ratio = self.model:CurTimeIsDouble() and 2 or 1
|
|
local exp_num1 = convoy_exp * cfg_data.stage_one_ratio/100
|
|
if self.data.result == 1 then
|
|
exp_num1 = convoy_exp * cfg_data.stage_one_ratio/100
|
|
elseif self.data.result == 2 then
|
|
exp_num1 = convoy_exp * cfg_data.overdue_ratio/100 * cfg_data.stage_one_ratio/100
|
|
end
|
|
if self.model:CurTimeIsDouble() or self.model.last_double_escort == 1 then
|
|
exp_num1 = exp_num1 *2
|
|
end
|
|
local exp_data = {
|
|
[1] = 0,
|
|
[2] = EscortConst.EXP_TPYE_ID,
|
|
[3] = exp_num1
|
|
}
|
|
table.insert(data, exp_data)
|
|
for ii,vv in ipairs(data) do
|
|
local item = self.escort_reward_item[ii]
|
|
if not item then
|
|
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.reward_con)
|
|
item:SetItemSize(84,84)
|
|
item:SetNumForceShow(true)
|
|
if #data == 2 then
|
|
item:SetPosition((ii-1)*90, 0)
|
|
else
|
|
item:SetPosition(50, 0)
|
|
end
|
|
self.escort_reward_item[ii] = item
|
|
end
|
|
item:SetData(vv[2],vv[3])
|
|
end
|
|
end
|
|
|
|
function EscortResultView:ClickBtn( )
|
|
if self.can_continue then
|
|
self.model:FlyToNpc()
|
|
else
|
|
self.model:FlyToNpc()
|
|
end
|
|
self:Close()
|
|
end
|