TaskDailyView = TaskDailyView or BaseClass(BaseView)
|
|
local TaskDailyView = TaskDailyView
|
|
TaskDailyView.Show_List = {
|
|
[1] = {
|
|
id = 1,
|
|
str = "经验副本",
|
|
icon_name = "icon_54_jjfb",
|
|
exp = 0,
|
|
show_recommend = true,
|
|
},
|
|
[2] = {
|
|
id = 2,
|
|
str = "日常任务",
|
|
icon_name = "icon_53_mrll",
|
|
exp = 0,
|
|
show_recommend = false,
|
|
},
|
|
[3] = {
|
|
id = 3,
|
|
str = "社团任务",
|
|
icon_name = "icon_49_ghrw",
|
|
exp = 0,
|
|
show_recommend = false,
|
|
},
|
|
[4] = {
|
|
id = 4,
|
|
str = "飞艇护送",
|
|
icon_name = "icon_48_fths",
|
|
exp = 0,
|
|
show_recommend = false,
|
|
},
|
|
[5] = {
|
|
id = 5,
|
|
str = "前往挂机",
|
|
icon_name = "icon_57_ywgj",
|
|
exp = 0,
|
|
show_recommend = false,
|
|
},
|
|
[6] = {
|
|
id = 6,
|
|
str = "装备副本",
|
|
icon_name = "icon_55_zbfb",
|
|
exp = 0,
|
|
show_recommend = false,
|
|
},
|
|
}
|
|
|
|
function TaskDailyView:__init()
|
|
self.base_file = "task"
|
|
self.layout_file = "TaskDailyView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.open_wnd_anim = 0
|
|
self.hide_maincancas = false
|
|
self.change_scene_close = true
|
|
self.click_bg_toClose = true
|
|
self.background_alpha = 0
|
|
self.is_set_order_sorting = false
|
|
self.item_list = {}
|
|
self.model = TaskModel:getInstance()
|
|
|
|
self.is_moving = false
|
|
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
|
|
self.open_callback = function()
|
|
self:InitView()
|
|
end
|
|
|
|
self.close_callback = function( )
|
|
end
|
|
|
|
self.destroy_callback = function()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
function TaskDailyView:InitView()
|
|
self:UpdateView()
|
|
self:TweenShowPanelPosition(true)
|
|
end
|
|
|
|
function TaskDailyView:Open()
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function TaskDailyView:Remove()
|
|
for k,v in pairs(self.item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.item_list = {}
|
|
|
|
self:CancelTween()
|
|
self:CancelTimer()
|
|
end
|
|
|
|
function TaskDailyView:LoadSuccess()
|
|
|
|
self.transform.localPosition = Vector3.zero
|
|
self.transform.sizeDelta = Vector3.zero
|
|
|
|
if ClientConfig.iphone_x_model then
|
|
self.transform.offsetMin = Vector2(ClientConfig.iphone_x_offset_left,0)
|
|
self.transform.offsetMax = Vector2(-ClientConfig.iphone_x_offset_right,0)
|
|
end
|
|
|
|
self.showObject,
|
|
self.mask_btn,
|
|
self.close_btn = self:GetChildGameObjects({
|
|
"Mask/ShowInfo",
|
|
"MaskBtn",
|
|
"Mask/ShowInfo/CloseBtn",
|
|
})
|
|
|
|
self.maskCon,
|
|
self.showCon,
|
|
self.mScoll,
|
|
self.mContent,
|
|
self.item_parent = self:GetChildTransforms({
|
|
"Mask",
|
|
"Mask/ShowInfo",
|
|
"Mask/ShowInfo/ScrollView",
|
|
"Mask/ShowInfo/ScrollView/Viewport/Content",
|
|
"Mask/ShowInfo/ScrollView/Viewport/Content/ItemParent",
|
|
})
|
|
|
|
self.showCon.anchoredPosition = Vector2(-250,-223)
|
|
self.maskCon.anchoredPosition = Vector2(300,-335)
|
|
end
|
|
|
|
function TaskDailyView:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.mask_btn or target == self.close_btn then
|
|
|
|
if self.is_moving then
|
|
return
|
|
end
|
|
self.mask_btn:SetActive(false)
|
|
self:TweenShowPanelPosition(false)
|
|
end
|
|
end
|
|
|
|
AddClickEvent(self.mask_btn,onBtnClickHandler)
|
|
AddClickEvent(self.close_btn,onBtnClickHandler)
|
|
end
|
|
|
|
function TaskDailyView:UpdateView( )
|
|
local list = self:GetShowList()
|
|
local len = #list
|
|
for i,v in ipairs(list) do
|
|
if self:CheckOperation(v) then
|
|
local item = self.item_list[i]
|
|
if not item then
|
|
item = TaskDailyItem.New(self.item_parent)
|
|
self.item_list[i] = item
|
|
end
|
|
item:SetVisible(true)
|
|
item:SetData(i,v)
|
|
end
|
|
end
|
|
|
|
self.mContent.sizeDelta = Vector2(360,99 * len)
|
|
|
|
for i=#list+1, #self.item_list do
|
|
self.item_list[i]:SetVisible(false)
|
|
end
|
|
end
|
|
|
|
--是否做完
|
|
function TaskDailyView:CheckOperation( vo )
|
|
local lv = RoleManager.Instance.mainRoleInfo.level
|
|
if vo.id==1 then
|
|
return BaseDungeonModel:getInstance():CanChallengeDun(BaseDungeonModel.DUN_TYPE.EXP)
|
|
elseif vo.id==2 then
|
|
return (self.model:CanAcceptCircleTask(TaskType.BOUNTY_LINE) or #self.model:GetTabData(TaskType.BOUNTY_LINE) > 0)
|
|
elseif vo.id==3 then
|
|
return (self.model:CanAcceptCircleTask(TaskType.GUILD_LINE) or #self.model:GetTabData(TaskType.GUILD_LINE) > 0)
|
|
elseif vo.id==5 then
|
|
return true
|
|
elseif vo.id==6 then
|
|
return BaseDungeonModel:getInstance():CanChallengeDun(BaseDungeonModel.DUN_TYPE.EQUIP)
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
--是否做完
|
|
function TaskDailyView:GetShowList()
|
|
local id_list = {}
|
|
for index,vo in ipairs(TaskDailyView.Show_List) do
|
|
if self:CheckOperation(vo) then
|
|
table.insert(id_list,vo)
|
|
end
|
|
end
|
|
|
|
if #id_list > 0 then
|
|
for index,vo in pairs(id_list) do
|
|
vo.exp = self.model:GetDoubleExp(vo.id)
|
|
end
|
|
|
|
local function sort_func(vo1,vo2)
|
|
if vo1.exp ~= vo2.exp then
|
|
return vo1.exp > vo2.exp
|
|
else
|
|
return vo1.id < vo2.id
|
|
end
|
|
end
|
|
|
|
table.sort(id_list,sort_func)
|
|
end
|
|
|
|
return id_list
|
|
end
|
|
|
|
function TaskDailyView:CancelTimer()
|
|
if self.timer_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
end
|
|
|
|
|
|
function TaskDailyView:CancelTween()
|
|
if self.tween_id then
|
|
TweenLite.Stop(self.tween_id)
|
|
self.tween_id = nil
|
|
end
|
|
end
|
|
|
|
function TaskDailyView:TweenShowPanelPosition(is_show)
|
|
|
|
if self.is_moving then
|
|
return
|
|
end
|
|
|
|
self.is_moving = true
|
|
|
|
self:CancelTween()
|
|
self:CancelTimer()
|
|
local func = function ()
|
|
if self._use_delete_method then
|
|
return
|
|
end
|
|
self:CancelTimer()
|
|
local end_x = is_show and 270 or -250
|
|
|
|
if is_show then
|
|
self.showObject:SetActive(true)
|
|
end
|
|
|
|
self.tween_id = TweenLite.to(self, self.showCon, TweenLite.UiAnimationType.ANCHORED_POSX, end_x, 0.2, function ()
|
|
if self._use_delete_method then
|
|
return
|
|
end
|
|
|
|
if is_show then
|
|
self.mask_btn:SetActive(true)
|
|
else
|
|
self:Close()
|
|
end
|
|
self.is_moving = false
|
|
end)
|
|
end
|
|
self.timer_id = TimerQuest.AddDelayQuest(GlobalTimerQuest, func,0.04)
|
|
end
|