源战役客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

215 Zeilen
6.8 KiB

--礼包功能
require("game.Gift.GiftModel")
require("game.Gift.GiftNormalView")
require("game.Gift.GiftNormalItem")
require("game.Gift.GiftDiamondView")
require("game.Gift.GiftOptionalView")
require("game.Gift.GiftOptionalItem")
require("game.Gift.GiftShowAllView")
require("game.Gift.VipActiveGiftView")
require("game.Gift.GiftActNormalView")--活动通用奖励界面
require("game.Gift.GiftActNormalItem")--活动通用奖励界面Item
GiftController = GiftController or BaseClass(BaseController)
function GiftController:__init()
GiftController.Instance = self
self.model = GiftModel:getInstance()
self:addAllEvents()
self:registerAllProtocals()
end
function GiftController:addAllEvents()
--打开展示物品界面
local function openShowGoodsView(goods_vo)
self.model.is_show_reward_view = true
if self.show_goods_view == nil then
self.show_goods_view = GiftNormalView.New()
end
if not self.show_goods_view:HasOpen() then
self.show_goods_view:Open(goods_vo)
end
end
self.model:Bind(GiftModel.OPEN_SHOW_GOODS_VIEW, openShowGoodsView)
--打开活动展示物品界面
local function openGiftActNormalView(goods_list,only_read_goods_type_id)
self.model.is_show_reward_view = true
if self.GiftActNormalView == nil then
self.GiftActNormalView = GiftActNormalView.New()
end
if not self.GiftActNormalView:HasOpen() then
self.GiftActNormalView:Open(goods_list,only_read_goods_type_id)
end
end
self.model:Bind(GiftModel.OPEN_SHOW_ACT_GOODS_VIEW, openGiftActNormalView)
--打开普通礼包界面
local function openNormalView(goods_vo)
local kind, list = self.model:getGiftConfig(goods_vo.type_id)
if kind == 0 then
Message.show("所选物品不是礼包")
return
end
if list.max_count > 0 then
local now_times = self.model.gift_use_times[list.gift_id] or 0
if now_times >= list.max_count then
Message.show("次数已达上限")
return
end
end
GlobalEventSystem:Fire(EventName.CLOSE_COM_AWARD_RESULT_VIEW)
self.model.is_show_reward_view = true
if self.gift_normal_view == nil then
self.gift_normal_view = GiftNormalView.New()
end
if not self.gift_normal_view:HasOpen() then
self.gift_normal_view:Open(goods_vo)
end
-- local data = {}
-- data.award = {}
-- data.type_id = goods_vo.type_id
-- for i,v in ipairs(goods_vo.show_goods) do
-- data.award[#data.award+1] = {v.type, v.goodid, v.gnum, is_rare = 0, goodid = v.goodid }
-- end
-- GlobalEventSystem:Fire(EventName.OPEN_COM_AWARD_RESULT_VIEW, data)
end
self.model:Bind(GiftModel.OPEN_NORMAL_VIEW, openNormalView)
--关闭普通礼包界面
local function closeNormalView()
if self.gift_normal_view and self.gift_normal_view:HasOpen() then
self.gift_normal_view:Close()
end
self.gift_normal_view = nil
end
self.model:Bind(GiftModel.CLOSE_NORMAL_VIEW, closeNormalView)
--打开自选礼包界面
local function openOptionalView(goods_vo)
if self.gift_optional_view == nil then
self.gift_optional_view = GiftOptionalView.New()
end
if not self.gift_optional_view:HasOpen() then
self.gift_optional_view:Open(goods_vo)
end
end
self.model:Bind(GiftModel.OPEN_OPTIONAL_VIEW, openOptionalView)
--关闭自选礼包界面
local function closeOptionalView()
if self.gift_optional_view and self.gift_optional_view:HasOpen() then
self.gift_optional_view:Close()
end
self.gift_optional_view = nil
end
self.model:Bind(GiftModel.CLOSE_OPTIONAL_VIEW, closeOptionalView)
--打开彩钻礼包界面
local function openDiamondView(goods_vo)
local kind, list = self.model:getGiftConfig(goods_vo.type_id)
if kind == 0 then
Message.show("所选物品不是礼包")
return
end
if list.max_count > 0 then
local now_times = self.model.gift_use_times[list.gift_id]
if now_times >= list.now_times then
Message.show("已超过使用次数")
return
end
end
if self.gift_diamond_view == nil then
self.gift_diamond_view = GiftDiamondView.New()
end
if not self.gift_diamond_view:HasOpen() then
self.gift_diamond_view:Open(goods_vo)
end
end
self.model:Bind(GiftModel.OPEN_DIAMOND_VIEW, openDiamondView)
--关闭彩钻礼包界面
local function closeDiamondView()
if self.gift_diamond_view and self.gift_diamond_view:HasOpen() then
self.gift_diamond_view:Close()
end
self.gift_diamond_view = nil
end
self.model:Bind(GiftModel.CLOSE_DIAMOND_VIEW, closeDiamondView)
--打开不够天数查看奖励界面
local function openShowAllView(type_id, need_day)
if self.gift_show_all_view == nil then
self.gift_show_all_view = GiftShowAllView.New()
end
if not self.gift_show_all_view:HasOpen() then
self.gift_show_all_view:Open(type_id, need_day)
end
end
self.model:Bind(GiftModel.OPEN_SHOW_ALL_VIEW, openShowAllView)
--关闭不够天数查看奖励界面
local function closeShowAllView()
if self.gift_show_all_view and self.gift_show_all_view:HasOpen() then
self.gift_show_all_view:Close()
end
self.gift_show_all_view = nil
end
self.model:Bind(GiftModel.CLOSE_SHOW_ALL_VIEW, closeShowAllView)
local function onSendCmdFunc( ... )
local args_list = {...}
if args_list[1] == 15085 then --礼包每天使用次数
self:SendFmtToGame(args_list[1], "i", args_list[2])
elseif args_list[1] == 15086 then --领取自选礼包物品内容
self:WriteBegin(args_list[1])
self:WriteFMT("l", args_list[2])
self:WriteFMT("i", args_list[3])
self:WriteFMT("i", args_list[4])
self:WriteFMT("h", #args_list[5])
for i, v in ipairs(args_list[5]) do
self:WriteFMT("c", v.seqno)
self:WriteFMT("h", v.seqnum)
end
self:SendToGame()
end
end
self.model:Bind(GiftModel.PROTO_CCMD_EVENT, onSendCmdFunc)
local function open_vip_gift_view(type_id,goods_id)
if not self.VipActiveGiftView then
self.VipActiveGiftView = VipActiveGiftView.New()
end
self.VipActiveGiftView:Open(type_id,goods_id)
end
GlobalEventSystem:Bind(EventName.OPEN_VIP_GIFT_CODE_VIEW,open_vip_gift_view)
end
function GiftController:registerAllProtocals()
self:RegisterProtocal(15085, "Handler15085")
self:RegisterProtocal(15086, "Handler15086")
end
--礼包每天使用次数
function GiftController:Handler15085()
local vo = SCMD15085.New(true)
--print("=============>>> YiRan:GiftController [start:174] vo Handler15085------------------------------------------")
--PrintTable(vo)
--print("=============>>> YiRan:GiftController [end] ------------------------------------------")
self.model:saveGiftUseTimes(vo)
end
--领取自选礼包物品内容
function GiftController:Handler15086()
local vo = SCMD15086.New(true)
---print("=============>>> YiRan:GiftController [start:180] vo15086 ------------------------------------------")
--PrintTable(vo)
--print("=============>>> YiRan:GiftController [end] ------------------------------------------")
if vo.code == 1 then
Message.show("领取成功")
GiftModel:getInstance():Fire(GiftModel.CLOSE_OPTIONAL_VIEW)
else
ErrorCodeShow(vo.code)
end
end