CSGWarInstructionView = CSGWarInstructionView or BaseClass(BaseView) local CSGWarInstructionView = CSGWarInstructionView --[[ CSGWarInstructionView.TabData = { [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]}, } --]] function CSGWarInstructionView:__init() self.base_file = "CSGWar" self.layout_file = "CSGWarInstructionView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true --全屏界面默认使用这个参数 --self.hide_maincancas = true --全屏界面需要放开隐藏主UI self.change_scene_close = true self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.ignore_use_anim = true self.hide_time = 15 self.model = CSGWarModel:getInstance() self.load_callback = function () self:LoadSuccess() 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 CSGWarInstructionView:Open(need_auto_close) self.need_auto_close = need_auto_close BaseView.Open(self) end function CSGWarInstructionView:LoadSuccess() local nodes = { "text2:tmp", "text4:tmp", "text1:tmp", "text3:tmp", "close_text:tmp", } self:GetChildren(nodes) self:AddEvent() local closeWin_callback = function() self:CloseAnimation() -- self:Close() end self.tabWindowComponent = UITabWindow.New(self.transform,nil,self.switch_callback,closeWin_callback,self.background_wnd,self.container, UITabWindow.SizeSmallNoTab, false,nil,false) self.tabWindowComponent:SetBackgroundRes("csgwar_instruction_bg") self.tabWindowComponent:SetTitleText("玩法教学") -- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_instruction_bg"),false) end function CSGWarInstructionView:AddEvent() end function CSGWarInstructionView:CloseAnimation( ) self.background_wnd:SetActive(false) if self.pos_id then TweenLite.Stop(self.pos_id) self.pos_id = nil end local function callback1( ) self:Close() end self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(360,320), 0.3, callback1) if self.scale_id then TweenLite.Stop(self.scale_id) self.scale_id = nil end local function callback2( ) self:Close() end self.scale_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3(0.1,0.1,0.1), 0.3, callback1) end function CSGWarInstructionView:StopCloseAnimation( ) if self.scale_id then TweenLite.Stop(self.scale_id) self.scale_id = nil end if self.pos_id then TweenLite.Stop(self.pos_id) self.pos_id = nil end end function CSGWarInstructionView:StartCloseTimer( ) local end_time = self.hide_time + TimeUtil:getServerTime() local function close_timer() local left_time = end_time - TimeUtil:getServerTime() self.close_text_tmp.text = left_time >= 0 and string.format("(%s秒后自动关闭)", HtmlColorTxt(math.ceil(left_time+1), ColorUtil.GREEN_DARK)) or "" if left_time < 0 then self:StopCloseTimer() self:CloseAnimation() end end close_timer() self.close_timer_id = GlobalTimerQuest:AddPeriodQuest(close_timer, 0.1, -1) end function CSGWarInstructionView:StopCloseTimer( ) if self.close_timer_id then GlobalTimerQuest:CancelQuest(self.close_timer_id) self.close_timer_id = nil end end function CSGWarInstructionView:OpenSuccess() self:UpdateView() end function CSGWarInstructionView:UpdateView() local cfg = CSGWarConst.INSTRUCTION_VIEW_DESC for i=1,4 do self["text"..i.."_tmp"].text = cfg[i] end if self.need_auto_close then self:StartCloseTimer() end end function CSGWarInstructionView:SwitchTab( index ) end function CSGWarInstructionView:DestroySuccess( ) GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() self.tabWindowComponent = nil end self:StopCloseTimer() self:StopCloseAnimation() end