源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

301 righe
11 KiB

CSMainAdvanceNoticeView = CSMainAdvanceNoticeView or BaseClass(BaseView)
local CSMainAdvanceNoticeView = CSMainAdvanceNoticeView
function CSMainAdvanceNoticeView:__init()
self.base_file = "csMain"
self.layout_file = "CSMainAdvanceNoticeView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true
self.change_scene_close = true
self.hide_maincancas = false --是否隐藏主界面
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.is_set_zdepth = true
self.click_bg_toClose = true
self.mainVo = RoleManager.Instance.mainRoleInfo
self.model = CSMainModel:getInstance()
self.cur_select_day = 0
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 CSMainAdvanceNoticeView:Open()
BaseView.Open(self)
end
function CSMainAdvanceNoticeView:LoadSuccess()
local nodes = {
"bg:raw", "dayImg:img",
"confirmBtn:obj", "leftBtn:obj", "rewardBtn:obj:img", "rightBtn:obj",
"rightBtn/rightRed:obj", "rewardBtn/rewardRed:obj", "leftBtn/leftRed:obj",
"openDayCon:obj", "openLvCon:obj", "openServerCon:obj",
"openDayCon/openDayDes:tmp", "openServerCon/openServerDes:tmp", "openLvCon/openLvDes:tmp",
"openServerCon/serverProgressBtn:obj",
"progressBlockCon/block7:img:obj", "progressBlockCon/block1:img:obj", "progressBlockCon/block3:img:obj", "progressBlockCon/block4:img:obj", "progressBlockCon/block2:img:obj", "progressBlockCon/block6:img:obj", "progressBlockCon/block5:img:obj",
"headTitle:tmp", "dayDes:tmp", "dayTitle:tmp",
"kfProcessBtn:obj",
}
self:GetChildren(nodes)
local _,cfg = GetModuleIsOpen(603)
local show_progress_num = cfg.open_day-1
self.progress_block_img_list = {}
self.progress_block_obj_list = {}
for i=1,7 do
self.progress_block_img_list[i] = self["block"..i.."_img"]
self.progress_block_obj_list[i] = self["block"..i.."_obj"]
self.progress_block_obj_list[i]:SetActive(i <= show_progress_num)
end
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_advance_notice_bg"))
self.headTitle_tmp.text = CSMainConst.AdvanceNoticeMainTitle
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
end
function CSMainAdvanceNoticeView:AddEvent()
local on_click = function ( click_obj )
if self.confirmBtn_obj == click_obj then
self:Close()
elseif self.leftBtn_obj == click_obj then
self.cur_select_day = self.cur_select_day - 1 >= 1 and self.cur_select_day - 1 or 1
self:SwitchDay(self.cur_select_day)
elseif self.rightBtn_obj == click_obj then
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
local _,cfg = GetModuleIsOpen(603)
local max_show_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
self.cur_select_day = self.cur_select_day + 1 <= max_show_day and self.cur_select_day + 1 or max_show_day
self:SwitchDay(self.cur_select_day)
elseif self.rewardBtn_obj == click_obj then
if self.can_get_reward then
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60316,self.cur_select_day)
else
local mes_str = string.format("第%s日奖励已领取过",self.cur_select_day)
Message.show(mes_str)
end
elseif self.openServerCon_obj == click_obj then
local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
if is_kf_state then
local is_cs_main_open = true
KfWorldModel:GetInstance():Fire(KfWorldConst.OPEN_KfWorld_TIP_VIEW, is_cs_main_open)
else
Message.show("本服暂未开启跨服状态!")
end
elseif self.kfProcessBtn_obj == click_obj then
local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
if is_kf_state then
local is_cs_main_open = true
KfWorldModel:GetInstance():Fire(KfWorldConst.OPEN_KfWorld_TIP_VIEW, is_cs_main_open)
else
Message.show("本服暂未开启跨服状态!")
end
end
end
AddClickEvent(self.confirmBtn_obj, on_click)
AddClickEvent(self.leftBtn_obj, on_click)
AddClickEvent(self.rightBtn_obj, on_click)
AddClickEvent(self.rewardBtn_obj, on_click)
AddClickEvent(self.openServerCon_obj, on_click)
AddClickEvent(self.kfProcessBtn_obj, on_click)
--刷新奖励领取状态
local function update_reward_state()
if not self.is_loaded then return end
self:UpdateView()
end
self:BindEvent(self.model, CSMainConst.UPDATE_CS_MAIN_ADVANCE_NOTICE_REWARD_STATE, update_reward_state)
local function chnage_open_day_func()
self:UpdateView()
end
self:BindEvent(GlobalEventSystem, EventName.OPEN_DAY_INIT, chnage_open_day_func)
local function chnage_day_func(type)
if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
self:UpdateView()
end
end
self:BindEvent(GlobalEventSystem, EventName.CHANE_DAY, chnage_day_func)
-- local function on_change_lv_handler()
-- self:UpdateView()
-- end
-- self.change_level_id = RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL,on_change_lv_handler)
end
function CSMainAdvanceNoticeView:OpenSuccess()
-- self:UpdateView()
end
function CSMainAdvanceNoticeView:UpdateView()
if self.cur_select_day == 0 then
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
local _,cfg = GetModuleIsOpen(603)
self.cur_select_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
end
self:SwitchDay(self.cur_select_day)
self:UpdateOpenCon()
local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
if is_kf_state then
self:AddUIEffect("ui_bianqiang", self.kfProcessBtn, "Activity", nil, {x=1,y=1}, true, nil,nil,nil,nil,nil,nil)
else
self:ClearUIEffect(self.kfProcessBtn)
end
end
function CSMainAdvanceNoticeView:SwitchDay(day)
--左右箭头
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
local _,cfg = GetModuleIsOpen(603)
local max_show_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
local need_hide_left = self.cur_select_day == 1
local need_hide_right = self.cur_select_day == max_show_day
self.leftBtn_obj:SetActive(not need_hide_left)
self.rightBtn_obj:SetActive(not need_hide_right)
--当天预告内容
local notice_cfg = Config.Legionadvance
local day_img_res = "cs_main_advance_img_"..self.cur_select_day
if notice_cfg[self.cur_select_day] and notice_cfg[self.cur_select_day].ads ~= 0 then
day_img_res = "cs_main_advance_img_"..notice_cfg[self.cur_select_day].ads
end
lua_resM:setOutsideImageSprite(self, self.dayImg_img, GameResPath.GetCSMainAdvanceNoticeImage(day_img_res))
local day_title_des = string.format("第 %s 日 %s", self.cur_select_day, CSMainConst.AdvanceNoticeDayDes[self.cur_select_day].title)
-- self.dayDes_tmp.text = CSMainConst.AdvanceNoticeDayDes[self.cur_select_day].des
if not string.find(day_title_des,"@") then
self.dayTitle_tmp.text = day_title_des
else
self.dayTitle_tmp.text = ChuanWenManager:FormatColorTag(day_title_des)
end
if not string.find(CSMainConst.AdvanceNoticeDayDes[self.cur_select_day].des,"@") then
self.dayDes_tmp.text = CSMainConst.AdvanceNoticeDayDes[self.cur_select_day].des
else
self.dayDes_tmp.text = ChuanWenManager:FormatColorTag(CSMainConst.AdvanceNoticeDayDes[self.cur_select_day].des)
end
--下方天数页签状态
for i=1,7 do
self["block"..i.."_obj"]:SetActive(i<=openDay)
if i == self.cur_select_day then
lua_resM:setImageSprite(self, self["block"..i.."_img"], "csMain_asset","cs_main_advance_progress_block_2")
else
lua_resM:setImageSprite(self, self["block"..i.."_img"], "csMain_asset","cs_main_advance_progress_block_1")
end
end
--奖励状态
self:UpdateRewardState()
end
function CSMainAdvanceNoticeView:UpdateOpenCon( )
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
local _,cfg = GetModuleIsOpen(603)
local left_day = cfg.open_day-openDay
local open_lv = GetModuleOpenLevel(603)
local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
if left_day <= 0 then --满足开服天数
if open_lv <= RoleManager.Instance.mainRoleInfo.level then--满足等级
if is_kf_num_enough then
self.openDayCon_obj:SetActive(false)
self.openLvCon_obj:SetActive(false)
self.openServerCon_obj:SetActive(false)
else
self.openDayCon_obj:SetActive(false)
self.openLvCon_obj:SetActive(false)
self.openServerCon_obj:SetActive(true)
self.openServerDes_tmp.text = "跨服分区拓展至4服时开启玩法 <#2cf89a><u>查看</u></color>"
end
else--不满足等级
self.openDayCon_obj:SetActive(false)
self.openLvCon_obj:SetActive(true)
self.openServerCon_obj:SetActive(false)
self.openLvDes_tmp.text = string.format("玩家达到 <#ff203a>%s</color>/200 级开放玩法", RoleManager.Instance.mainRoleInfo.level)
end
else--不满足开服天数
self.openDayCon_obj:SetActive(true)
self.openLvCon_obj:SetActive(false)
self.openServerCon_obj:SetActive(false)
self.openDayDes_tmp.text = string.format("距离系统开放还有 %s 日", left_day)
end
end
function CSMainAdvanceNoticeView:UpdateRewardState( )
local can_get_reward = self.model:CanDayGetCSMainAdvanceNoticeReward(self.cur_select_day)
self.rewardRed_obj:SetActive(can_get_reward)
local can_get_reward_last_day = self.model:CanDayGetCSMainAdvanceNoticeRewardBeforeOrAfter(self.cur_select_day,1)
local can_get_reward_next_day = self.model:CanDayGetCSMainAdvanceNoticeRewardBeforeOrAfter(self.cur_select_day,2)
self.leftRed_obj:SetActive(can_get_reward_last_day)
self.rightRed_obj:SetActive(can_get_reward_next_day)
self.can_get_reward = can_get_reward
SetImageGray(self.rewardBtn_img, not can_get_reward)
if can_get_reward then
if not self.main_action then
--左右跳跃
-- local pre_x, pre_y = GetAnchoredPosition(self.rewardBtn)
-- local action1 = cc.MoveTo.createAnchoredType( 0.05, -256, -195, pre_x, pre_y)
-- local action2 = cc.MoveTo.createAnchoredType( 0.05, -266, -195, pre_x+10, pre_y)
-- local action3 = cc.DelayTime.New(2)
-- local action4 = cc.Sequence.New(action1,action2,action1,action2,action3)--顺序
-- self.main_action = cc.RepeatForever.New( action4 )
-- self:AddAction(self.main_action, self.rewardBtn)
--旋转跳跃
local action1 = cc.RotateTo.New(0.05, 15, 1)
local action2 = cc.RotateTo.New(0.05, -15, 1)
local action3 = cc.RotateTo.New(0.05, 0, 1)
local action4 = cc.DelayTime.New( 1.5 )
local action5 = cc.Sequence.New( action1,action2,action1,action2,action3,action4)
self.main_action = cc.RepeatForever.New( action5 )
self:AddAction(self.main_action, self.rewardBtn)
end
else
if self.main_action then
cc.ActionManager:getInstance():removeAction(self.main_action)
self.main_action = nil
end
SetAnchoredPosition(self.rewardBtn, -266, -195)
end
end
function CSMainAdvanceNoticeView:DestroySuccess( )
if self.main_action then
cc.ActionManager:getInstance():removeAction(self.main_action)
self.main_action = nil
end
if self.change_level_id then
self.mainVo:UnBind(self.change_level_id)
self.change_level_id = nil
end
self:ClearUIEffect(self.kfProcessBtn)
end