EquipCollectTipView = EquipCollectTipView or BaseClass(BaseView)
|
|
local EquipCollectTipView = EquipCollectTipView
|
|
--[[
|
|
EquipCollectTipView.TabData = {
|
|
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
|
|
}
|
|
--]]
|
|
|
|
function EquipCollectTipView:__init()
|
|
self.base_file = "equipCollect"
|
|
self.layout_file = "EquipCollectTipView"
|
|
self.layer_name = "Top"
|
|
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 = EquipCollectModel:getInstance()
|
|
self.hide_time = 2--关闭倒计时
|
|
self.item_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 EquipCollectTipView:Open(data)
|
|
self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function EquipCollectTipView:ReOpen( data )
|
|
self.data = data
|
|
self:UpdateView()
|
|
end
|
|
|
|
function EquipCollectTipView:LoadSuccess()
|
|
local nodes = {
|
|
"item_con", "bg:raw", "title:img",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("equip_collect_tip_bg"), false)
|
|
if AchieveModel:getInstance().tip_view_show then
|
|
self.transform.anchoredPosition = Vector2(-3, 211)
|
|
else
|
|
self.transform.anchoredPosition = Vector2(-3, 61)
|
|
end
|
|
end
|
|
|
|
function EquipCollectTipView:AddEvent()
|
|
|
|
end
|
|
|
|
function EquipCollectTipView:OpenSuccess()
|
|
self:UpdateView()
|
|
self:StartCloseTimer()
|
|
self:OpenAnimation() -- 播放打开界面的动画
|
|
end
|
|
|
|
-- 播放打开界面的动画
|
|
function EquipCollectTipView:OpenAnimation()
|
|
self.canvasGroup.alpha = 0
|
|
if self.alpha_anim_id then
|
|
TweenLite.Stop(self.alpha_anim_id)
|
|
self.alpha_anim_id = nil
|
|
end
|
|
self.alpha_anim_id = TweenLite.to(self, self.canvasGroup, TweenLite.UiAnimationType.ALPHA, 1, 0.2)
|
|
end
|
|
|
|
-- 关闭(隐藏)界面的动画
|
|
function EquipCollectTipView:CloseAnimation()
|
|
self.canvasGroup.alpha = 1
|
|
if self.alpha_anim_id then
|
|
TweenLite.Stop(self.alpha_anim_id)
|
|
self.alpha_anim_id = nil
|
|
end
|
|
self.alpha_anim_id = TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 0, 0.5)
|
|
local pos_y = self.transform.anchoredPosition.y + 100
|
|
if self.pos_id then
|
|
TweenLite.Stop(self.pos_id)
|
|
self.pos_id = nil
|
|
end
|
|
local function callback( )
|
|
self:Close()
|
|
end
|
|
self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSY, pos_y, 0.5, callback)
|
|
end
|
|
|
|
function EquipCollectTipView:CloseAnimation2( )
|
|
self.canvasGroup.alpha = 1
|
|
if self.alpha_anim_id then
|
|
TweenLite.Stop(self.alpha_anim_id)
|
|
self.alpha_anim_id = nil
|
|
end
|
|
self.alpha_anim_id = TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 0, 0.5)
|
|
local pos_y = self.transform.anchoredPosition.y + 100
|
|
if self.pos_id then
|
|
TweenLite.Stop(self.pos_id)
|
|
self.pos_id = nil
|
|
end
|
|
local function callback( )
|
|
self:Close()
|
|
end
|
|
self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(-330,720), 0.5, callback)
|
|
|
|
if self.scale_id then
|
|
TweenLite.Stop(self.scale_id)
|
|
self.scale_id = nil
|
|
end
|
|
local function callback( )
|
|
self:Close()
|
|
end
|
|
self.scale_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3(0.1,0.1,0.1), 0.5, callback)
|
|
end
|
|
|
|
|
|
function EquipCollectTipView:StartCloseTimer( )
|
|
local end_time = self.hide_time + TimeUtil:getServerTime()
|
|
local function hide_timer()
|
|
local left_time = end_time - TimeUtil:getServerTime()
|
|
if left_time < 0 then
|
|
if self.is_full then
|
|
self:CloseAnimation2()
|
|
else
|
|
self:CloseAnimation()
|
|
end
|
|
self:ClearHideTimer()
|
|
end
|
|
end
|
|
hide_timer()
|
|
if not self.hide_timer_id then
|
|
self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
|
|
end
|
|
end
|
|
|
|
function EquipCollectTipView:UpdateView()
|
|
local server_data = self.model:GetEquipCollectTipData(self.data.id)
|
|
lua_resM:setImageSprite(self, self.title_img, "equipCollect_asset","equipCollect_name_font"..self.data.id)
|
|
local count = 0
|
|
local need_action_data = nil
|
|
for i,v in ipairs(server_data) do
|
|
if v.type_id > 0 then
|
|
count = count + 1
|
|
end
|
|
if v.need_action then
|
|
need_action_data = DeepCopy(v)
|
|
need_action_data.index = i
|
|
end
|
|
end
|
|
self.is_full = count == 7
|
|
-- self.is_full = true
|
|
local x_offset = 68
|
|
for i=1,7 do
|
|
local item = self.item_list[i]
|
|
if not item then
|
|
item = EquipCollectTipItem.New(self.item_con)
|
|
item:SetPosition(x_offset*(i-1), 1)
|
|
self.item_list[i] = item
|
|
end
|
|
item:SetData(server_data[i])
|
|
end
|
|
self:StartFlyInAction(need_action_data)--开始飞进来的动画
|
|
end
|
|
|
|
function EquipCollectTipView:StartFlyInAction( need_action_data )
|
|
if not need_action_data or self.is_action then
|
|
return
|
|
end
|
|
if not self.action_item then
|
|
self.action_item = EquipCollectTipItem.New(self.item_con)
|
|
need_action_data.need_action = false
|
|
self.action_item:SetData(need_action_data)
|
|
end
|
|
self.action_item:StartAction(need_action_data)
|
|
end
|
|
|
|
|
|
function EquipCollectTipView:ClearHideTimer( )
|
|
if self.hide_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.hide_timer_id)
|
|
self.hide_timer_id = nil
|
|
end
|
|
end
|
|
|
|
function EquipCollectTipView:DestroySuccess( )
|
|
self:ClearHideTimer()
|
|
if self.delay_closeview_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest,self.delay_closeview_id)
|
|
self.delay_closeview_id = nil
|
|
end
|
|
if self.alpha_anim_id then
|
|
TweenLite.Stop(self.alpha_anim_id)
|
|
self.alpha_anim_id = nil
|
|
end
|
|
if self.pos_id then
|
|
TweenLite.Stop(self.pos_id)
|
|
self.pos_id = nil
|
|
end
|
|
if self.scale_id then
|
|
TweenLite.Stop(self.scale_id)
|
|
self.scale_id = nil
|
|
end
|
|
for i,v in ipairs(self.item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.item_list = {}
|
|
if self.action_item then
|
|
self.action_item:DeleteMe()
|
|
self.action_item = nil
|
|
end
|
|
end
|