PsionicTitleTipView = PsionicTitleTipView or BaseClass(BaseView)
|
|
local PsionicTitleTipView = PsionicTitleTipView
|
|
|
|
function PsionicTitleTipView:__init()
|
|
self.base_file = "psionic"
|
|
self.layout_file = "PsionicTitleTipView"
|
|
self.layer_name = "Top"
|
|
self.destroy_imm = true
|
|
self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.hide_time = 3 -- n秒后播放界面隐藏动画
|
|
|
|
self.model = PsionicModel:getInstance()
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function PsionicTitleTipView:Open(title_lv)
|
|
self.title_lv = title_lv
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function PsionicTitleTipView:LoadSuccess()
|
|
local nodes = {
|
|
"title_icon:img",
|
|
"tip_lb:tmp",
|
|
"stage_name:img",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
|
|
self.transform.anchoredPosition = Vector2(-3.5, 61.5)
|
|
end
|
|
|
|
function PsionicTitleTipView:AddEvent()
|
|
|
|
end
|
|
|
|
function PsionicTitleTipView:OpenSuccess()
|
|
self:UpdateView()
|
|
self:StartCloseTimer()
|
|
self:OpenAnimation() -- 播放打开界面的动画
|
|
end
|
|
|
|
function PsionicTitleTipView:UpdateView()
|
|
lua_resM:setImageSprite(self, self.stage_name_img, "psionic_asset", "ps_stage_name" .. self.title_lv, true)
|
|
lua_resM:setImageSprite(self, self.title_icon_img, "psionicExtra_asset", "ps_stage_icon" .. self.title_lv, true)
|
|
|
|
self.tip_lb_tmp.text = string.format("<color=#fdffc2>激活</color> %s圣阶", Trim(Config.Nucleontitle[self.title_lv].name))
|
|
end
|
|
|
|
-- 开始界面关闭的倒计时
|
|
function PsionicTitleTipView:StartCloseTimer()
|
|
self:ClearHideTimer()
|
|
local end_time = self.hide_time + TimeUtil:getServerTime()
|
|
local function hide_timer()
|
|
local left_time = end_time - TimeUtil:getServerTime()
|
|
if left_time < 0 then
|
|
self:ClearHideTimer()
|
|
self:CloseAnimation()
|
|
end
|
|
end
|
|
hide_timer()
|
|
self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
|
|
-- 设置动画标志量
|
|
self.is_animating = true
|
|
end
|
|
function PsionicTitleTipView:ClearHideTimer( )
|
|
if self.hide_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.hide_timer_id)
|
|
self.hide_timer_id = nil
|
|
end
|
|
end
|
|
|
|
-- 播放打开界面的动画
|
|
function PsionicTitleTipView: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 PsionicTitleTipView: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 PsionicTitleTipView:DestroySuccess( )
|
|
self:ClearHideTimer()
|
|
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
|
|
end
|