|
|
- require("game.proto.143.Require143")
- require("game.warSoul.WarSoulModel")
- require("game.warSoul.WarSoulConst")
-
- --战魂主界面
- require("game.warSoul.view.WarSoulBaseView")
-
- --战魂上阵
- require("game.warSoul.view.wear.WarSoulWearView")--战魂上阵主界面
- require("game.warSoul.view.wear.WarSoulSuitView")--战魂阵法套装界面
- require("game.warSoul.view.wear.WarSoulSuitItem")--战魂阵法套装item
- require("game.warSoul.view.wear.WarSoulWearGoodsTipView")--战魂道具tips
- require("game.warSoul.view.wear.WarSoulWearGoodsTipCompareView")--战魂道具tips对比界面
- require("game.warSoul.view.wear.WarSoulWearGoodsTipAttrItem")--战魂道具tips属性item
- require("game.warSoul.view.wear.WarSoulWearBagView")--战魂上阵背包界面
- require("game.warSoul.view.wear.WarSoulWearBagItem")--战魂上阵背包格子
- require("game.warSoul.view.wear.WarSoulSkillItem")--战魂技能图标
- require("game.warSoul.view.wear.WarSoulAttrItem")--战魂属性item
- require("game.warSoul.view.wear.WarSoulWearBagNewItem")--战魂背包上阵item
-
- --战魂背包
- require("game.warSoul.view.bag.WarSoulMainStrengthView")--战魂强化总览
- require("game.warSoul.view.bag.WarSoulBagAttrItem")--战魂背包属性item
- require("game.warSoul.view.bag.WarSoulBagItem")--战魂背包item
- require("game.warSoul.view.bag.WarSoulBagSpliteView")--战魂背包分解界面
- require("game.warSoul.view.bag.WarSoulStrengthAttrItem")--战魂等级强化属性item
- require("game.warSoul.view.bag.WarSoulStrengthBackView")--战魂强化回退
-
- --战魂进化
- require("game.warSoul.view.evolution.WarSoulMainEvolutionView")--战魂进化主界面
- require("game.warSoul.view.evolution.WarSoulEvoItem")--战魂进化item
- require("game.warSoul.view.evolution.WarSoulEvoSuccessView")--战魂进化成功界面
- require("game.warSoul.view.evolution.WarSoulEvoSuccessAttrItem")--战魂进化成功界面Item
- require("game.warSoul.view.evolution.WarSoulEvolutionlvView")--战魂进化升级界面
- require("game.warSoul.view.evolution.WarSoulEvolutionlvItem")--战魂进化item
- require("game.warSoul.view.evolution.WarSoulEvolutionChooseView")--战魂进化背包选择界面
- require("game.warSoul.view.evolution.WarSoulEvoView")--战魂背包进化路线
-
-
-
- --战魂图鉴
- require("game.warSoul.view.pictrue.WarSoulPictrueView")--战魂图鉴主界面
- require("game.warSoul.view.pictrue.WarSoulPictrueItem")--战魂图鉴item
- require("game.warSoul.view.pictrue.WarSoulPictrueBoxItem")--战魂图鉴宝箱
- require("game.warSoul.view.pictrue.WarSoulPictrueAwardTipView")--战魂图鉴奖励提示界面
-
-
- WarSoulController = WarSoulController or BaseClass(BaseController)
- WarSoulController.Is_Debug = false
- function WarSoulController:__init()
- WarSoulController.Instance = self
- self.model = WarSoulModel:getInstance()
- self.mainVo = RoleManager.Instance.mainRoleInfo
- self:EnableCheckoutClear()
- self:RegisterAllProtocals()
- self:AddAllEvents()
- self.is_delay_check = false--红点刷新防止重复刷新的键值
- end
-
- function WarSoulController:getInstance()
- if WarSoulController.Instance == nil then
- WarSoulController.Instance = WarSoulController.New()
- end
- return WarSoulController.Instance
- end
-
- function WarSoulController:__delete()
-
- end
-
- function WarSoulController:AddAllEvents()
- local function game_start_func()
- end
- GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
-
- -- local function CheckRedPoint( ... )
-
- -- end
- -- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
-
- local function onSceneStartHandler()
-
- end
- self:Bind(SceneEventType.SCENE_CHANGED, onSceneStartHandler)
-
- --请求协议
- local function onRequestProtocal(...)
- local args = {...}
- if args[1] == 14301 then
- self.model.cur_pos = args[3]--当前操作阵位
- end
- if args[1] == 14301 or args[1] == 14308 then
- self:SendFmtToGame(args[1], "lc", args[2],args[3])
- elseif args[1] == 14302 then
- self:SendFmtToGame(args[1], "l", args[2])
- elseif args[1] == 14303 then
- self:SendFmtToGame(args[1], "lcc", args[2],args[3],args[4])
- elseif args[1] == 14310 then--战魂系统-解锁位置
- self:SendFmtToGame(args[1], "c", args[2])
- elseif args[1] == 14304 then
- self:WriteBegin(14304)
- self:WriteFMT("l", args[2])
- self:WriteFMT("c", args[3])
- self:WriteFMT("h", args[4])
- for i, v in ipairs(args[5]) do
- self:WriteFMT("l", v.goods_id)
- end
- self:SendToGame()
- else
- self:SendFmtToGame(args[1])
- end
- end
- self.model:Bind(WarSoulModel.REQUEST_CCMD_EVENT, onRequestProtocal)
-
- local function init_open_day( ... )--开服天数初始化
- -- if GetModuleIsOpen(143) then
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14300)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14305)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14309)
- -- end
-
- local function init_server_info( ... )
-
- end
- setTimeout(init_server_info,3.5)
- end
- GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
-
- --升级
- local function onLevelUp(level)
- if level == Config.Modulesub["143@1"].open_lv then--战魂阵型
- WarSoulModel:getInstance():IsNeedRed(WarSoulModel.MainTab.Suit)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14309)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14300)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14305)
- elseif level == Config.Modulesub["143@5"].open_lv then--战魂强化
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14300)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14305)
- WarSoulModel:getInstance():IsNeedRed(WarSoulModel.MainTab.Strength)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14300)
- self.model:Fire(WarSoulModel.REQUEST_CCMD_EVENT,14305)
- elseif level == Config.Modulesub["143@3"].open_lv then--战魂进化
- WarSoulModel:getInstance():IsNeedRed(WarSoulModel.MainTab.Evolution)
- end
-
- local un_lock_cfg = self.model.warsoul_unlock_cfg
- local is_find = false
- for k,v in pairs(un_lock_cfg) do
- if is_find then
- break
- end
- if v.condition then
- for kk,vv in pairs(v.condition) do
- if vv[1] == "lv" and level == tonumber(vv[2]) then
- WarSoulModel:getInstance():IsNeedRed(WarSoulModel.MainTab.Suit)
- break
- end
- end
- end
- end
- end
- RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
-
- --战魂主界面
- local function open_equip_main_view(tab_index,speaciel_data)
- if RoleManager.Instance.mainRoleInfo.level < Config.Moduleid[143].open_lv then
- Message.show("功能暂未开启","fault")
- return
- end
- tab_index = tonumber(tab_index)
- if self.WarSoulBaseView == nil then
- self.WarSoulBaseView = WarSoulBaseView.New()
- end
- if not self.WarSoulBaseView:HasOpen() then
- self.WarSoulBaseView:Open(tab_index, speaciel_data)
- else
- self.WarSoulBaseView:UpdateView(tab_index, speaciel_data)
- end
- end
- GlobalEventSystem:Bind(WarSoulModel.OPEN_MAIN_VIEW,open_equip_main_view)
-
- --主界面关闭
- local function close_equip_main_view()
- if self.WarSoulBaseView and self.WarSoulBaseView:HasOpen() then
- self.WarSoulBaseView:Close()
- end
- self.WarSoulBaseView = nil
- end
- GlobalEventSystem:Bind(WarSoulModel.CLOSE_MAIN_VIEW,close_equip_main_view)
-
- local onOpenWarSoulSuitView = function ()--战魂阵法套装界面
- print("战魂阵法套装界面 :")
- if self.WarSoulSuitView == nil then
- self.WarSoulSuitView = WarSoulSuitView.New()
- end
- if self.WarSoulSuitView:HasOpen() then
- -- self.WarSoulSuitView:UpdateView()
- else
- self.WarSoulSuitView:Open()
- end
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_SUIT_VIEW, onOpenWarSoulSuitView)
-
- local onOpenWarSoulWearBagView = function (show,pos_index)--战魂上阵背包界面
- print("战魂上阵背包界面 :")
- self:OpenView("WarSoulWearBagView", show, pos_index)
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_BAG_VIEW, onOpenWarSoulWearBagView)
-
- local onOpenWarSoulBagSpliteView = function ()--战魂分解界面
- print("战魂分解界面 :")
- if self.WarSoulBagSpliteView == nil then
- self.WarSoulBagSpliteView = WarSoulBagSpliteView.New()
- end
- if self.WarSoulBagSpliteView:HasOpen() then
-
- else
- self.WarSoulBagSpliteView:Open()
- end
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_SPLITE_VIEW, onOpenWarSoulBagSpliteView)
-
- local onOpenWarSoulEvoSuccessView = function ()--战魂进化升级成功界面
- if not self.model.evo_goods_vo then return end
- print("战魂进化升级成功界面 :")
- if self.WarSoulEvoSuccessView == nil then
- self.WarSoulEvoSuccessView = WarSoulEvoSuccessView.New()
- end
- if self.WarSoulEvoSuccessView:HasOpen() then
- else
- self.WarSoulEvoSuccessView:Open()
- end
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_EVO_SUCCESS_VIEW, onOpenWarSoulEvoSuccessView)
-
- local onOpenWarSoulEvoBagView = function (data)--战魂进化背包界面
- print("战魂进化背包界面 :")
- if self.WarSoulEvolutionChooseView == nil then
- self.WarSoulEvolutionChooseView = WarSoulEvolutionChooseView.New()
- end
- if self.WarSoulEvolutionChooseView:HasOpen() then
- else
- self.WarSoulEvolutionChooseView:Open(data)
- end
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_EVO_CHOOSE_VIEW, onOpenWarSoulEvoBagView)
-
-
- local onOpenWarSoulPictrueView = function (show)--战魂图鉴界面
- print("战魂图鉴界面 :")
- self:OpenView("WarSoulPictrueView", show)
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_PICTRUE_VIEW, onOpenWarSoulPictrueView)
-
-
- local onOpenWarSoulPictrueAwardTipView = function (show,data)--战魂图鉴奖励提示小界面
- print("战魂图鉴奖励提示小界面 :")
- self:OpenView("WarSoulPictrueAwardTipView", show,data)
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_PICTRUE_AWARD_TIP_VIEW, onOpenWarSoulPictrueAwardTipView)
-
- local onOpenWarSoulEvoView = function (show)--战魂背包进化路线
- print("战魂背包进化路线 :")
- self:OpenView("WarSoulEvoView", show)
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_EVO_VIEW, onOpenWarSoulEvoView)
-
- local onOpenWarSoulStrengthBackView = function (show, data)--战魂强化回退
- print("战魂强化回退 :")
- self:OpenView("WarSoulStrengthBackView", show, data)
- end
- self.model:Bind(WarSoulModel.OPEN_WAR_SOUL_STRENGTH_BACK_VIEW, onOpenWarSoulStrengthBackView)
-
- local updateFunc = function ()
- self:OnWarSoulGoodsUpdate()
- end
- GlobalEventSystem:Bind(EventName.GOODS_DECOMPOSE_RESULT, updateFunc)
- GoodsModel:getInstance():Bind(GoodsModel.UPDATE_SPECIAL_SCORE, updateFunc)
- end
-
-
- --战魂道具变化更新
- function WarSoulController:OnWarSoulGoodsUpdate( )
- local function delay_fun( ... )
- self.model:IsNeedRed(WarSoulModel.MainTab.Suit)
- self.model:IsNeedRed(WarSoulModel.MainTab.Strength)
- self.model:IsNeedRed(WarSoulModel.MainTab.Evolution)
- end
- TimeManager.GetInstance():StartTime("15017OnWarSoulGoodsUpdate",0.15,delay_fun)
- end
-
- function WarSoulController:RegisterAllProtocals()
- self:RegisterProtocal(14300, "on14300")--战魂系统-总战力
- self:RegisterProtocal(14301, "on14301")--战魂系统-上阵
- self:RegisterProtocal(14302, "on14302")--战魂系统-卸下
- self:RegisterProtocal(14303, "on14303")--战魂系统-强化
- self:RegisterProtocal(14304, "on14304")--战魂系统-升星
- self:RegisterProtocal(14305, "on14305")--战魂系统-图鉴信息-最好只请求一次
- self:RegisterProtocal(14306, "on14306")--战魂系统-新增一条图鉴
- self:RegisterProtocal(14307, "on14307")--战魂系统-领取图鉴奖励
- self:RegisterProtocal(14308, "on14308")--战魂系统-回退等级
- self:RegisterProtocal(14309, "on14309")--战魂系统-位置解锁状态
- self:RegisterProtocal(14310, "on14310")--战魂系统-解锁位置
-
- end
-
- -- ########### 战魂系统-总战力 ##############
- -- protocol=14300
- -- {
- -- c2s{
- -- }
- -- s2c{
- -- power :int32 // 总战力
- -- }
- -- }
- function WarSoulController:on14300()
- local vo = SCMD14300.New(true)
- -- print("huangcong:WarSoulController14300 vo.power:", vo.power)
- self.model.warSoul_power = vo.power
- self.model:Fire(WarSoulModel.UPDATE_POWER)
- end
-
- -- ########### 战魂系统-上阵 ##############
- -- protocol=14301
- -- {
- -- c2s{
- -- goods_id :int64 // 物品id
- -- pos :int8 // 阵位
- -- }
- -- s2c{
- -- // 成功会推15017
- -- res :int32 // 错误码
- -- goods_id :int64 // 物品id
- -- }
- -- }
- function WarSoulController:on14301()
- local vo = SCMD14301.New(true)
- -- print("huangcong:WarSoulController [start:234] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("上阵成功","success")
- self.model:Fire(WarSoulModel.PLAY_EFFECT)
- self.model:IsNeedRed(WarSoulModel.MainTab.Suit)
- self.model:Fire(WarSoulModel.OPEN_WAR_SOUL_BAG_VIEW,false)
- self.model:Fire(WarSoulModel.CLOSE_WAR_SOUL_TIP_VIEW)
- ------------------------------魂力系统需要检测穿戴的星数来判断红点
- SoulPowerModel:getInstance():Fire(SoulPowerConst.UPDATE_RED_DOT, SoulPowerConst.RedType.UpGrade)
- ---------------------------------------
- if self.model.skill_goods_vo then
- self.model:OpenSkillActiveShowView()
- end
- else
- ErrorCodeShow(vo.res)
- end
- end
-
- -- ########### 战魂系统-卸下 ##############
- -- protocol=14302
- -- {
- -- c2s{
- -- goods_id :int64
- -- }
- -- s2c{
- -- // 成功会推15018
- -- res :int32 // 错误码
- -- }
- -- }
- function WarSoulController:on14302()
- local vo = SCMD14302.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("卸下成功","success")
- self.model:IsNeedRed(WarSoulModel.MainTab.Suit)
- self.model:Fire(WarSoulModel.OPEN_WAR_SOUL_BAG_VIEW,false)
- ------------------------------魂力系统需要检测穿戴的星数来判断红点
- SoulPowerModel:getInstance():Fire(SoulPowerConst.UPDATE_RED_DOT, SoulPowerConst.RedType.UpGrade)
- ---------------------------------------
- else
- ErrorCodeShow(vo.res)
- end
- end
-
- -- ############## 战魂系统-强化 ##############
- -- protocol=14303
- -- {
- -- c2s{
- -- goods_id :int64 // 物品id
- -- location :int8 // 物品所在位置 背包位置,见后台配置19战魂背包/20战魂装备位置
- -- count :int8 // 强化次数
- -- }
- -- s2c{
- -- // 成功会推15017
- -- res :int32 // 错误码
- -- lv :int16 // 新的强化等级
- -- }
- -- }
- function WarSoulController:on14303()
- local vo = SCMD14303.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("强化成功","success")
- self.model:IsNeedRed(WarSoulModel.MainTab.Strength)
- self.model:Fire(WarSoulModel.STRENGTH_PLAY_EFFECT)
- else
- ErrorCodeShow(vo.res)
- end
- end
-
- -- ############## 战魂系统-升星 ##############
- -- protocol=14304
- -- {
- -- c2s{
- -- goods_id :int64 // 原物品id
- -- location :int8 // 物品所在位置 背包位置,见后台配置19战魂背包/20战魂装备位置
- -- extra_cost:array{
- -- cost_goods_id :int64 // 消耗物品id
- -- }
- -- }
- -- s2c{
- -- // 成功会推15017
- -- res :int32 // 错误码
- -- goods_id :int64 // 物品id
- -- }
- -- }
- function WarSoulController:on14304()
- local vo = SCMD14304.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("进化成功","success")
- self.model:Fire(WarSoulModel.OPEN_WAR_SOUL_EVO_SUCCESS_VIEW)
- else
- ErrorCodeShow(vo.res)
- end
- end
-
- -- ########### 战魂系统-图鉴信息-最好只请求一次 ##############
- -- protocol=14305
- -- {
- -- c2s{
- -- }
- -- s2c{
- -- num :int16 // 领取的数量阶段
- -- goods_list:array{
- -- goods_id :int32 // 已收集的战魂
- -- }
- -- }
- -- }
- function WarSoulController:on14305()
- local vo = SCMD14305.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- self.model:SetPictrueInfo(vo)
- end
-
- -- ########### 战魂系统-新增一条图鉴 ##############
- -- protocol=14306
- -- {
- -- s2c{
- -- goods_id :int32 // 已收集的战魂
- -- }
- -- }
- function WarSoulController:on14306()
- local vo = SCMD14306.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- WarSoulModel:getInstance():SetOnePictrueInfo(vo.goods_id)
- end
-
- -- ########### 战魂系统-领取图鉴奖励 ##############
- -- protocol=14307
- -- {
- -- c2s{
- -- }
- -- s2c{
- -- res :int32 // 错误码
- -- num :int16 // 领取的数量阶段
- -- }
- -- }
- function WarSoulController:on14307()
- local vo = SCMD14307.New(true)
- -- print("huangcong:WarSoulController [start:257] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("领取成功","success")
- self.model.pictrue_award_num = vo.num
- self.model:IsNeedRed(WarSoulModel.MainTab.Strength)
- else
- ErrorCodeShow(vo.res)
- end
- end
-
-
- -- ########### 战魂系统-回退等级 ##############
- -- protocol=14308
- -- {
- -- c2s{
- -- goods_id :int64
- -- location :int8 // 物品所在位置 背包位置,见后台配置19战魂背包/20战魂装备位置
- -- }
- -- s2c{
- -- // 成功会推15018
- -- res :int32 // 错误码
- -- }
- -- }
- function WarSoulController:on14308()
- local vo = SCMD14308.New(true)
- -- print("huangcong:WarSoulController [start:510] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("回退成功","success")
- self.model:IsNeedRed(WarSoulModel.MainTab.Strength)
- else
- ErrorCodeShow(vo.res)
- end
- end
-
- -- ########### 战魂系统-位置解锁状态 ##############
- -- protocol=14309
- -- {
- -- c2s{
- -- }
- -- s2c{
- -- list:array{
- -- pos:int8
- -- }
- -- }
- -- }
- function WarSoulController:on14309()
- local vo = SCMD14309.New(true)
- -- print("huangcong:WarSoulController [start:534] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- self.model:SetWarSoulPosInfo(vo.list)
- self.model:IsNeedRed(WarSoulModel.MainTab.Suit)
- end
-
- -- ########### 战魂系统-解锁位置 ##############
- -- protocol=14310
- -- {
- -- c2s{
- -- pos:int8
- -- }
- -- s2c{
- -- res :int32 // 错误码
- -- pos:int8
- -- }
- -- }
- function WarSoulController:on14310()
- local vo = SCMD14310.New(true)
- -- print("huangcong:WarSoulController [start:534] vo:", vo)
- -- PrintTable(vo)
- -- print("huangcong:WarSoulController [end]")
- if vo.res == 1 then
- Message.show("解锁成功","success")
- self.model.cur_pos = vo.pos--当前操作阵位
- self.model:SetWarSoulPosInfoOne(vo.pos)
- local function end_func( ... )
- self.model:IsNeedRed(WarSoulModel.MainTab.Suit)
- end
- self.model:Fire(WarSoulModel.PLAY_EFFECT,end_func)
- else
- ErrorCodeShow(vo.res)
- end
- end
|