|
EscortSceneView = EscortSceneView or BaseClass(BaseView)
|
|
local EscortSceneView = EscortSceneView
|
|
--[[
|
|
EscortSceneView.TabData = {
|
|
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
|
|
}
|
|
--]]
|
|
local table_sort = table.sort
|
|
function EscortSceneView:__init()
|
|
self.base_file = "escort"
|
|
self.layout_file = "EscortSceneView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.use_background = false --全屏界面默认使用这个参数
|
|
--self.hide_maincancas = true --全屏界面需要放开隐藏主UI
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
|
|
self.model = EscortModel:getInstance()
|
|
self.cur_index = 1
|
|
self.is_hide = false
|
|
self.escort_reward_item = {}
|
|
self.kill_info_list = {}
|
|
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 EscortSceneView:Open( )
|
|
--self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function EscortSceneView:LoadSuccess()
|
|
local nodes = {
|
|
"base_con", "base_con/escort_btn:obj:img", "arrow_image",
|
|
"hide_btn:obj","base_con/escort_btn/escort_btn_image:img",
|
|
"downCon:obj", "downCon/go_btn:obj:img",
|
|
"tip_con:obj",
|
|
--运送con
|
|
"base_con/escort_con/name_text:tmp", "base_con/escort_con/time_text:tmp", "base_con/escort_con/iconImg:img",
|
|
"base_con/escort_con/escort_reward_con1", "base_con/escort_con/have_times_text:tmp",
|
|
"base_con/escort_con:obj", "base_con/escort_con/lb1:tmp", "base_con/escort_con/desc_text:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
-- self.time_limit = Config.Convoykv["convoy_overtime"].value_content
|
|
self.lb1_tmp.text = "外送奖励"
|
|
self.desc_text_tmp.text = "勤奋的外送员从不偷懒!\n外送至目的地可获得奖励"
|
|
self.transform.sizeDelta = Vector3(ScreenWidth, ScreenHeight)
|
|
SetAnchoredPosition(self.transform, 0, 0)
|
|
self:ChangeUiPosition()
|
|
self.model:SetEscortSceneViewOpen(true)
|
|
ExpDunModel:getInstance():Fire(ExpDunModel.UPDATE_EXP_DUN_BTN)
|
|
|
|
if not self.init_exit_btn then
|
|
self.init_exit_btn = true
|
|
local function call_back( ... )
|
|
local is_escort = self.model:IsEscortState()
|
|
local is_in_dun = SceneManager.Instance:IsEscortPVEDunScene()
|
|
local function ok( ... )
|
|
if is_escort then
|
|
self.model:Fire(EscortConst.REQUEST_SCMD_EVENT, 50008)
|
|
elseif is_in_dun then
|
|
BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61002)
|
|
else
|
|
self.model:FlyToNpc()
|
|
end
|
|
end
|
|
local ask_str = (is_escort or is_in_dun) and "\n放弃运送将会损失大量经验,确定吗?" or "即将返回主城,确定吗?"
|
|
Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
|
|
end
|
|
local data = {call_back = call_back, pos = {x = 240,y = 310}} -- pos 为左侧侧边栏的长度
|
|
GlobalEventSystem:Fire(EventName.SHOW_EXIT_BTN_STATE, data)
|
|
end
|
|
|
|
if self.model:GetEscortSceneLeftHideState() then--代表是展示了左边的东西 所以这里要隐藏
|
|
self:SetHideState(true)
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:AddEvent()
|
|
--适配刘海屏
|
|
local function onOrientationChange()
|
|
self:ChangeUiPosition()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
|
|
|
|
local function on_update_stage_info( )
|
|
self:UpdateView()
|
|
end
|
|
self.on_update_stage_info_id = self.model:BindOne("escort_stage_info", on_update_stage_info)
|
|
|
|
local function on_ans_basic_info()
|
|
-- print("Lizhijian:EscortSceneView [start:105]")
|
|
if self.model:IsEscortState() and SceneManager.Instance:IsEscortAllScene() then
|
|
self:UpdateReward()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, EscortConst.ANS_BASIC_INFO, on_ans_basic_info)
|
|
self:BindEvent(self.model, EscortConst.CHANGE_LAST_DOUBLE, on_ans_basic_info)
|
|
|
|
local function on_update_escort_state( ... )
|
|
self:SetBtnState()
|
|
end
|
|
self.on_update_escort_state_id = self.model:BindOne("escort_base_info", on_update_escort_state)
|
|
|
|
-- local function on_update_escort_btn( )
|
|
-- self:UpdateEscortBtnState()
|
|
-- end
|
|
-- self:BindEvent(self.model, EscortConst.UPDATE_BUTTON_STATE, on_update_escort_btn)
|
|
|
|
local function on_hide_left()
|
|
self:SetHideState(self.model:GetEscortSceneLeftHideState())
|
|
end
|
|
self:BindEvent(self.model, EscortConst.UPDATE_ESCORT_LEFT_SHOW, on_hide_left)
|
|
|
|
local function on_close_tip( ... )
|
|
self:ShowEscortCarTip(false)
|
|
end
|
|
self:BindEvent(self.model, EscortConst.RUN_NEAR_CAR, on_close_tip)
|
|
local function on_change_btn_state( )
|
|
print("HWR:EscortSceneView [125]2323232: ",2323232)
|
|
self:UpdateEscortBtnState()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, AutoFightManager.CHANGE_AUTO_FIND_WAY_STATE, on_change_btn_state)
|
|
local function on_click( target )
|
|
if target == self.escort_btn_obj then
|
|
if self.model:IsEscortState() or SceneManager.Instance:IsEscortPVEDunScene() then
|
|
self:SwitchView(1)
|
|
else
|
|
Message.show("您目前没有在运送中哦~")
|
|
self:SwitchView(2)
|
|
end
|
|
elseif target == self.hide_btn_obj then
|
|
self:SetHideState(not self.is_hide)
|
|
elseif target == self.go_btn_obj then
|
|
if not self.model:IsFollowEscortCar() then
|
|
self.model:GoEscortNpc()
|
|
else
|
|
self.model:SetEscortCarFollow(false)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.escort_btn_obj, on_click)
|
|
AddClickEvent(self.hide_btn_obj, on_click)
|
|
AddClickEvent(self.go_btn_obj, on_click)
|
|
|
|
-- self:BindLittleMove(self.go_btn, BaseView.LittleMoveDir.Bottom, -206.5)
|
|
|
|
self:BindLittleMove(self.tip_con, BaseView.LittleMoveDir.Bottom, -98)
|
|
self:BindLittleMove(self.downCon, BaseView.LittleMoveDir.Bottom, 310)
|
|
|
|
self:BindLittleMove(self.base_con, BaseView.LittleMoveDir.Left, 0)
|
|
self:BindLittleMove(self.hide_btn, BaseView.LittleMoveDir.Left, 0)
|
|
self:BindLittleMove(self.arrow_image, BaseView.LittleMoveDir.Left, 20)
|
|
|
|
-- 主界面聊天展开事件
|
|
self:BindMainUIExpandEvent(self.downCon)
|
|
end
|
|
|
|
function EscortSceneView:SetHideState(bool)
|
|
if self.is_do_action then
|
|
return
|
|
end
|
|
if bool == self.is_hide then return end
|
|
self.is_hide = bool
|
|
self:DoMoveAnimation()
|
|
end
|
|
|
|
function EscortSceneView:DoMoveAnimation()
|
|
if self.is_hide then
|
|
self.is_do_action = true
|
|
local function moveComplete()
|
|
self:MoveOutOfScreen(self.base_con.transform)
|
|
self.is_do_action = false
|
|
end
|
|
TweenLite.to(self, self.base_con, TweenLite.UiAnimationType.ANCHORED_POSX, -200, 0.2, moveComplete)
|
|
self.arrow_image.transform.localRotation = Quaternion.Euler(0,0,180)
|
|
else
|
|
self.is_do_action = true
|
|
local function moveComplete()
|
|
self.is_do_action = false
|
|
end
|
|
TweenLite.to(self, self.base_con, TweenLite.UiAnimationType.ANCHORED_POSX, ClientConfig.iphone_x_offset_left, 0.2, moveComplete)
|
|
self.arrow_image.transform.localRotation = Quaternion.Euler(0,0,0)
|
|
self:MoveInToScreen(self.base_con.transform)
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:OpenSuccess()
|
|
self:UpdateView()
|
|
end
|
|
|
|
function EscortSceneView:UpdateView()
|
|
self:UpdateEscortTime()
|
|
self:UpdateReward()
|
|
self:SwitchView(self.cur_index)
|
|
self:SetBtnState()
|
|
self:UpdateEscortBtnState()
|
|
end
|
|
|
|
function EscortSceneView:UpdateDunInfo( )
|
|
local dun_id = SceneManager:getInstance():GetCurrDunId()
|
|
local wave_cfg = BaseDungeonModel:getInstance():GetDunWaveCfg(dun_id)
|
|
local temp_mon_list = {}
|
|
for i,v in ipairs(wave_cfg) do
|
|
local mon_list = stringtotable(v.mon_list)
|
|
local sort_func = function ( a, b )
|
|
return a[1] < b[1]
|
|
end
|
|
table_sort(mon_list, sort_func)
|
|
for kk, vv in ipairs(mon_list) do -- 一条数据就是一个怪
|
|
temp_mon_list[vv[1]] = temp_mon_list[vv[1]] or 0
|
|
temp_mon_list[vv[1]] = temp_mon_list[vv[1]] + 1
|
|
end
|
|
end
|
|
local temp_one_mon_id = nil
|
|
for i,v in pairs(temp_mon_list) do
|
|
temp_one_mon_id = i
|
|
break
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:SwitchView( index )
|
|
self.cur_index = index
|
|
if index == 1 then
|
|
self.escort_con_obj:SetActive(true)
|
|
lua_resM:setImageSprite(self, self.escort_btn_image_img, "escort_asset", "escort_icon6", true)
|
|
self:UpdateReward()
|
|
else
|
|
self.escort_con_obj:SetActive(false)
|
|
lua_resM:setImageSprite(self, self.escort_btn_image_img, "escort_asset", "escort_item7", true)
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:SetBtnState( )
|
|
local is_escort = self.model:IsEscortState()
|
|
self.go_btn_obj:SetActive(is_escort)
|
|
local base_info = self.model:GetEscortBaseInfo()
|
|
if TableSize(base_info) > 0 then
|
|
self.have_times_text_tmp.text = string.format("剩余可接外送次数:<color=%s>%s次</color>",ColorUtil.YELLOW_DARK,self.model:GetMaxEscortTimes() - base_info.convoy_counts)
|
|
lua_resM:setImageSprite(self, self.iconImg_img, "escort_asset", "escort_"..base_info.object_id)
|
|
local cfg = Config.Convoyobject
|
|
if cfg[base_info.object_id] then
|
|
self.name_text_tmp.text = Trim(cfg[base_info.object_id].name)
|
|
end
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:UpdateEscortTime( )
|
|
if self.escort_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.escort_timer_id)
|
|
self.escort_timer_id = nil
|
|
end
|
|
local data = self.model:GetEscortBaseInfo()
|
|
if TableSize(data) == 0 then return end
|
|
self.end_time = data.end_time
|
|
local left_time = math.max(0,self.end_time - TimeUtil:getServerTime())
|
|
if left_time <= 0 then
|
|
|
|
else
|
|
local function onExitTimer()
|
|
left_time = self.end_time - TimeUtil:getServerTime()
|
|
if left_time > 0 then
|
|
self.time_text_tmp.text = string.format("外送限时 <size=115%%>%s</size>",HtmlColorTxt(TimeUtil:timeConvert8(left_time), ColorUtil.GREEN_DARK))
|
|
else
|
|
GlobalTimerQuest:CancelQuest(self.escort_timer_id)
|
|
self.escort_timer_id = nil
|
|
end
|
|
end
|
|
self.escort_timer_id = GlobalTimerQuest:AddPeriodQuest(onExitTimer, 1, -1)
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:UpdateReward( )
|
|
local data = self.model:GetStageRewardByType("escort")
|
|
-- print("Lizhijian:EscortSceneView [start:280] ")
|
|
-- PrintTable(data)
|
|
-- PrintTable(self.model:GetEscortBaseInfo())
|
|
-- print("Lizhijian:EscortSceneView [end:280] ")
|
|
if TableSize(data) == 0 then
|
|
return
|
|
end
|
|
local count = 1
|
|
for i=1,1 do
|
|
if data[i] then
|
|
for ii,vv in ipairs(data[i]) do
|
|
local item = self.escort_reward_item[count]
|
|
if not item then
|
|
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self["escort_reward_con1"])
|
|
item:SetItemSize(62,62)
|
|
item:SetNumForceShow(true)
|
|
item:SetPosition((count-1)*80, 0)
|
|
self.escort_reward_item[count] = item
|
|
end
|
|
item:SetData(vv[2],vv[3])
|
|
count = count + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:UpdateEscortBtnState( )
|
|
if AutoFightManager:getInstance():GetAutoFindWayState() then
|
|
lua_resM:setImageSprite(self, self.go_btn_img, "escort_asset", "escort_icon9")
|
|
else
|
|
lua_resM:setImageSprite(self, self.go_btn_img, "escort_asset", "escort_icon4")
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:ChangeUiPosition( )
|
|
SetAnchoredPositionX(self.base_con.transform, ClientConfig.iphone_x_offset_left)
|
|
SetAnchoredPositionX(self.arrow_image.transform, 19 + ClientConfig.iphone_x_offset_left)
|
|
SetAnchoredPositionX(self.hide_btn.transform, -1 + ClientConfig.iphone_x_offset_left)
|
|
end
|
|
|
|
function EscortSceneView:ShowEscortCarTip( bool )
|
|
if bool then
|
|
self.tip_con_obj:SetActive(true)
|
|
if self.delay_tip_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest,self.delay_tip_id)
|
|
self.delay_tip_id = nil
|
|
end
|
|
local function delay_method( )
|
|
self:ShowEscortCarTip(false)
|
|
end
|
|
self.delay_tip_id = setTimeout(delay_method, 15)--倒数15秒消失
|
|
else
|
|
self.tip_con_obj:SetActive(false)
|
|
if self.delay_tip_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest,self.delay_tip_id)
|
|
self.delay_tip_id = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
function EscortSceneView:DestroySuccess( )
|
|
GlobalEventSystem:Fire(EventName.HIDE_EXIT_BTN_STATE)
|
|
if self.kill_update_id then
|
|
BaseDungeonModel:getInstance():UnBind(self.kill_update_id)
|
|
self.kill_update_id = nil
|
|
end
|
|
if self.escort_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.escort_timer_id)
|
|
self.escort_timer_id = nil
|
|
end
|
|
|
|
if self.on_update_stage_info_id then
|
|
self.model:UnBind(self.on_update_stage_info_id)
|
|
self.on_update_stage_info_id = nil
|
|
end
|
|
|
|
if self.on_update_blood_id then
|
|
self.model:UnBind(self.on_update_blood_id)
|
|
self.on_update_blood_id = nil
|
|
end
|
|
|
|
if self.on_update_escort_state_id then
|
|
self.model:UnBind(self.on_update_escort_state_id)
|
|
self.on_update_escort_state_id = nil
|
|
end
|
|
|
|
|
|
if self.on_update_skill_btn_id then
|
|
self.model:UnBind(self.on_update_skill_btn_id)
|
|
self.on_update_skill_btn_id = nil
|
|
end
|
|
|
|
if self.change_icon_event_id then
|
|
GlobalEventSystem:UnBind(self.change_icon_event_id)
|
|
self.change_icon_event_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 = {}
|
|
self.model:SetEscortSceneViewOpen(false)
|
|
ExpDunModel:getInstance():Fire(ExpDunModel.UPDATE_EXP_DUN_BTN)
|
|
end
|