CSMainBaseView = CSMainBaseView or BaseClass(BaseView) local CSMainBaseView = CSMainBaseView function CSMainBaseView:__init() self.base_file = "csMain" self.layout_file = "CSMainBaseView" self.layer_name = "UI" self.destroy_imm = true self.use_background = true self.change_scene_close = true self.hide_maincancas = true --是否隐藏主界面 self.append_to_ctl_queue = true --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.close_fog = true self.is_set_zdepth = true self.full_screen = true self.need_culling_mask_ground = true --打开界面是否需要摄像机剔除ground层 -- self.fire_change_visible_event = true self.hide_clear_role_model = false self.model = CSMainModel:getInstance() self.current_index = nil self.anim_time = 0.3 self.role_show_item_list = {} self.load_callback = function () self:LoadSuccess() self:AddEvent() self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60300) --切换背景音乐 self.last_scene_sound = lua_soundM.cur_scene_sound if lua_soundM:StopBacksound() then lua_soundM.last_backgound_abName = false end lua_soundM:PlayBackgroundSound("field2", LuaSoundManager.SOUND_TYPE.SCENE, true) end self.open_callback = function ( ) self:OpenSuccess() end self.destroy_callback = function ( ) self:DestroySuccess() --恢复背景音乐 local cur_scene_sound = self.last_scene_sound if cur_scene_sound then if lua_soundM:StopBacksound() then lua_soundM.last_backgound_abName = false end lua_soundM:PlayBackgroundSound(cur_scene_sound, LuaSoundManager.SOUND_TYPE.SCENE, true) end end end function CSMainBaseView:Open() BaseView.Open(self) end function CSMainBaseView:LoadSuccess() local nodes = { "helpBtn:obj", "rightBtnCon/taskBtn:obj", "closeBtn:obj", "modelCon", "rightBtnCon/militaryRanksBtn:obj", "bg:raw", "rightBtnCon/exploitBtn:obj", "rightBtnCon", "sandTableBtn:obj", "appointBtn:obj", "sandTableBtn/sanTableImg:img", "rightBtnCon/taskBtn/taskRed:obj", "rightBtnCon/exploitBtn/exploitRed:obj", "rightBtnCon/militaryRanksBtn/militaryRed:obj", "appointBtn/appointRed:obj", "sandTableBtn/sandRed:obj", "rightBtnCon/sandTableBtn2:obj", "rightBtnCon/sandTableBtn2/sandTableRed2:obj", "titleImg1", "titleLabel", "titleImg2", "roleLabel", "appointTitle:img", "con_money", "con_money/num_money:tmp", "con_money/add_btn_money:obj", "con_money/des_score:tmp", "con_money/di_money2", "con_money/di_money", } self:GetChildren(nodes) lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_command_bg")) lua_resM:setOutsideImageSprite(self, self.sanTableImg_img, GameResPath.GetCSMainImage("cs_main_command_sand_table")) lua_resM:setOutsideImageSprite(self, self.appointTitle_img, GameResPath.GetCSMainImage("cs_main_appoint_out_title")) SetSizeDelta(self.transform, ScreenWidth, ScreenHeight) self:SetIpxMode() -- SetLocalPositionZ(self.sandTableBtn,-1000) 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.tabWindowComponent.win_bg) self:MoveUIToBack(self.bg_raw) end if self.background_wnd then bg_back_func() else self.bg_back_func = bg_back_func end end function CSMainBaseView:AddEvent() local on_click = function ( click_obj ) if self.closeBtn_obj == click_obj then--关闭 self:Close() elseif self.helpBtn_obj == click_obj then--规则 EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 60301) elseif self.taskBtn_obj == click_obj then--任务 self.model:Fire(CSMainConst.OPEN_CS_MAIN_TASK_VIEW) -- self:OpenTaskView() elseif self.militaryRanksBtn_obj == click_obj then--军衔 self.model:Fire(CSMainConst.OPEN_CS_MAIN_MILITARY_RANKS_BSAE_VIEW) elseif self.exploitBtn_obj == click_obj then--军功排行 self.model:Fire(CSMainConst.OPEN_CS_MAIN_EXPLOIT_RANK_VIEW) elseif self.appointBtn_obj == click_obj then--任命界面 self.model:Fire(CSMainConst.OPEN_CS_MAIN_APPOINT_VIEW) elseif self.sandTableBtn_obj == click_obj then--沙盘入口 SandTableModel:getInstance():Fire(SandTableConst.OPEN_MAIN_VIEW) elseif self.sandTableBtn2_obj == click_obj then--沙盘入口 SandTableModel:getInstance():Fire(SandTableConst.OPEN_MAIN_VIEW) elseif click_obj == self.add_btn_money_obj then UIToolTipMgr:getInstance():AppendGoodsTips(SandTableModel:getInstance().dungeon_cost_id, nil, nil,nil,nil,nil,nil,true) end end AddClickEvent(self.closeBtn_obj, on_click) AddClickEvent(self.helpBtn_obj, on_click) AddClickEvent(self.taskBtn_obj, on_click) AddClickEvent(self.militaryRanksBtn_obj, on_click) AddClickEvent(self.exploitBtn_obj, on_click) AddClickEvent(self.appointBtn_obj, on_click) AddClickEvent(self.sandTableBtn_obj, on_click) AddClickEvent(self.sandTableBtn2_obj, on_click) AddClickEvent(self.add_btn_money_obj,on_click) --60300后刷新指挥室角色展示 local function on_update_role_show() self.has_got_figure_data = true self:UpdateRoleShowCon() end self:BindEvent(self.model, CSMainConst.UPDATE_CS_MAIN_BASE_VIEW, on_update_role_show) local function update_red_dot(tab_id) if not self.is_loaded then return end self:RefreshRed(tab_id) end self:BindEvent(self.model, CSMainConst.ANS_UPDATE_RED_DOT, update_red_dot) local function onOrientationChange() self:SetIpxMode() end self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange) local function on_arms_num_change_var() self:ShowMoney() end self.on_arms_num_change_var_id = self.on_arms_num_change_var_id or self.model:BindOne("arms_num", on_arms_num_change_var) self:ShowMoney() local function on_exploit_rank_score_change_var() self:ShowScore() end self.on_exploit_rank_score_change_var_id = self.on_exploit_rank_score_change_var_id or self.model:BindOne("exploit_rank_score", on_exploit_rank_score_change_var) self:ShowScore() end function CSMainBaseView:ShowScore( ) self.des_score_tmp.text = string.format( "我的战功 :%d", self.model:GetCSMainExploitRankScore( )) SetSizeDeltaX(self.di_money2.transform, self.des_score_tmp.preferredWidth + 20) end function CSMainBaseView:ShowMoney( ) self.money_name = self.money_name or GoodsModel:getInstance():GetGoodsBasicByTypeId( SandTableModel:getInstance().dungeon_cost_id ).goods_name local cur = self.model:GetCSMainArmsNum( ) self.num_money_tmp.text = string.format( "%s :%s" ,self.money_name, cur) SetSizeDeltaX(self.di_money.transform, self.num_money_tmp.preferredWidth + 40) end function CSMainBaseView:SetIpxMode( ) if ClientConfig.iphone_x_model then self.titleImg1.anchoredPosition = Vector2(0+ClientConfig.iphone_x_offset_left, 333.5) self.titleLabel.anchoredPosition = Vector2(43+ClientConfig.iphone_x_offset_left, 333.5) self.titleImg2.anchoredPosition = Vector2(-115+ClientConfig.iphone_x_offset_left, 311) self.helpBtn.anchoredPosition = Vector2(10.5+ClientConfig.iphone_x_offset_left, -329.5) self.roleLabel.anchoredPosition = Vector2(61.5+ClientConfig.iphone_x_offset_left, -328) self.closeBtn.anchoredPosition = Vector2(0-ClientConfig.iphone_x_offset_right, 334) self.rightBtnCon.anchoredPosition = Vector2(0-ClientConfig.iphone_x_offset_right, 0) end end function CSMainBaseView:RefreshRed(tab_id) local bool = false if tab_id == CSMainConst.RedType.Task then bool = self.model:GetTaskRed() or self.model:GetActiveRed() self.taskRed_obj:SetActive(bool) elseif tab_id == CSMainConst.RedType.Active then bool = self.model:GetTaskRed() or self.model:GetActiveRed() self.taskRed_obj:SetActive(bool) elseif tab_id == CSMainConst.RedType.DailyReward then bool = self.model:GetDailyRewardRed() or self.model:GetWorShipRed() self.exploitRed_obj:SetActive(bool) elseif tab_id == CSMainConst.RedType.MilitaryRanks then bool = self.model:GetMilitaryRanksRed() self.militaryRed_obj:SetActive(bool) elseif tab_id == CSMainConst.RedType.SandTable then bool = self.model:GetSandTableRed() self.sandRed_obj:SetActive(bool) self.sandTableRed2_obj:SetActive(bool) elseif tab_id == CSMainConst.RedType.WorShip then bool = self.model:GetDailyRewardRed() or self.model:GetWorShipRed() self.exploitRed_obj:SetActive(bool) end end function CSMainBaseView:UpdateAllRed( ) local taskRed = self.model:GetTaskRed() or self.model:GetActiveRed() self.taskRed_obj:SetActive(taskRed) local exploitRed = self.model:GetDailyRewardRed() or self.model:GetWorShipRed() self.exploitRed_obj:SetActive(exploitRed) local militaryRed = self.model:GetMilitaryRanksRed() self.militaryRed_obj:SetActive(militaryRed) local sandRed = self.model:GetSandTableRed() self.sandRed_obj:SetActive(sandRed) self.sandTableRed2_obj:SetActive(sandRed) end function CSMainBaseView:OpenTaskView( ) self:StopAnim() local function onCompleted() local function delay_method( ) self.model:Fire(CSMainConst.OPEN_CS_MAIN_TASK_VIEW) -- self.tween_lite_id_3 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(0,0), self.anim_time) -- self.tween_lite_id_4 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3.New(1,1,1), self.anim_time) SetAnchoredPosition(self.transform, 0, 0) SetLocalScale(self.transform, 1, 1, 1) end self.delay_open_id = setTimeout(delay_method, 0.1) end self.tween_lite_id_1 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(1854,-713), self.anim_time) self.tween_lite_id_2 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3.New(4,4,4), self.anim_time, onCompleted) end function CSMainBaseView:UpdateRoleShowCon( ) local role_data = {} for i=1,7 do role_data[i] = self.model:GetCSMainDirectorDataByPos(i) end for k,v in pairs(self.role_show_item_list) do v:SetVisible(false) end for i,v in ipairs(role_data) do local item = self.role_show_item_list[i] if not item then item = CSMainRoleModelItem.New(self.modelCon) self.role_show_item_list[i] = item end item:SetVisible(true) item:SetData(i,v) item:SetAnchoredPosition(CSMainConst.RoleModelPos[i].x, CSMainConst.RoleModelPos[i].y) end end function CSMainBaseView:OpenSuccess() -- self:UpdateRoleShowCon() self:UpdateAllRed() end function CSMainBaseView:StopAnim( ) if self.delay_open_id then TimerQuest.CancelQuest(GlobalTimerQuest,self.delay_open_id) self.delay_open_id = nil end if self.tween_lite_id_1 then TweenLite.Stop(self.tween_lite_id_1) self.tween_lite_id_1 = nil end if self.tween_lite_id_2 then TweenLite.Stop(self.tween_lite_id_2) self.tween_lite_id_2 = nil end if self.tween_lite_id_3 then TweenLite.Stop(self.tween_lite_id_3) self.tween_lite_id_3 = nil end if self.tween_lite_id_4 then TweenLite.Stop(self.tween_lite_id_4) self.tween_lite_id_4 = nil end end function CSMainBaseView:DestroySuccess( ) self:StopAnim() for i, v in ipairs(self.role_show_item_list) do v:DeleteMe() end self.role_show_item_list = {} if self.on_arms_num_change_var_id then self.model:UnBind(self.on_arms_num_change_var_id) self.on_arms_num_change_var_id = nil end if self.on_exploit_rank_score_change_var_id then self.model:UnBind(self.on_exploit_rank_score_change_var_id) self.on_exploit_rank_score_change_var_id = nil end end