TaskAnnounceView = TaskAnnounceView or BaseClass(BaseView)
|
|
|
|
local TaskAnnounceView = TaskAnnounceView
|
|
|
|
function TaskAnnounceView:__init()
|
|
self.base_file = "taskAnnounce"
|
|
self.layout_file = "TaskAnnounceView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.hide_maincancas = false
|
|
self.change_scene_close = true
|
|
self.cur_select = false
|
|
self.data_list = false
|
|
-- self.use_local_view = true
|
|
|
|
self.is_set_zdepth = false
|
|
|
|
self.blur_activity_bg = true
|
|
self.use_show_anim = true
|
|
self.use_hide_anim = true
|
|
|
|
self.item_list = false
|
|
self.reward_item_list = {}
|
|
self.model = TaskAnnounceModel:getInstance()
|
|
self.mainVo = RoleManager:getInstance():GetMainRoleVo()
|
|
self.loop_mgr = LoopScrowViewMgr.New()
|
|
self.column_num = 1 --一行多少个图标
|
|
self.show_count = 7
|
|
self.data_list_num = false
|
|
self.ui_effect = false
|
|
self.open_id = false
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
|
|
self.open_callback = function()
|
|
self:UpdateView()
|
|
end
|
|
|
|
self.close_callback = function( )
|
|
end
|
|
|
|
self.destroy_callback = function()
|
|
self:Clear()
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:Open(open_id)
|
|
self.open_id = open_id
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function TaskAnnounceView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:raw",
|
|
"reward_con/jum_btn:obj",
|
|
"right_red_dot:obj",
|
|
"rt_item:raw:obj",
|
|
"desc:tmp",
|
|
"right:obj",
|
|
"reward_con/tips:tmp",
|
|
"title_img:img",
|
|
"left_red_dot:obj",
|
|
"reward_con/get_btn:obj",
|
|
"ScrollView/Viewport:img",
|
|
"ScrollView/Viewport/Content",
|
|
"ScrollView/Viewport/Content/parent",
|
|
"reward_con/item_con:obj",
|
|
"left:obj",
|
|
"close_btn:obj",
|
|
"ScrollView:scroll:obj",
|
|
"icon:img:obj",
|
|
"reward_con/get_btn/get_btn_red_dot:obj",
|
|
"reward_con/get_done:obj",
|
|
"continue_btn:obj",
|
|
"continue_btn/continue_btn_txt:tmp",
|
|
"continue_tips:tmp:obj",
|
|
"reward_con:obj",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self.task_tip_table = {}
|
|
for i=1,2 do
|
|
self.task_tip_table[i] = {}
|
|
self.task_tip_table[i].dot = self:GetChild("task_con/task_dot_" .. i).gameObject
|
|
self.task_tip_table[i].txt = self:GetChild("task_con/task_tps_" .. i):GetComponent("TMPro.TextMeshProUGUI")
|
|
end
|
|
self.continue_btn_txt_tmp.text = "立即开启"
|
|
self.continue_tips_tmp.text = HtmlColorTxt("产出大量高级战魂", "#2cf86f")
|
|
self.right_obj:SetActive(true)
|
|
self.right_red_dot_obj:SetActive(true)
|
|
self.left_obj:SetActive(true)
|
|
self.left_red_dot_obj:SetActive(true)
|
|
self.ScrollView_obj:SetActive(true)
|
|
|
|
local function bg_back_func( ... )
|
|
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
|
|
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
|
|
|
|
end
|
|
self:MoveUIToBack(self.bg_raw)
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("task_announce_bg_988_458"))
|
|
end
|
|
if self.background_wnd then
|
|
bg_back_func()
|
|
else
|
|
self.bg_back_func = bg_back_func
|
|
end
|
|
|
|
self.mask_id = self:RegisterMask(self.Viewport_img)
|
|
|
|
end
|
|
|
|
function TaskAnnounceView:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.left_obj then
|
|
self:OnClickLeft()
|
|
|
|
elseif target == self.right_obj then
|
|
self:OnClickRight()
|
|
|
|
elseif target == self.close_btn_obj then
|
|
|
|
self:Close()
|
|
|
|
elseif target == self.continue_btn_obj then
|
|
self:Close()
|
|
|
|
elseif target == self.get_btn_obj then
|
|
if self.data then
|
|
self.model:Fire(TaskAnnounceModel.REQUEST_CCMD_EVENT, 18201, self.data.id)
|
|
end
|
|
elseif target == self.jum_btn_obj then
|
|
if self.data then
|
|
local jump_info = self.data and self.data.jump or ""
|
|
local jump_info = stringtotable(jump_info)
|
|
if jump_info and jump_info[1] and jump_info[2] then
|
|
self:Close()
|
|
OpenFun.Open(tonumber(jump_info[1]), tonumber(jump_info[2]))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.close_btn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.left_obj,onBtnClickHandler)
|
|
AddClickEvent(self.right_obj,onBtnClickHandler)
|
|
AddClickEvent(self.get_btn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.jum_btn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.continue_btn_obj,onBtnClickHandler)
|
|
|
|
|
|
local function onUpdateView()
|
|
if self._use_delete_method then return end
|
|
self.has_open = false
|
|
self:UpdateView()
|
|
self:UpdateCenter()
|
|
self.model:GetRewardByIndexSide(nil,nil, true)
|
|
end
|
|
self.update_view_id = self.model:Bind(TaskAnnounceModel.UPDATE_ANNOUNCE_VIEW, onUpdateView)
|
|
end
|
|
|
|
function TaskAnnounceView:UpdateView()
|
|
self.model:GetRewardByIndexSide(nil,nil, true)
|
|
local list = self.model:GetTaskAnnounceListInView()
|
|
local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
|
|
|
|
self.continue_btn_obj:SetActive(false)
|
|
self.continue_tips_obj:SetActive(false)
|
|
self.reward_con_obj:SetActive(true)
|
|
|
|
--只展示一个特殊的样式
|
|
if self.open_id and list and #list > 0 then
|
|
local t = false
|
|
for i,v in ipairs(list) do
|
|
if v.id == self.open_id then
|
|
t = v
|
|
break
|
|
end
|
|
end
|
|
if t then
|
|
self.data_list = {[1] = t}
|
|
self.data_list_num = 1
|
|
|
|
self.right_obj:SetActive(false)
|
|
self.right_red_dot_obj:SetActive(false)
|
|
self.left_obj:SetActive(false)
|
|
self.left_red_dot_obj:SetActive(false)
|
|
self.ScrollView_obj:SetActive(false)
|
|
self.reward_con_obj:SetActive(false)
|
|
|
|
self.continue_btn_obj:SetActive(true)
|
|
self.continue_tips_obj:SetActive(true)
|
|
|
|
else
|
|
self.data_list = list
|
|
self.data_list_num = #list or 0
|
|
end
|
|
else
|
|
self.data_list = list
|
|
self.data_list_num = #list or 0
|
|
end
|
|
|
|
-- self.data_list = list
|
|
-- self.data_list_num = #list or 0
|
|
if list then
|
|
if not self.item_list then
|
|
self.item_list = {}
|
|
local click_call_back = function (idx)
|
|
self:SelectItem(idx)
|
|
end
|
|
for i = 1, self.show_count do
|
|
local item = self.item_list[i]
|
|
if item == nil then
|
|
item = TaskAnnounceItem.New(self.parent)
|
|
item:SetClickCallBack(click_call_back)
|
|
self.item_list[i] = item
|
|
end
|
|
end
|
|
end
|
|
|
|
local function wrap_callback()
|
|
self:WrapContent()
|
|
end
|
|
self.loop_mgr:Init(self.ScrollView, self.Content, self.column_num, 230 , 130, function(item,index,realIndex)
|
|
if item and realIndex > 0 and realIndex <= #list then
|
|
item:SetData(realIndex, list[realIndex], self.mask_id)
|
|
item:SetSelect(realIndex == self.cur_select)
|
|
end
|
|
end, nil,nil,nil, wrap_callback)
|
|
if not self.has_open then
|
|
self.loop_mgr:InitChildren(self.item_list, #list)
|
|
self.loop_mgr:RestToBeginning()
|
|
self.loop_mgr:SetContentSizeData()
|
|
local index
|
|
local is_open = false
|
|
for k,v in pairs(list) do
|
|
if v and v.has_open and ((not index) or (index and k >= index)) then
|
|
index = k
|
|
if self.model:GetRewardData(v.id) == 1 then
|
|
break
|
|
end
|
|
end
|
|
if v and not v.has_open then
|
|
index = k
|
|
break
|
|
else
|
|
is_open = true
|
|
end
|
|
end
|
|
if not index then
|
|
index = is_open and #self.data_list_num - 3 or 1
|
|
end
|
|
if index then
|
|
index = index > (self.data_list_num - 3) and self.data_list_num - 3 or index
|
|
index = index < 1 and 1 or index
|
|
self.loop_mgr:JumpToChild(index - 1)
|
|
self:SelectItem(index)
|
|
end
|
|
else
|
|
self.loop_mgr:InitChildren(self.item_list, #list)
|
|
self.loop_mgr:ForceUpdateCurrentItems()
|
|
self.loop_mgr:SetContentSizeData()
|
|
end
|
|
self.has_open = true
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:Clear()
|
|
if self.item_list then
|
|
for k,v in pairs(self.item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.item_list = false
|
|
end
|
|
|
|
for k,v in pairs(self.reward_item_list) do
|
|
v:ReleaseObj()
|
|
end
|
|
self.reward_item_list = {}
|
|
|
|
if self.loop_mgr then
|
|
self.loop_mgr:DeleteMe()
|
|
self.loop_mgr = nil
|
|
end
|
|
|
|
if self.update_view_id then
|
|
self.model:UnBind(self.update_view_id)
|
|
self.update_view_id = nil
|
|
end
|
|
|
|
self:ClearUIEffect(self.rt_item)
|
|
lua_resM:clearRoleMode(self)
|
|
end
|
|
|
|
function TaskAnnounceView:SelectItem(idx)
|
|
if self.cur_select ~= idx then
|
|
self.cur_select = idx
|
|
for i,v in ipairs(self.item_list) do
|
|
v:SetSelect(v:GetItemIdx() == self.cur_select)
|
|
end
|
|
self:UpdateCenter()
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:WrapContent()
|
|
if self.data_list_num and self.data_list_num >= 4 then
|
|
local x = GetAnchoredPosition(self.Content)
|
|
local left_b = x < -229
|
|
local right_b = x > -229 * (self.data_list_num - 5)
|
|
self.left_obj:SetActive(left_b)
|
|
self.right_obj:SetActive(right_b)
|
|
local idx = math.ceil(math.abs( x / 229))
|
|
local left_idx = idx
|
|
local right_idx = idx + 4
|
|
self.left_red_dot_obj:SetActive(left_b and self.model:GetRewardByIndexSide(left_idx, true))
|
|
self.right_red_dot_obj:SetActive(right_b and self.model:GetRewardByIndexSide(right_idx))
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:OnClickLeft()
|
|
local x = GetAnchoredPosition(self.Content)
|
|
if x >= -229 * 4 then
|
|
self.loop_mgr:JumpToChild(1)
|
|
else
|
|
local index = math.ceil(- x / 229 )
|
|
index = index - 4
|
|
self.loop_mgr:JumpToChild(index)
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:OnClickRight()
|
|
local x = GetAnchoredPosition(self.Content)
|
|
if x <= -229 * (self.data_list_num - 4) then
|
|
self.loop_mgr:JumpToChild((self.data_list_num - 4))
|
|
else
|
|
local index = math.floor(- x / 229 )
|
|
index = index + 5
|
|
self.loop_mgr:JumpToChild(index)
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:CancelHide()
|
|
BaseView.CancelHide(self)
|
|
self:UpdateCenter()
|
|
end
|
|
|
|
function TaskAnnounceView:UpdateCenter()
|
|
if self.data_list and self.cur_select then
|
|
self.data = self.data_list[self.cur_select]
|
|
self:StopOpenFunTweenAnimation()
|
|
if self.data then
|
|
self.desc_tmp.text = Trim(self.data.func_desc)
|
|
self.tips_tmp.text = self.data.has_open and HtmlColorTxt("已开放", "#2cf86f") or Trim(self.data.con_desc)
|
|
local task_tip = {}
|
|
task_tip[1] = Trim(self.data.mod_desc1)
|
|
task_tip[2] = Trim(self.data.mod_desc2)
|
|
for i,v in ipairs(task_tip) do
|
|
if v == "" then
|
|
self.task_tip_table[i].dot:SetActive(false)
|
|
self.task_tip_table[i].txt.text = ""
|
|
else
|
|
self.task_tip_table[i].dot:SetActive(true)
|
|
self.task_tip_table[i].txt.text = v
|
|
end
|
|
end
|
|
local icon_res = Trim(self.data.title_pic)
|
|
lua_resM:setOutsideImageSprite(self, self.title_img_img, GameResPath.GetTaskAnnounce(icon_res), true)
|
|
|
|
if self.data.reward and self.data.reward ~= "" then
|
|
local reward = ErlangParser:GetInstance():Parse(self.data.reward)
|
|
for k,v in pairs(reward) do
|
|
local item = self.reward_item_list[k]
|
|
if item == nil then
|
|
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_con, nil, self.layer_name)
|
|
self.reward_item_list[k] = item
|
|
end
|
|
item:SetData(v[2], v[3], nil, nil, nil, nil, nil, self.mask_id)
|
|
item:SetVisible(true)
|
|
item:SetItemSize(62,62)
|
|
end
|
|
else
|
|
for k,v in pairs(self.reward_item_list) do
|
|
if v then
|
|
v:SetVisible(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
if self.data.icon and self.data.icon ~= 0 then
|
|
self:StartOpenFunTweenAnimation()
|
|
local call_back = function ( ... )
|
|
local size_x, size_y = GetSizeDeltaXY(self.icon.transform)
|
|
if size_x < 100 or size_y < 100 then
|
|
SetLocalScale(self.icon.transform, 1.4, 1.4, 1.4)
|
|
else
|
|
--SetLocalScale(self.icon.transform, 1, 1, 1)
|
|
SetLocalScale(self.icon.transform, 0.7, 0.7, 0.7)
|
|
end
|
|
end
|
|
-- SetAnchoredPosition(self.icon.transform, -144, 39)
|
|
self.icon.gameObject:SetActive(true)
|
|
lua_resM:setOutsideImageSprite(self, self.icon_img, GameResPath.GetTaskAnnounce("task_announce_icon_" .. self.data.icon), true, call_back)
|
|
else
|
|
self.icon.gameObject:SetActive(false)
|
|
end
|
|
|
|
self:ClearUIEffect(self.rt_item)
|
|
lua_resM:clearRoleMode(self)
|
|
local fashion_type
|
|
if self.data.model_res and self.data.model_res ~= 0 and Trim(self.data.model_res) ~= "" then
|
|
self.rt_item_obj:SetActive(true)
|
|
local model_data = stringtotable(Trim(self.data.model_res))
|
|
fashion_type = tonumber(model_data[1])
|
|
local figure_id = tonumber(model_data[2])
|
|
local position = Vector3(0,0,0)
|
|
local scale = 1
|
|
local action_name_list = {"show"}
|
|
if fashion_type == 1004 then -- 武器
|
|
action_name_list = {"show3"}
|
|
end
|
|
local style
|
|
--武器要根据每个职业自己的位置
|
|
if fashion_type == 1004 then
|
|
local career = RoleManager.Instance.mainRoleInfo.career
|
|
style = TaskAnnounceModel.WeaponUIStyle[career]
|
|
|
|
--如果是龙神宝库,虽然也是坐骑类型,但是这个坐骑比较大,特殊设置把
|
|
elseif self.data.id == 47 then
|
|
style = TaskAnnounceModel.TAViewUIStyle[9999]
|
|
else
|
|
style = TaskAnnounceModel.TAViewUIStyle[fashion_type]
|
|
end
|
|
if style then
|
|
scale = tonumber(style[1])
|
|
position = Vector3(style[2],style[3],style[4])
|
|
else
|
|
print("功能预告没有设置模型展示参数 类型 ", fashion_type)
|
|
scale = 300
|
|
position = Vector3(0,0, 0)
|
|
end
|
|
|
|
if fashion_type == 1301 then
|
|
self.rt_item.localRotation = Quaternion.Euler(-25, 0, 0)
|
|
else
|
|
self.rt_item.localRotation = Quaternion.Euler(0, 0, 0)
|
|
end
|
|
|
|
SetLocalPositionZ(self.rt_item, -2000)
|
|
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.rt_item,
|
|
fashion_type = fashion_type,
|
|
figure_id = figure_id,
|
|
action_name_list = action_name_list,
|
|
size = Vector2(1280,720),
|
|
scale = scale,
|
|
position = position,
|
|
show_shadow = true,
|
|
rotate = 0,
|
|
ui_model_type = UIModelCommon.ModelType.BackModel,
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
else
|
|
self.rt_item_obj:SetActive(false)
|
|
end
|
|
|
|
self:UpdateState()
|
|
|
|
end
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:StartOpenFunTweenAnimation()
|
|
local call_fun = function ()
|
|
local function onCompleted()
|
|
self:StartOpenFunTweenAnimation()
|
|
end
|
|
self.oepn_func_tween_id2 =TweenLite.to(self, self.icon.transform,TweenLite.UiAnimationType.POSY, 73+ 10,1,onCompleted)
|
|
end
|
|
self.oepn_func_tween_id1 =TweenLite.to(self, self.icon.transform,TweenLite.UiAnimationType.POSY, 73 - 10, 1, call_fun)
|
|
end
|
|
|
|
|
|
function TaskAnnounceView:StopOpenFunTweenAnimation()
|
|
if self.oepn_func_tween_id1 then
|
|
TweenLite.Stop(self.oepn_func_tween_id1)
|
|
self.oepn_func_tween_id1 = nil
|
|
end
|
|
|
|
if self.oepn_func_tween_id2 then
|
|
TweenLite.Stop(self.oepn_func_tween_id2)
|
|
self.oepn_func_tween_id2 = nil
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:UpdateState()
|
|
if self.data then
|
|
local state = self.model:GetRewardData(self.data.id)
|
|
self.get_btn_red_dot_obj:SetActive(state == 1)
|
|
self.get_btn_obj:SetActive(state == 1)
|
|
self.get_done_obj:SetActive(state == 2)
|
|
self.jum_btn_obj:SetActive(state == 2)
|
|
-- for i,v in ipairs(self.reward_item_list) do
|
|
-- v:SetGray(not self.data.has_open or state ~= 1)
|
|
-- end
|
|
|
|
-- if state and self.item_list[1] then
|
|
-- local callback = function()
|
|
-- self.model:Fire(TaskAnnounceModel.REQUEST_CCMD_EVENT, 18201, self.data.id)
|
|
-- end
|
|
-- if state == 0 or not has_open then --不可领取
|
|
-- self.item_list[1]:SetEnableClick(false)
|
|
-- self.item_list[1]:SetRedDot(false)
|
|
-- self.item_list[1]:SetCallBack(nil)
|
|
-- elseif state == 1 then --未领取
|
|
-- self.item_list[1]:SetEnableClick(true)
|
|
-- self.item_list[1]:SetRedDot(true)
|
|
-- self.item_list[1]:SetCallBack(callback)
|
|
-- elseif state == 2 then --已领取
|
|
-- self.item_list[1]:SetEnableClick(true)
|
|
-- self.item_list[1]:SetStatueTips(true, "tyui_ylq", nil, true)
|
|
-- self.item_list[1]:SetRedDot(false)
|
|
-- self.item_list[1]:SetCallBack(nil)
|
|
-- end
|
|
-- else
|
|
|
|
-- end
|
|
end
|
|
end
|
|
|
|
function TaskAnnounceView:Close()
|
|
BaseView.Close(self)
|
|
end
|