源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

581 rivejä
23 KiB

require("game.proto.173.Require173")
require("game.god.GodModel")
require("game.god.GodConst")
require("game.god.view.GodBaseView")
require("game.god.view.GodSubView")
require("game.god.view.GodEquipBaseView")
require("game.god.view.GodEquipTipView")
require("game.god.view.GodAttrItem")
require("game.god.view.GodBagView")
require("game.god.view.GodBookTabItem")
require("game.god.view.GodBookView")
require("game.god.view.GodEquipAwrdItem")
require("game.god.view.GodEquipItem")
require("game.god.view.GodGoFightView")
require("game.god.view.GodGuardTabItem")
require("game.god.view.GodGuardView")
require("game.god.view.GodIconItem")
require("game.god.view.GodInfoItemSquare")
require("game.god.view.GodSelectView")
require("game.god.view.GodSkillItem")
require("game.god.view.GodSuitBookItem")
require("game.god.view.GodTabItem")
require("game.god.view.GodUnlockPosView")
require("game.god.view.GodInfoShowView")--神座展示界面
require("game.god.view.GodAttrThreeItem")
require("game.god.view.GodAttrFourItem")
require("game.god.view.GodGoFightModelItem")
require("game.god.view.GodStarUpgradeView") -- 升星界面
require("game.GodActivity.GodActivityBaseView")
require("game.GodActivity.GodActivityCommonView")
require("game.GodActivity.GodActivityLimitView")
require("game.GodActivity.GodActivityRewardItem")
require("game.GodActivity.GodActivityResultView")
require("game.GodActivity.GodActivityEffectView")
-------------------------
require("game.god.view.GodEquipSubView")--神座装备页签
require("game.god.view.GodActiveView")--新神座激活界面
require("game.god.view.GodSkillUpGradeView")--神座技能升级界面
require("game.god.view.GodSuccessView")--升星成功界面
require("game.god.view.GodAttrSixItem")--神座属性条目
require("game.god.view.GodFightGuardView")--神座上阵以及护佑界面
require("game.god.view.GodEquipUpgradeView")--神座装备升级界面
require("game.god.view.GodEquipSuitItem")--神座装备套装条目
require("game.god.view.GodEquipSuitItemTwo")--神座装备套装条目2
require("game.god.view.GodAttrEightItem")
require("game.god.view.GodPreviewView") -- 奖励详情
require("game.god.view.GodPreviewItem") --奖励详情
-------------------------
GodController = GodController or BaseClass(BaseController, true)
local GodController = GodController
function GodController:__init()
GodController.Instance = self
self.model = GodModel:getInstance()
self:AddEvents()
self:RegisterAllProtocal()
end
function GodController:__delete()
end
function GodController:RegisterAllProtocal( )
local register_cfg = {
[17301] = {-- 神座信息
req_event_data = {GodConst.REQ_BASE_INFO},req_func = false,
handler = function(self,scmd)
self.model:SetGodBaseData(scmd)
self.model:SetSlotUnlockInfo(scmd.unlock)
self:GodCheckRedDot()
self.model:Fire(GodConst.ANS_BASE_INFO)
end,
},
[17302] = {-- 神座信息:单条刷新
req_event_data = {GodConst.REQ_ONE_GOD_INFO,"h"},req_func = false,
handler = function(self,scmd)
self.model:SetOneGodData(scmd)
self:GodCheckRedDot()
self.model:Fire(GodConst.ANS_ONE_GOD_INFO, scmd.id, scmd.pos)
if self.need_show_star_up_success then
self.model:Fire(GodConst.OPEN_UP_SUCCESS_VIEW, scmd.id, scmd.star, scmd.lv)
self.need_show_star_up_success = nil
end
if self.need_show_active_success then
self.model:Fire(GodConst.OPEN_ACTIVE_VIEW, scmd.id, scmd.star, scmd.lv)
self.need_show_active_success = nil
end
end,
},
[17303] = {-- 神座操作:激活
req_event_data = {GodConst.REQ_GOD_ACITVE, "h"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("激活成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.need_show_active_success = true
self.model:Fire(GodConst.REQ_ONE_GOD_INFO,scmd.id)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17304] = {-- 神座操作:升星
req_event_data = {GodConst.REQ_GOD_UP_STAR,"h"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("升星成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.need_show_star_up_success = true
self.model:Fire(GodConst.REQ_ONE_GOD_INFO,scmd.id)
elseif scmd.res == 1730004 then
local _,_,need_lv = self.model:IsGodCanUpStar( scmd.id )
if need_lv then
lua_soundM:PlayEffect(LuaSoundManager:getInstance(), "fault", false, LuaSoundManager.SOUND_TYPE.UI)
Message.show(string.format("需要神座等级达到 %d 级",need_lv))
else
ErrorCodeShow(scmd.res)
end
else
ErrorCodeShow(scmd.res)
end
end,
},
[17305] = {-- 神座操作:升级
req_event_data = {GodConst.REQ_GOD_UP_LV,"hcii"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("升级成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
local temp = self.model:GetGodInfoById(scmd.id)
if temp then
temp.lv = scmd.lv
temp.exp = scmd.exp
end
self:GodCheckRedDot()
self.model:Fire(GodConst.ANS_GOD_UP_LV, scmd.id, scmd.is_up_lv)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17306] = {--神座操作:技能升级
req_event_data = {GodConst.REQ_GOD_UP_SKILL, "hi"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("升级成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
local temp = self.model:GetGodInfoById(scmd.id)
if temp then
for k,v in pairs(temp.skill) do
if v.skill_id == scmd.skill_id then
v.skill_lv = scmd.skill_lv
break
end
end
end
self:GodCheckRedDot()
self.model:Fire(GodConst.ANS_GOD_UP_SKILL, scmd.id)
self.model:Fire(GodConst.OPEN_SKILL_UP_SUCCESS, scmd.id, scmd.skill_id, scmd.skill_lv)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17307] = {--神座操作:穿戴装备
req_event_data = {GodConst.REQ_GOD_DRESS_EQUIP, "hcl"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("穿戴成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.model:Fire(GodConst.ANS_GOD_DRESS_EQUIP)
self.model:Fire(GodConst.BOARD_EFFECT_EVENT,"up_equip",scmd.pos)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17308] = {--神座操作:装备卸下
req_event_data = {GodConst.REQ_GOD_DOWN_EQUIP, "hc"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("操作成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.model:Fire(GodConst.ANS_GOD_DOWN_EQUIP)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17309] = {--神座操作:装备升级
req_event_data = {GodConst.REQ_STREN_EQUIP}, req_func = function(self,goods_id,cost_list)
self:WriteBegin(17309)
self:WriteFMT("l", goods_id)
self:WriteFMT("h", #cost_list)
for k, v in pairs(cost_list) do
self:WriteFMT("l", v.goods_id)
self:WriteFMT("h", 1)
end
self:SendToGame()
end,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("升级成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.model:Fire(GodConst.ANS_STREN_EQUIP)
self.model:Fire(GodConst.BOARD_EFFECT_EVENT,"stren_equip")
else
ErrorCodeShow(scmd.res)
end
end,
},
[17310] = {--神座操作:解锁位置
req_event_data = {GodConst.REQ_UNLOCK_POS, "h"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("解锁成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.model:Fire(GodConst.REQ_BASE_INFO)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17311] = {--神座操作:上阵
req_event_data = {GodConst.REQ_INFO_FIGHT, "hh"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("上阵成功")
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
self.model:Fire(GodConst.REQ_BASE_INFO)
self.model:Fire(GodConst.BOARD_EFFECT_EVENT,"up_fight",scmd.pos)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17312] = {--神座信息:上次召唤时间戳
req_event_data = {GodConst.REQ_LAST_USE_TIME},req_func = false,
handler = function(self,scmd)
-- self.model:SetBecomeGodTime(scmd.time)
-- self.model:SetCanBecomeGodTime(scmd.time + self.model:GetBecomeGodCD())
self.model:SetBecomeGodTime(scmd.summon_list)
self.model:Fire(GodConst.ANS_LAST_USE_TIME)
print('=======Msh:GodController.lua[265] ===TABLE====')
PrintTable(scmd)
end,
},
[17313] = {--神座操作:召唤出战/重复点击切换下一个
req_event_data = {GodConst.REQ_CALL_GOD, "h"},req_func = false,
handler = function(self,scmd)
print('=======Msh:GodController.lua[272] ===TABLE====', scmd.res, scmd.god_id)
if scmd.res ~= 1 then
ErrorCodeShow(scmd.res)
else
self.model:Fire(GodConst.ANS_CALL_GOD)
end
end,
},
--[[ [17314] = {--普通抽奖信息
req_event_data = {GodConst.REQ_ACTIVITY_COMMON_INFO},req_func = false,
handler = function(self,scmd)
self.model:SetActivityCommonInfo(scmd)
self.model:Fire(GodConst.ANS_ACTIVITY_COMMON_INFO)
self:GodCheckRedDot()
end,
},--]]
[17315] = {--限时抽奖信息
req_event_data = {GodConst.REQ_ACTIVITY_LIMIT_INFO},req_func = false,
handler = function(self,scmd)
self.model:SetActivityLimitInfo(scmd)
self.model:Fire(GodConst.ANS_ACTIVITY_LIMIT_INFO)
self:GodCheckRedDot()
end,
},
[17316] = {--抽奖
req_event_data = {GodConst.REQ_ACTIVITY_PLAY,"cc"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
if scmd.pool_type == GodConst.ActivityType.Common then
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
else
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
end
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
-------------------------
local data = {}
data.pool_type = GodConst.ActivityType.Limit -- 只有限时抽奖了
data.type = scmd.type
data.award = {}
data.col_num = 5
for k, v in pairs(scmd.award_list) do
data.award[#data.award+1] = {0,v.goods_id,v.goods_num}
end
-- GiftModel:getInstance():Fire(GiftModel.OPEN_SHOW_ACT_GOODS_VIEW, data.award)
self.model:Fire(GodConst.ANS_ACTIVITY_PLAY, data.pool_type, scmd.type, data)
else
if scmd.res == 1001 then
GlobalEventSystem:Fire(EventName.OPEN_RECHARGE_TIP_VIEW, true)
else
ErrorCodeShow(scmd.res)
end
end
end,
},
[17317] = {--领取保底奖励
req_event_data = {GodConst.REQ_ACTIVITY_GET_MIN_AWARD,"c"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("领取成功!")
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17318] = {--领取累计奖励
req_event_data = {GodConst.REQ_ACTIVITY_GET_NUM_AWARD,"c"},req_func = false,
handler = function(self,scmd)
if scmd.res == 1 then
Message.show("领取成功!")
if scmd.pool_type == GodConst.ActivityType.Common then
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
else
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
end
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.res)
end
end,
},
[17319] = {--神座操作:变身广播
handler = function(self,scmd)
Scene:getInstance():GodChange(scmd)
print('=======Msh:GodController.lua[359] ===TABLE=玩家god_id变更==17319=', scmd.role_id, scmd.god_id)
-- PrintTable(scmd)
end,
},
[17320] = {--抽奖活动状态变更
handler = function(self,scmd)
if scmd.type == GodConst.ActivityType.Common then
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
elseif scmd.type == GodConst.ActivityType.Limit then
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
end
end,
},
[17321] = {--抽奖每日免费剩余次数
req_event_data = {GodConst.REQ_GOD_LEFT_FREE_DRAW},req_func = false,
handler = function(self,scmd)
self.model:SetGodLeftFreeDrawTimes(scmd)
self:GodCheckRedDot()
end,
},
}
self:RegisterProtocalByCFG(register_cfg)
end
function GodController:AddEvents()
local function on_game_start()
self.model:Reset()
local function delay( )
if GetModuleIsOpen(173,1) then
self.model:Fire(GodConst.REQ_BASE_INFO)
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
self.model:Fire(GodConst.REQ_GOD_LEFT_FREE_DRAW)
end
-- if GetModuleIsOpen(173,4) then
-- end
end
setTimeout(delay,2)
end
GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
local function onLevelChange( level )
local lv = GetModuleOpenLevel( 173,1,true)
if lv == level then
self.model:Fire(GodConst.REQ_BASE_INFO)
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
self.model:Fire(GodConst.REQ_GOD_LEFT_FREE_DRAW)
end
-------------------------
-- local lv = GetModuleOpenLevel( 173,4,true)
-- if lv == level then
-- end
end
RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelChange)
--任务完成检测神座开启
local function onTaskFinishHandler(taskId)
local god_task_id = self.model:GetOpenTask(nil,true)
if taskId then
if god_task_id ~= 0 and taskId == god_task_id then
self.model:Fire(GodConst.REQ_BASE_INFO)
-- self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
self.model:Fire(GodConst.REQ_ACTIVITY_LIMIT_INFO)
end
end
end
GlobalEventSystem:Bind(TaskEventType.TASK_SUCCESS, onTaskFinishHandler)
local function OPEN_BASE_VIEW( main_id,sub_id )
self.godbaseview = self.godbaseview or GodBaseView.New()
if self.godbaseview:HasOpen() then
self.godbaseview:ReOpen(main_id,sub_id)
else
self.godbaseview:Open(main_id,sub_id)
end
end
self.model:Bind(GodConst.OPEN_BASE_VIEW,OPEN_BASE_VIEW)
local function OPEN_ACTIVITY_EFFECT_VIEW( data )
if not self.godactivityeffectview then
self.godactivityeffectview = self.godactivityeffectview or GodActivityEffectView.New()
self.godactivityeffectview:Open(data)
end
end
self.model:Bind(GodConst.OPEN_ACTIVITY_EFFECT_VIEW,OPEN_ACTIVITY_EFFECT_VIEW)
local function OPEN_ACTIVITY_RESULT_VIEW( result_data )
self.godactivityresultview = self.godactivityresultview or GodActivityResultView.New()
-- if self.godactivityresultview:HasOpen() then
-- self.godactivityresultview:ReOpen(main_id,sub_id)
-- else
self.godactivityresultview:Open(result_data)
-- end
end
self.model:Bind(GodConst.OPEN_ACTIVITY_RESULT_VIEW,OPEN_ACTIVITY_RESULT_VIEW)
local function OpenEquipTipView( data_1,data_2,tag )
--要传入背包的信息!!!!
if not data_1 and not data_2 then return end
if not self.godequipbaseview then
self.godequipbaseview = GodEquipBaseView.New()
self.godequipbaseview:Open(data_1,data_2,tag)
end
end
self.model:Bind(GodConst.OpenEquipTipView,OpenEquipTipView)
local function CloseEquipTipView( )
if self.godequipbaseview then
self.godequipbaseview:Close()
end
end
self.model:Bind(GodConst.CloseEquipTipView,CloseEquipTipView)
local function OPEN_GOD_INFO_VIEW( god_id )
if not god_id then return end
if not self.godinfoshowview then
self.godinfoshowview = GodInfoShowView.New()
self.godinfoshowview:Open(god_id)
end
end
self.model:Bind(GodConst.OPEN_GOD_INFO_VIEW,OPEN_GOD_INFO_VIEW)
local function OPEN_UP_SUCCESS_VIEW( god_id, star, lv )
if (not god_id) or (not star) or (not lv) then return end
if not self.godsuccessview then
self.godsuccessview = GodSuccessView.New()
self.godsuccessview:Open( god_id, star, lv )
end
end
self.model:Bind(GodConst.OPEN_UP_SUCCESS_VIEW,OPEN_UP_SUCCESS_VIEW)
local function OPEN_ACTIVE_VIEW( god_id, star, lv )
if (not god_id) or (not star) or (not lv) then return end
if not self.godactiveview then
self.godactiveview = GodActiveView.New()
self.godactiveview:Open( god_id, star, lv )
end
end
self.model:Bind(GodConst.OPEN_ACTIVE_VIEW,OPEN_ACTIVE_VIEW)
local function OPEN_SKILL_UP_SUCCESS( god_id, skill_id, skill_lv )
if (not god_id) or (not skill_id) or (not skill_lv) then return end
if not self.godskillupgradeview then
self.godskillupgradeview = GodSkillUpGradeView.New()
self.godskillupgradeview:Open( god_id, skill_id, skill_lv )
end
end
self.model:Bind(GodConst.OPEN_SKILL_UP_SUCCESS,OPEN_SKILL_UP_SUCCESS)
local function OPEN_FIGHT_AND_GUARD_VIEW( pos,sub_pos,is_close )
if is_close then
if self.godfightguardview then
self.godfightguardview:Close()
end
return
end
pos = pos or 1
if not self.godfightguardview then
self.godfightguardview = GodFightGuardView.New()
self.godfightguardview:Open( pos )
end
end
self.model:Bind(GodConst.OPEN_FIGHT_AND_GUARD_VIEW,OPEN_FIGHT_AND_GUARD_VIEW)
local function OPEN_EQUIP_UPGRADE_VIEW( goods_vo )
if not goods_vo then return end
if not self.godequipupgradeview then
self.godequipupgradeview = GodEquipUpgradeView.New()
self.godequipupgradeview:Open( goods_vo )
end
end
self.model:Bind(GodConst.OPEN_EQUIP_UPGRADE_VIEW,OPEN_EQUIP_UPGRADE_VIEW)
local function OPEN_STAR_UPGRADE_VIEW( god_id )
if not god_id then return end
if not self.godstarupgradeview then
self.godstarupgradeview = GodStarUpgradeView.New()
self.godstarupgradeview:Open( god_id )
end
end
self.model:Bind(GodConst.OPEN_STAR_UPGRADE_VIEW, OPEN_STAR_UPGRADE_VIEW)
self.model:Bind(GodConst.UpdateGodEquipBagListChange, function()
self:GodCheckRedDot()
end)
-- 如果激活了神座免费抽奖相关的宠物生活技能,则需要主动请求17321
local function on_pet_life_skill_actived(skill_id)
if skill_id == PetConst.LifeSkill.GalaxyFreeSummon then
self.model:Fire(GodConst.REQ_GOD_LEFT_FREE_DRAW)
end
end
PetModel:getInstance():Bind(PetConst.PET_LIFE_SKILL_ACTIVED, on_pet_life_skill_actived)
local function chnage_day_func(type)
if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
self.model:Fire(GodConst.REQ_GOD_LEFT_FREE_DRAW)
end
end
GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func)
local function openPerviewView(show)
if show then
self:OpenView("GodPreviewView", show)
end
end
self.model:Bind(GodConst.OPEN_PREVIEW_VIEW, openPerviewView)
end
function GodController:GodCheckRedDot( )
local function call_backack( )
local need_red = self.model:IsNeedRedAll()
GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 173, need_red)
self.model:Fire(GodConst.UpdateRedDot)
end
TimeManager.GetInstance():StartTime("GodController_GodCheckRedDot", 0.25, call_backack)
end