源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

243 行
7.3 KiB

-- require("game.proto.416.Require416")
require("game.hopeGift.HopeGiftConst")
require("game.hopeGift.HopeGiftModel")
require("game.hopeGift.view.HopeGiftMainView")--臻享礼包主界面
require("game.hopeGift.view.HopeGiftMainTab")--明日之主界面页签
require("game.hopeGift.view.HopeGiftMainSubTab")--明日之主界面子页签
require("game.hopeGift.view.HopeGiftSubView")--臻享礼包子界面
require("game.hopeGift.view.HopeGiftAwardShowView")--臻享礼包奖励展示界面
require("game.hopeGift.view.HopeGiftAwardShowItem")--臻享礼包奖励展示item
require("game.hopeGift.view.HopeGiftMainAwardCon")--臻享礼包奖励动画奖励Con
require("game.hopeGift.view.HopeGiftMainModelItem")--臻享礼包模型展示item
HopeGiftController = HopeGiftController or BaseClass(BaseController)
HopeGiftController.Is_Debug = false
function HopeGiftController:__init()
HopeGiftController.Instance = self
self.model = HopeGiftModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self:RegisterAllProtocals()
self:AddAllEvents()
end
function HopeGiftController:__delete()
end
function HopeGiftController:AddAllEvents()
local function game_start_func()
end
GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
local onHopeGiftAwardShowView = function (sub_type)
if self.HopeGiftAwardShowView == nil then
self.HopeGiftAwardShowView = HopeGiftAwardShowView.New()
end
if self.HopeGiftAwardShowView:HasOpen() then
else
self.HopeGiftAwardShowView:Open(sub_type)
end
end
self.model:Bind(HopeGiftModel.OPEN_HOPE_GIFT_AWARD_SHOW_VIEW, onHopeGiftAwardShowView)
-- local function CheckRedPoint( ... )
-- end
-- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
local function change_day_func(type)
if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
local base_type = CustomActivityModel.CustomActBaseType.HOPE_GIFT
local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
for k, v in pairs(act_list) do
self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,v.sub_type)
end
end
end
GlobalEventSystem:Bind(EventName.CHANE_DAY, change_day_func)
local function request_info(request_id , ... )
if not HopeGiftController.Is_Debug then
local fun_name = string.format("send%s",request_id)
if self[fun_name] then
print('----in HopeGiftController.lua,line 44 request_id',request_id , ...)
self[fun_name](self,...)
end
elseif request_id == 33136 or request_id == 33137 or request_id == 33138 then
local fun_name = string.format("handle%s",request_id)
if self[fun_name] then
print('----in HopeGiftController.lua,line 96 request_idIs_Debug',request_id , ...)
self[fun_name](self,...)
end
end
end
self.model:Bind(HopeGiftModel.REQUEST_INFO,request_info)
local function init_open_day( ... )--开服天数初始化
end
GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
--升级
local function onLevelUp(level)
end
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
local updateInfo = function (base_type,sub_type)
if base_type == CustomActivityModel.CustomActBaseType.HOPE_GIFT then
self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,sub_type)
end
end
CustomActivityModel:getInstance():Bind(CustomActivityModel.UPDATE_ACTIVITY_INFO,updateInfo)
end
function HopeGiftController:RegisterAllProtocals()
self:RegisterProtocal(33136, "handle33136") -- 臻享礼包:轮次信息
self:RegisterProtocal(33137, "handle33137") -- 臻享礼包:领取钥匙
self:RegisterProtocal(33138, "handle33138") -- 臻享礼包:抽奖
end
-- ################# 臻享礼包:轮次信息 ############
-- protocol=33136
-- {
-- c2s{
-- sub_type:int8 // 定制活动子类型
-- }
-- s2c{
-- sub_type:int8 // 定制活动子类型
-- round:int8 // 当前抽奖轮次
-- day_lucky_limit:int8 // 今日抽奖上限:0否1是
-- already_get_list:array{
-- grade_id:int8 // 每个档位ID
-- get_num:int16 // 当前已领取钥匙数量
-- status:int8 // 今日领取钥匙状态1已领取0未领取
-- }
-- get_id:array{
-- award_id:int16 // 当前轮次已经抽取到的奖励id
-- }
-- }
-- }
function HopeGiftController:send33136(sub_type)
self:SendFmtToGame(33136,"c",sub_type)
end
function HopeGiftController:handle33136()
local scmd = {}
if not HopeGiftController.Is_Debug then
scmd = SCMD33136.New(true)
else
scmd = {
sub_type = 1,
round = 1,
}
local already_get_list = {}
for i=1,4 do
already_get_list[i] = {}
already_get_list[i].grade_id = i
already_get_list[i].get_num = 0
already_get_list[i].status = 0
end
scmd.already_get_list = already_get_list
local get_id = {}
for i=1,10 do
-- get_id[i] = {}
-- get_id[i].award_id = i
end
scmd.get_id = get_id
end
self.model:SetHopeGiftInfo(scmd)
VipModel:getInstance():IsNeedRed(VipModel.TabType.HopeGift,nil,scmd.sub_type)
-- print("huangcong:HopeGiftController [117]: ",scmd.day_lucky_limit)
-- PrintTable(scmd)
end
-- ################# 臻享礼包:领取钥匙 ############
-- protocol=33137
-- {
-- c2s{
-- sub_type:int8 // 定制活动子类型
-- }
-- s2c{
-- res:int32
-- sub_type:int8 // 定制活动子类型
-- }
-- }
function HopeGiftController:send33137(sub_type)
self:SendFmtToGame(33137,"c",sub_type)
end
function HopeGiftController:handle33137()
local scmd = {}
if not HopeGiftController.Is_Debug then
scmd = SCMD33137.New(true)
else
scmd = {}
end
if scmd.res == 1 then
local goods_name = GoodsModel:getInstance():getGoodsName(self.model.cost_id, true)
local str = string.format("获得 %s x%s",goods_name,self.model.return_day_sum_num)
Message.show(str,"success")
self.model:SetHopeGiftIsAction(false,scmd.sub_type)
self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,scmd.sub_type)
else
ErrorCodeShow(scmd.res)
end
-- print("huangcong:HopeGiftController [117]: ",scmd)
-- PrintTable(scmd)
end
-- ################# 臻享礼包:抽奖 ############
-- protocol=33138
-- {
-- c2s{
-- sub_type:int8 // 定制活动子类型
-- num:int8 // 抽奖次数
-- }
-- s2c{
-- res:int32
-- sub_type:int8 // 定制活动子类型
-- day_lucky_limit:int8 // 今日抽奖上限:0否1是
-- get_id:array{
-- award_id:int16 // 抽取到的奖励id
-- }
-- }
-- }
function HopeGiftController:send33138(sub_type,num)
self:SendFmtToGame(33138,"cc",sub_type,num)
end
function HopeGiftController:handle33138()
local scmd = {}
if not HopeGiftController.Is_Debug then
scmd = SCMD33138.New(true)
else
scmd = {
res = 1,
sub_type = 1,
}
local get_id = {}
for i=1,1 do
get_id[i] = {}
get_id[i].award_id = 9
end
scmd.get_id = get_id
end
-- print("huangcong:HopeGiftController [start:213] :", scmd)
-- PrintTable(scmd)
-- print("huangcong:HopeGiftController [end]")
if scmd.res == 1 then
self.model:Fire(HopeGiftModel.UPDATE_LUCKY_INFO,scmd.get_id,scmd.sub_type)
else
self.model:SetHopeGiftIsAction(false,scmd.sub_type)
ErrorCodeShow(scmd.res)
end
-- print("huangcong:HopeGiftController [117]: ",scmd)
-- PrintTable(scmd)
end