|
--[[@------------------------------------------------------------------
|
|
@description:福利
|
|
@author:HWR
|
|
----------------------------------------------------------------------]]
|
|
require("game.proto.160.Require160")
|
|
require("game.fuli.FuliModel")
|
|
require("game.fuli.FuliConst")
|
|
require("game.fuli.FuliMainView")
|
|
require("game.fuli.FuliSignView")--签到奖励
|
|
require("game.fuli.FuliSignItem")
|
|
require("game.fuli.FuliSignRewardItem")
|
|
require("game.fuli.FuliAIView")--在线奖励
|
|
require("game.fuli.FuliAIItem")
|
|
require("game.fuli.FuliLevelView")--冲级奖励
|
|
require("game.fuli.FuliLevelItem")
|
|
require("game.fuli.FuliDownloadView")--下载奖励
|
|
require("game.fuli.FuliCDKView")--激活码
|
|
require("game.fuli.FuliVipAskView")--询问是否升V的界面
|
|
require("game.fuli.FuliLimitPackageView") --开服限时礼包
|
|
require("game.fuli.FuliLimitPackageItem")
|
|
require("game.fuli.FuliLimitPackageNumItem") --开发限时礼包动画节点
|
|
require("game.fuli.FuliLimitPackageNumTextItem") --开发显示礼包动画文本节点
|
|
require("game.fuli.FuliLimitPackageRewardView") --冲级礼包领取展示
|
|
require("game.fuli.FuliNoticeView") --游戏公告界面
|
|
require("game.fuli.FuliNoticeTab") --游戏公告界面
|
|
|
|
FuliController = FuliController or BaseClass(BaseController)
|
|
function FuliController:__init()
|
|
FuliController.Instance = self
|
|
self.model = FuliModel:getInstance()
|
|
self:InitEvent()
|
|
self:registerAllProtocals()
|
|
end
|
|
|
|
function FuliController:getInstance()
|
|
if FuliController.Instance == nil then
|
|
FuliController.New()
|
|
end
|
|
return FuliController.Instance
|
|
end
|
|
|
|
function FuliController:InitEvent()
|
|
local function onRequestHandler(...)
|
|
local args = {...}
|
|
if args[1] == 16006 or args[1] == 16004 or args[1] == 16010 then
|
|
self:SendFmtToGame(args[1], "c", args[2])
|
|
elseif args[1] == 16009 then
|
|
self:SendFmtToGame(args[1], "sl", args[2], 0)
|
|
else
|
|
self:SendFmtToGame(args[1])
|
|
end
|
|
end
|
|
self.model:Bind(FuliConst.REQ_FULI_SCMD, onRequestHandler)
|
|
|
|
local function init_open_day( ... )--开服天数初始化
|
|
self.model:UpdateFuliLevelActIcon(RoleManager.Instance.mainRoleInfo.level)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
|
|
|
|
local function chnage_day_func(type)
|
|
if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
|
|
self.model:UpdateFuliLevelActIcon(RoleManager.Instance.mainRoleInfo.level)
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func)
|
|
|
|
--升级
|
|
local function onLevelUp(level)
|
|
if level and type(level) == "number" then
|
|
level = level or RoleManager.Instance.mainRoleInfo.level
|
|
--检查升级福利引导图标开启
|
|
self.model:UpdateFuliLevelActIcon(level)
|
|
end
|
|
end
|
|
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
|
|
FuliModel:getInstance():BindOne("fuli_level_info", onLevelUp)
|
|
|
|
local on_open_fuli_main_view = function (index, sub_index, param_list)
|
|
if self.fuli_main_view == nil then
|
|
self.fuli_main_view = FuliMainView.New()
|
|
end
|
|
if self.fuli_main_view:HasOpen() then
|
|
self.fuli_main_view:ReOpen(index, sub_index, param_list)
|
|
else
|
|
self.fuli_main_view:Open(index, sub_index, param_list)
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(FuliConst.OPEN_FULI_MAIN_VIEW, on_open_fuli_main_view)
|
|
|
|
local on_open_fuli_ask_view = function ()
|
|
if self.fuli_ask_view == nil then
|
|
self.fuli_ask_view = FuliVipAskView.New()
|
|
end
|
|
self.fuli_ask_view:Open()
|
|
end
|
|
self.model:Bind(FuliConst.OPEN_FULI_VIP_ASK_VIEW, on_open_fuli_ask_view)
|
|
|
|
local onGameStartHandler = function ()
|
|
self.model:Fire(FuliConst.REQ_FULI_SCMD, 16001)
|
|
self.model:Fire(FuliConst.REQ_FULI_SCMD, 16003)
|
|
self.model:Fire(FuliConst.REQ_FULI_SCMD, 16005)
|
|
self.model:Fire(FuliConst.REQ_FULI_SCMD, 16007)
|
|
end
|
|
self:Bind(EventName.GAME_START, onGameStartHandler)
|
|
local function update_red_dot_by_tab_id_func( tab_id )--主要的更新红点方法
|
|
if not tab_id then
|
|
self.model:IsFuliNeedRedAll()
|
|
else
|
|
self.model:IsFuliNeedRed(tab_id)
|
|
end
|
|
local red_dot = self.model:GetAllFuliRedDot()
|
|
local bool = false
|
|
for i,v in pairs(red_dot) do
|
|
if v then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 16000, bool)
|
|
end
|
|
self.model:Bind(FuliConst.UPDATE_FULI_RED_DOT,update_red_dot_by_tab_id_func)
|
|
|
|
local function onLevelChange(level)
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.LEVEL)
|
|
end
|
|
RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelChange)
|
|
local function onVipChange()
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.SIGN)
|
|
end
|
|
RoleManager:getInstance().mainRoleInfo:BindOne("vip_flag", onVipChange)
|
|
--已下载量,总更新量,当前更新速度,是否已更新完成
|
|
local function update_resourse_state(now_size,all_size,speed,isdone)
|
|
self.model:Fire(FuliConst.SHOW_FULI_DOWN_RES_NUM, now_size, all_size, speed, isdone)
|
|
if isdone then
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.DOWNLOAD)
|
|
StepPackModule:getInstance():SetCallbackFunc(nil)
|
|
end
|
|
end
|
|
StepPackModule:getInstance():SetCallbackFunc(update_resourse_state)
|
|
|
|
local on_open_fuli_limitpackage_view = function ()
|
|
if self.fuli_limit_package_view == nil then
|
|
self.fuli_limit_package_view = FuliLimitPackageView.New()
|
|
end
|
|
if self.fuli_limit_package_view:HasOpen() then
|
|
self.fuli_limit_package_view:ReOpen()
|
|
else
|
|
self.fuli_limit_package_view:Open()
|
|
end
|
|
end
|
|
self.model:Bind(FuliConst.OPEN_FULI_LIMIT_PACKAGE_VIEW, on_open_fuli_limitpackage_view)
|
|
|
|
--打开普通礼包界面
|
|
local function on_open_fuli_limitpackage_reward_view(no)
|
|
if self.fuli_limit_package_reward_view == nil then
|
|
self.fuli_limit_package_reward_view = FuliLimitPackageRewardView.New()
|
|
end
|
|
if self.fuli_limit_package_reward_view:HasOpen() then
|
|
self.fuli_limit_package_reward_view:ReOpen()
|
|
else
|
|
self.fuli_limit_package_reward_view:Open(no)
|
|
end
|
|
end
|
|
self.model:Bind(FuliConst.OPEN_FULI_LIMIT_REWARD_VIEW, on_open_fuli_limitpackage_reward_view)
|
|
|
|
local function CLOSE_SOME_VIEW( )
|
|
if self.fuli_main_view then
|
|
self.fuli_main_view:Close()
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.CLOSE_SOME_VIEW,CLOSE_SOME_VIEW)
|
|
GlobalEventSystem:Bind(FuliConst.CLOSE_FULI_MAIN_VIEW,CLOSE_SOME_VIEW)
|
|
end
|
|
|
|
function FuliController:registerAllProtocals()
|
|
self:RegisterProtocal(16001,"handle16001")--福利大厅-签到状态
|
|
self:RegisterProtocal(16002,"handle16002")--福利大厅-签到
|
|
self:RegisterProtocal(16003,"handle16003")--福利大厅-在线奖励状态
|
|
self:RegisterProtocal(16004,"handle16004")--福利大厅-在线奖励领取
|
|
self:RegisterProtocal(16005,"handle16005")--福利大厅-冲级奖励状态
|
|
self:RegisterProtocal(16006,"handle16006")--福利大厅-领取冲级奖励
|
|
self:RegisterProtocal(16007,"handle16007")--福利大厅-资源下载奖励状态
|
|
self:RegisterProtocal(16008,"handle16008")--福利大厅-领取资源下载奖励奖励
|
|
self:RegisterProtocal(16009,"handle16009")--福利大厅-领取激活码礼包
|
|
self:RegisterProtocal(16010,"handle16010")--福利大厅-领取累计签到奖励
|
|
self:RegisterProtocal(16011,"handle16011")--限时开服礼包
|
|
end
|
|
|
|
function FuliController:handle16001()
|
|
local vo = SCMD16001.New(true)
|
|
local table = TenbyteToTwobyte(vo.cumulative_info)
|
|
vo.total_state = table
|
|
self.model:SetFuliSignInfo(vo)
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.SIGN)
|
|
end
|
|
|
|
function FuliController:handle16002()
|
|
local vo = SCMD16002.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("签到成功~")
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16003()
|
|
local vo = SCMD16003.New(true)
|
|
local table = TenbyteToTwobyte(vo.receive_state)
|
|
vo.my_receive = table
|
|
self.model:SetFuliAIInfo(vo)
|
|
PkRankModel:getInstance():GetOnlineTime()
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.AI)
|
|
end
|
|
|
|
function FuliController:handle16004()
|
|
local vo = SCMD16004.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("奖励领取成功~")
|
|
self.model:Fire(FuliConst.AI_TALK_SHOW, FuliConst.AI_TALK_TYPE.SEND_GIFT)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16005()
|
|
local vo = SCMD16005.New(true)
|
|
local limit_state = {}
|
|
for i,v in ipairs(vo.limit_state) do
|
|
limit_state[v.id] = v.number
|
|
end
|
|
vo.limit_state = limit_state
|
|
local table = TenbyteToTwobyte(vo.receive_state)
|
|
vo.my_receive = table
|
|
self.model:SetFuliLevelInfo(vo)
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.LEVEL)
|
|
self.model:UpdateFuliLevelActIcon(RoleManager.Instance.mainRoleInfo.level)
|
|
end
|
|
|
|
function FuliController:handle16006()
|
|
local vo = SCMD16006.New(true)
|
|
PrintTable(vo)
|
|
if vo.res == 1 then
|
|
Message.show("奖励领取成功~")
|
|
-- if vo.no == 1 then
|
|
-- self.model:Fire(FuliConst.OPEN_FULI_LIMIT_REWARD_VIEW, vo.no)
|
|
-- end
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16007()
|
|
local vo = SCMD16007.New(true)
|
|
self.model:SetFuliDownState(vo.receive_state)
|
|
self.model:Fire(FuliConst.UPDATE_FULI_RED_DOT, FuliConst.TAB_ID.DOWNLOAD)
|
|
end
|
|
|
|
function FuliController:handle16008()
|
|
local vo = SCMD16008.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("奖励领取成功~")
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16009()
|
|
local vo = SCMD16009.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("奖励领取成功~")
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16010()
|
|
local vo = SCMD16010.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("累积签到奖励领取成功~")
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
|
|
function FuliController:handle16011()
|
|
local vo = SCMD16011.New(true)
|
|
self.model.fuli_limit_package_info = vo
|
|
self.model:Fire(FuliConst.FULI_LIMIT_INFO_UPDATE)
|
|
end
|