源战役客户端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1217 lines
39 KiB

require("game.proto.146.Require146")
require("game.foster.FosterConst")
require("game.foster.FosterModel")
require("game.foster.view.FosterBaseView")
require("game.foster.view.FosterSubView")
require("game.foster.view.FosterSubViewNew")
require("game.foster.view.FosterSkinView")
require("game.foster.view.FosterAttrItem")
require("game.foster.view.FosterTabItem")
require("game.foster.view.FosterSubTabItem")
require("game.foster.view.FosterSkinTabItem")
require("game.foster.view.FosterSkillItem")
require("game.foster.view.FosterBlessView")
require("game.foster.view.FosterSkillTips")
require("game.foster.view.FosterEquipItem")
require("game.foster.view.FosterEquipBaseView")
require("game.foster.view.FosterEquipTipView")
require("game.foster.view.FosterAttrItemTwo")
require("game.foster.view.FosterAttrItemThree")
require("game.foster.view.FosterUpEquipView")
require("game.foster.view.FosterKernelView")
require("game.foster.view.FosterKernelItem")
require("game.foster.view.FosterKernelTips")
require("game.foster.view.FosterEquipingView")
require("game.foster.view.FosterEquipingTabItem")
-- require("game.foster.view.FosterBagView")--逻辑修改已弃用
FosterController = FosterController or BaseClass(BaseController, true)
local FosterController = FosterController
function FosterController:__init()
FosterController.Instance = self
self.model = FosterModel:GetInstance()
self:AddEvents()
self:RegisterAllProtocal()
end
function FosterController:__delete()
self:StopShowUpCostTimer()
end
function FosterController:RegisterAllProtocal( )
self:RegisterProtocal(14600, "on14600")--基础系统信息
self:RegisterProtocal(14601, "on14601")--普通系统培养
self:RegisterProtocal(14602, "on14602")--使用核心
self:RegisterProtocal(14603, "on14603")--幻化协议
self:RegisterProtocal(14604, "on14604")--技能升级
self:RegisterProtocal(14605, "on14605")--技能激活通知
self:RegisterProtocal(14606, "on14606")--装备升级
self:RegisterProtocal(14607, "on14607")--装备穿戴
self:RegisterProtocal(14608, "on14608")--装备更新
self:RegisterProtocal(14609, "on14609")--骑乘状态修改
self:RegisterProtocal(14613, "on14613")--新手激活推送
self:RegisterProtocal(14614, "on14614")--进阶装备助战状态查询 - 全量数据
self:RegisterProtocal(14615, "on14615")--进阶装备助战状态查询 - 单个查询
self:RegisterProtocal(14616, "on14616")--手动激活进阶装备助战状态
self:RegisterProtocal(14617, "on14617")--弱进阶系统皮肤信息
self:RegisterProtocal(14618, "on14618")--弱进阶系统皮肤激活或者升星
self:RegisterProtocal(14619, "on14619")--弱进阶系统皮肤幻化
self:RegisterProtocal(14620, "on14620")--弱进阶系统升级
self:RegisterProtocal(14621, "on14621")--助战变更后推送
end
function FosterController:AddEvents()
local function init_open_day()
self.model:Reset()
local function delay( )
for k,v in pairs(FosterConst.ModuleId) do
if GetModuleIsOpen(146,v) then
self.model:Fire(FosterConst.ReqBasicInfo, v)
if v>=5 then
self.model:Fire(FosterConst.ReqSubSkinInfo, v)
end
-- 请求装备协助相关
if v == FosterConst.ModuleId.FHorse or v == FosterConst.ModuleId.FJarvis then
self.model:Fire(FosterConst.ReqEquipAssistInfo, v)
end
end
end
end
setTimeout(delay,2)
end
GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT, init_open_day)
local function loadComplete()
--在不显示坐骑的场景,要下坐骑噢!
local is_ride = RoleManager:getInstance():GetMainRoleVo() and (RoleManager:getInstance():GetMainRoleVo().is_ride ~= 0)
if is_ride and (not SceneManager:getInstance():IsShowHorseScene()) then
GlobalEventSystem:Fire(EventName.HIDE_HORSE)
end
end
GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, loadComplete)
local function onLevelChange( level )
for k,v in pairs(FosterConst.ModuleId) do
if Config.Modulesub["146@" .. v] and (Config.Modulesub["146@" .. v].open_lv == level or Config.Modulesub["146@" .. v].icon_lv == level) then
-- 幻化初始外观
-- self.model:Fire(FosterConst.ReqChangeSkin, v, 1)
self.model:Fire(FosterConst.ReqBasicInfo, v)
-- 请求装备协助相关
if v == FosterConst.ModuleId.FHorse or v == FosterConst.ModuleId.FJarvis then
self.model:Fire(FosterConst.ReqEquipAssistInfo, v)
end
end
end
end
RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelChange)
local function ANS_FINISHED_TASK_LIST( task_id )
if task_id == Config.Modulesub["146@5"].task_id then
--ai娘后端会提早开出来,所以要前端先不显示场景对象,任务完成的时候再更新显示
local main_role = Scene.Instance:GetMainRole()
if main_role then
main_role:ChangePet()
end
end
end
GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST,ANS_FINISHED_TASK_LIST)
--基础系统信息
local function ReqBasicInfo( type_id )
if type_id then
self:SendFmtToGame(14600, "c", type_id)
end
end
self.model:Bind(FosterConst.ReqBasicInfo, ReqBasicInfo)
--普通系统培养
local function ReqStrengthen( type_id, is_auto_up, is_auto_buy, auto_bgold )
is_auto_up = is_auto_up and 1 or 0
is_auto_buy = is_auto_buy and 1 or 0
auto_bgold = auto_bgold or 0-- 0 红钻不足后停止,1 会消耗彩钻
if type_id then
self:SendFmtToGame(14601, "cccc", type_id, is_auto_up, is_auto_buy, auto_bgold)
end
end
self.model:Bind(FosterConst.ReqStrengthen, ReqStrengthen)
--弱进阶系统皮肤信息
local function ReqSubSkinInfo(type_id)
if type_id then
self:SendFmtToGame(14617, "c", type_id)
end
end
self.model:Bind(FosterConst.ReqSubSkinInfo, ReqSubSkinInfo)
-- 弱进阶皮肤请求激活或升星
local function req_sub_skin_act_or_up(type_id, skin_id, option)
if type_id and skin_id and option then
self:SendFmtToGame(14618, "chc", type_id, skin_id, option)
end
end
self.model:Bind(FosterConst.ReqSubSkinActiveOrUpGrade, req_sub_skin_act_or_up)
local function req_sub_skin_change(type_id, skin_id, star)
if type_id and skin_id and star then
self:SendFmtToGame(14619, "chh", type_id, skin_id, star)
end
end
self.model:Bind(FosterConst.ReqSubSkinChange, req_sub_skin_change)
--弱进阶系统使用升级材料
local function ReqSubUpgrade( type_id, material_type, is_auto_up)
material_type = material_type or 1
is_auto_up = is_auto_up and 1 or 0
if type_id then
self:SendFmtToGame(14620, "ccc", type_id, material_type, is_auto_up)
end
end
self.model:Bind(FosterConst.ReqSubUpgrade, ReqSubUpgrade)
--使用核心
local function ReqUseKernel( type_id, op_type, num )
op_type = op_type or 0
num = num or 1
if type_id then
self:SendFmtToGame(14602, "ccc", type_id, op_type, num)
end
end
self.model:Bind(FosterConst.ReqUseKernel, ReqUseKernel)
--幻化协议
local function ReqChangeSkin( type_id, diaplay_id )
if type_id and diaplay_id then
self:SendFmtToGame(14603, "ch", type_id, diaplay_id)
end
end
self.model:Bind(FosterConst.ReqChangeSkin, ReqChangeSkin)
--技能升级
local function ReqSkillUpgrade( type_id, pos )
if type_id and pos then
self:SendFmtToGame(14604, "cc", type_id, pos)
end
end
self.model:Bind(FosterConst.ReqSkillUpgrade, ReqSkillUpgrade)
--装备升级
local function ReqEquipUpGrade( type_id, grade, pos, eats )
if type_id and grade and pos and eats then
self:WriteBegin(14606)
self:WriteFMT("c", type_id)
self:WriteFMT("h", grade)
self:WriteFMT("c", pos)
self:WriteFMT("h", TableSize(eats))
for k, v in pairs(eats) do
self:WriteFMT("l", k)
end
self:SendToGame()
end
end
self.model:Bind(FosterConst.ReqEquipUpGrade, ReqEquipUpGrade)
--装备穿戴
local function ReqEquipDress( opty, type_id, grade, goods_id )
if opty and type_id and grade and goods_id then
self:SendFmtToGame(14607, "cchl", opty, type_id, grade, goods_id )
end
end
self.model:Bind(FosterConst.ReqEquipDress, ReqEquipDress)
local function OPEN_SUCCESS_VIEW( type_id,id,star )
print('----LZR ShapeController.lua 92-- type_id,id,star=',type_id,id,star)
if not self.shapesuccessview then
self.shapesuccessview = ShapeSuccessView.New()
self.shapesuccessview:Open(type_id,id,star, true)
end
end
self.model:Bind(FosterConst.OPEN_SUCCESS_VIEW,OPEN_SUCCESS_VIEW)
local function ReqEquipDressInfo( type_id,grade )
if not type_id or not grade then return end
self:SendFmtToGame(14608, "ch", type_id,grade )
end
self.model:Bind(FosterConst.ReqEquipDressInfo, ReqEquipDressInfo)
--骑乘状态修改
local function Change_Ride_Status( op_type )
--非显示坐骑场景,不给上坐骑
if op_type == 1 and not SceneManager:getInstance():IsShowHorseScene() then
Message.show("该场景不能上坐骑哦")
return
end
op_type = op_type or 0
-------------------------
--要筛选不能转换状态的情况,下坐骑就不限制了
local main_role = Scene:getInstance():GetMainRole()
if main_role then
if op_type == 1 then
--在部分不能上坐骑的地方,不要让它上坐骑
if not main_role:CanOperateHorse() then
Message.show("当前状态不能上坐骑哦")
return
end
end
end
-------------------------
if GetModuleIsOpen(146,1) then
self:SendFmtToGame(14609, "c", op_type )
end
end
self.model:Bind(FosterConst.Change_Ride_Status, Change_Ride_Status)
local function require_equip_assist_info(type)
if not type then return end
self:SendFmtToGame(14614, "c", type)
end
self.model:Bind(FosterConst.ReqEquipAssistInfo, require_equip_assist_info)
local function check_equip_assist_info(type, grade)
if not type or not grade then return end
self:SendFmtToGame(14615, "ch", type, grade)
end
self.model:Bind(FosterConst.CheckEquipAssistInfo, check_equip_assist_info)
local function require_activate_equip_assist(type, grade)
if not type or not grade then return end
self:SendFmtToGame(14616, "ch", type, grade)
end
self.model:Bind(FosterConst.ReqActivateEquipAssist, require_activate_equip_assist)
local function HIDE_HORSE( )
--下坐骑
Change_Ride_Status(0)
end
GlobalEventSystem:Bind(EventName.HIDE_HORSE,HIDE_HORSE)
local function RIDE_HORSE( )
if EscortModel:getInstance():IsEscortState() then--护送不给上坐骑
return
end
--上坐骑
Change_Ride_Status(1)
end
GlobalEventSystem:Bind(EventName.RIDE_HORSE,RIDE_HORSE)
local function OpenBaseView( type_id, right_show_type,is_skin)
-- print("Lizhijian:FosterController [start:298] ")
-- print(type_id, right_show_type,is_skin)
-- print("Lizhijian:FosterController [end:298] ")
if not self.FosterBaseView then
self.FosterBaseView = FosterBaseView.New(nil, nil, nil,type_id,right_show_type,is_skin)
self.FosterBaseView:Open()
else
self.FosterBaseView:ReOpen(type_id,right_show_type,is_skin)
end
end
GlobalEventSystem:Bind(FosterConst.OpenBaseView, OpenBaseView)
local function OpenKernelView( type_id )
if not type_id then
if self.FosterKernelView then
self.FosterKernelView:Close()
end
return
end
if not self.FosterKernelView then
self.FosterKernelView = FosterKernelView.New()
self.FosterKernelView:Open(type_id)
end
end
self.model:Bind(FosterConst.OpenKernelView,OpenKernelView)
local function OpenSkinView( type_id, sub_type_id)
if self.FosterBaseView then
self.FosterBaseView:Close()
local function delay_method()
local is_skin = true
GlobalEventSystem:Fire(FosterConst.OpenBaseView, type_id, sub_type_id, is_skin)
end
self.delay_method_id = setTimeout(delay_method, 0.5)
end
end
self.model:Bind(FosterConst.OpenSkinView,OpenSkinView)
local function OpenEquipingView( type_id,grade,equip_pos,equip_color)
if not type_id then
if self.FosterEquipingView then
self.FosterEquipingView:Close()
end
return
end
if not self.FosterEquipingView then
self.FosterEquipingView = FosterEquipingView.New()
self.FosterEquipingView:Open(type_id,grade,equip_pos,equip_color)
end
end
self.model:Bind(FosterConst.OpenEquipingView,OpenEquipingView)
local function OpenBlessView( type_id )
if not type_id then
self.model:Fire(FosterConst.CloseBaseView)
return
end
if not self.FosterBlessView then
self.FosterBlessView = FosterBlessView.New()
self.FosterBlessView:Open(type_id)
end
end
self.model:Bind(FosterConst.OpenBlessView, OpenBlessView)
local function OpenSkillTips( type_id, pos, skill_id )
if not type_id or not pos or not skill_id then
return
end
if not self.FosterSkillTips then
self.FosterSkillTips = FosterSkillTips.New()
self.FosterSkillTips:Open(type_id, pos, skill_id)
end
end
self.model:Bind(FosterConst.OpenSkillTips,OpenSkillTips)
--技能tips界面里跳转到商店时,关闭这个tips
local function CloseSkillTips()
if self.FosterSkillTips and self.FosterSkillTips.isPop then
self.FosterSkillTips:Close()
end
end
self.model:Bind(FosterConst.CloseSkillTips,CloseSkillTips)
-- local function OpenFosterBagView( type_id,grade,pos )
-- if not grade then return Message.show("进阶背包参数错误") end
-- if not self.FosterBagView then
-- self.model:SetDressAction(type_id,grade,pos)
-- -------------------------
-- self.FosterBagView = FosterBagView.New()
-- self.FosterBagView:Open(type_id,grade,pos)
-- end
-- end
-- self.model:Bind(FosterConst.OpenFosterBagView,OpenFosterBagView)
local function OpenFosterEquipTipView( data_1,data_2,tag,open_show_get_way,hide_base_con )
--要传入背包的信息!!!!
if not data_1 and not data_2 then return end
if not self.FosterEquipBaseView then
self.FosterEquipBaseView = FosterEquipBaseView.New()
self.FosterEquipBaseView:Open(data_1,data_2,tag,open_show_get_way,hide_base_con)
end
end
self.model:Bind(FosterConst.OpenFosterEquipTipView,OpenFosterEquipTipView)
local function OpenFosterUpEquipView( bag_data )
if not bag_data then return end
--要传入背包的信息!!!!
if not self.FosterUpEquipView then
self.FosterUpEquipView = FosterUpEquipView.New()
self.FosterUpEquipView:Open(bag_data)
end
end
self.model:Bind(FosterConst.OpenFosterUpEquipView,OpenFosterUpEquipView)
local function BOARD_CLOSE_FUNC_OPEN_VIEW( )
if self.wait_show_up_success_call then
self.wait_show_up_success_call()
self.wait_show_up_success_call = false
end
end
GlobalEventSystem:Bind(EventName.BOARD_CLOSE_FUNC_OPEN_VIEW, BOARD_CLOSE_FUNC_OPEN_VIEW)
end
--基础系统信息
function FosterController:on14600( )
local scmd = SCMD14600.New(true)
scmd.end_time = scmd.retime + TimeUtil:getServerTime()
self.model:SetBasicInfo(scmd.type, scmd)
local basic = self.model:GetBasicInfo(scmd.type)
self.model:CheckRedDot( true,scmd.type )
self:CheckRedDot()
self.model:Fire(FosterConst.AnsBasicInfo,scmd.type)
end
--系统培养
function FosterController:on14601( )
local scmd = SCMD14601.New(true)
if scmd.result == 1 then
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
local star_change,grade_change = self.model:StrengthenCheckIsUpgrade(scmd)
if star_change or grade_change then
if grade_change then
self:ShowUpSuccess(scmd.type,scmd.grade)
end
--升级重新请求
local function delay( )
self.model:Fire(FosterConst.ReqBasicInfo, scmd.type)
end
setTimeout(delay,0)
-------------------------
-- 升阶成功后需要检测是否弹出活动引导
local temp = {
[1] = scmd.type,
[2] = scmd.grade,
[3] = scmd.star,
}
KfActivityModel:getInstance():CheckNeedShowActGuide("foster", temp)
elseif not self.model:RefreshStrengthenExp( scmd ) then
--非升级就直接修改,未成功修改就请求数据
self.model:Fire(FosterConst.ReqBasicInfo, scmd.type)
end
-- if not (star_change or grade_change) then
-- Message.show(string.format( "升阶成功,祝福值+%d",scmd.exp ))
-- else
Message.show("升阶成功")
-- end
self.model:CanUpgrade(true,scmd.type)
self.model:Fire(FosterConst.AnsStrengthen,(star_change or grade_change) and true or false)
self:CheckRedDot()
self.model:ResetPetFightSkillState()
if ((not (star_change or grade_change)) and (scmd.auto_up == 1 and scmd.auto_buy == 0)) or
--自动进阶且非自动购买的时候,还没升级说明资源耗尽
(self.model:IsFirstForsterAdvance() and KfActivityModel:getInstance():CheckFosterRechargeAdsShow( scmd.type, scmd.grade)) then
self:ShowUpCostGoodsTips( scmd.type, scmd.grade, scmd.auto_up, true )
end
else
self.model:Fire(FosterConst.AnsStrengthen,"fail")
--[[if then
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.FAULT)
lua_soundM:PlayEffect(self, "fault", false, LuaSoundManager.SOUND_TYPE.UI)
GlobalEventSystem:Fire(EventName.OPEN_RECHARGE_TIP_VIEW, true)
ErrorCodeShow(scmd.result)
else--]]
if scmd.result == 1003 or scmd.result == 1006 or scmd.result == 1001 then
if scmd.result == 1006 and scmd.auto_up == 1 and scmd.auto_buy == 1 then
local function call_yes( )
local function delay( )
self.model:Fire(FosterConst.ReqStrengthen, scmd.type, true,true, 1)
end
setTimeout(delay,0.3)
end
Alert.show('您的红钻已用完,需要开始消耗彩钻进阶,确认继续吗?', Alert.Type.Two, call_yes, nil, '确定', '取消')
return
end
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.FAULT)
lua_soundM:PlayEffect(self, "fault", false, LuaSoundManager.SOUND_TYPE.UI)
self:ShowUpCostGoodsTips( scmd.type, scmd.grade, scmd.auto_up, false)
else
ErrorCodeShow(scmd.result)
end
end
end
function FosterController:ShowUpCostGoodsTips( type_id, grade, auto_up, is_success )
local cost_data = self.model:GetGradeCost(type_id)
if cost_data then
local parm_list = {}
--如果是成功,并且是第一次弹提示窗,才需要延时
local is_delay_show = self.model:IsFirstForsterAdvance() and is_success
-- 进阶抢购和进阶首充不同时出现 进阶首充的显示优先级高
if KfActivityModel:getInstance():CheckFosterRechargeAdsShow( type_id, grade) then
parm_list.foster_recharge_show = true
else
parm_list.show_limit_shop = true
end
for k,v in pairs(ShopModel:getInstance():GetGoodsListInfo( ShopType.BindGold )) do
for a,b in pairs(v) do
if b.goods_id == tonumber(cost_data[1][2]) then
parm_list.shop_data = DeepCopy(b)
-------------------------
--填入一个缺少值
parm_list.shop_data.first_buy_num = self.model:GetUpgradeNeedMoreCostNum(type_id, auto_up)
-------------------------
end
end
end
self:StopShowUpCostTimer()
if is_delay_show then
local function delay_call_back( ... )
self:StopShowUpCostTimer()
local main_role = Scene.Instance:GetMainRole()
if not main_role then
return
end
self.model:SetFirstForsterAdvanceCookie()
-- 传入当前类型和阶数
parm_list.foster_data = {type = type_id, grade = grade}
UIToolTipMgr:getInstance():AppendGoodsTips(cost_data[1][2], nil, nil,nil,nil,parm_list,nil,nil)
end
self.show_up_cost_timer = GlobalTimerQuest:AddDelayQuest(delay_call_back,1.5)
else
self.model:SetFirstForsterAdvanceCookie()
-- 传入当前类型和阶数
parm_list.foster_data = {type = type_id, grade = grade}
UIToolTipMgr:getInstance():AppendGoodsTips(cost_data[1][2], nil, nil,nil,nil,parm_list,nil,nil)
end
end
end
function FosterController:StopShowUpCostTimer()
if self.show_up_cost_timer then
GlobalTimerQuest:CancelQuest(self.show_up_cost_timer)
self.show_up_cost_timer = nil
end
end
--使用核心
function FosterController:on14602( )
local scmd = SCMD14602.New(true)
if scmd.result == 1 then
Message.show("使用成功")
-- 每次使用成功后请求基础数据更新
self.model:Fire(FosterConst.ReqBasicInfo, scmd.type)
self.model:Fire(FosterConst.AnsUseKernel,scmd.opty, scmd.result)
self.model:CanKernel(true,scmd.type)
self:CheckRedDot()
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
self.model:Fire(FosterConst.AnsUseKernel,scmd.opty, scmd.result)
ErrorCodeShow(scmd.result)
end
end
--幻化协议
function FosterController:on14603( )
local scmd = SCMD14603.New(true)
if scmd.result == 1 then
Message.show("幻化成功")
if not self.model:RefreshSkinUseInfo( scmd.type, scmd.display ) then
self.model:Fire(FosterConst.ReqBasicInfo, scmd.type)
end
self.model:Fire(FosterConst.AnsChangeSkin, scmd.type)
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.result)
end
end
--技能升级
function FosterController:on14604( )
local scmd = SCMD14604.New(true)
if scmd.result == 1 then
Message.show("升级成功")
self.model:RefreshSkillInfo(scmd.type, scmd)
-------------------------
self.model:CanSkillUpgradeByType( true,scmd.type )
self:CheckRedDot()
self.model:Fire(FosterConst.AnsSkillUpgrade)
self.model:Fire(FosterConst.ReqBasicInfo, scmd.type)
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.result)
end
end
--技能激活通知
function FosterController:on14605( )
local scmd = SCMD14605.New(true)
self.model:RefreshSkillInfo(scmd.type, scmd)
self.model:Fire(FosterConst.BoardSkillActive)
if scmd.skill > 0 then
local skill_data = {skill_id = scmd.skill, show_time = 15, ignore_auto_task = true}
FuncOpenController.Instance:ShowSkill(skill_data)
end
-------------------------
self.model:CanSkillUpgradeByType( true,scmd.type )
self:CheckRedDot()
end
--装备升级
function FosterController:on14606( )
local scmd = SCMD14606.New(true)
if scmd.res == 1 then
Message.show("升级成功")
self.model:ResetSwallowSelect()
self.model:Fire(FosterConst.SwallowStatusChange)
-------------------------
self.model:Fire(FosterConst.AnsEquipUpGrade, scmd.type, scmd.grade)
self.model:Fire(FosterConst.ReqEquipDressInfo,scmd.type,scmd.grade)
-------------------------
self.model:RefreshEquipRedData( scmd.type )
self:CheckRedDot()
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.res)
end
end
--装备穿戴
function FosterController:on14607( )
local scmd = SCMD14607.New(true)
if scmd.res == 1 then
if scmd.opty == 1 then
Message.show("穿戴成功")
else
Message.show("卸下成功")
end
self.model:Fire(FosterConst.CloseFosterEquipTipView)
self.model:Fire(FosterConst.CloseFosterBagView)
self.model:Fire(FosterConst.AnsEquipDress, scmd.type, scmd.grade, scmd.opty, scmd.pos)
self.model:Fire(FosterConst.ReqEquipDressInfo,scmd.type,scmd.grade)
-------------------------
self.model:RefreshEquipRedData( scmd.type )
self:CheckRedDot()
GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
else
ErrorCodeShow(scmd.res)
end
end
--装备更新
function FosterController:on14608( )
local scmd = SCMD14608.New(true)
self.model:RefreshEquipList( scmd.type,scmd.grade,scmd.equips )
self.model:Fire(FosterConst.AnsEquipDressInfo)
-------------------------
self.model:RefreshEquipRedData( scmd.type )
self:CheckRedDot()
end
--骑乘状态修改
function FosterController:on14609( )
local scmd = SCMD14609.New(true)
if scmd.res==1 then
else
ErrorCodeShow(scmd.res)
end
end
--新手激活推送
function FosterController:on14613( )
local scmd = SCMD14613.New(true)
local reward_data = {show_name = "", show_list = {}}
for k,v in pairs(scmd.awards) do
table.insert(reward_data.show_list, {0, v.kdata, v.vdata})
end
self:ShowUpSuccess( scmd.type, scmd.grade, reward_data )
end
-- 进阶装备助战状态查询 - 全量数据
function FosterController:on14614( )
local vo = SCMD14614.New(true)
self.model:SetFosterSuitAssistFlagData(vo)
self:CheckRedDot()
self.model:Fire(FosterConst.UPDATE_FOSTER_ASSIST_FLAG)
end
function FosterController:on14615( )
local vo = SCMD14615.New(true)
self.model:UpdateFosterSuitAssistFlagData(vo)
self.model:CanActivateFosterAssist(true, vo.type)
self:CheckRedDot()
self.model:Fire(FosterConst.UPDATE_FOSTER_ASSIST_FLAG, vo.type, vo.grade)
end
function FosterController:on14616( )
local vo = SCMD14616.New(true)
if vo.errcode == 1 then -- 激活成功
vo.state = 2 -- 成功写死2
self.model:UpdateFosterSuitAssistFlagData(vo)
self.model:CanActivateFosterAssist(true, vo.type)
self:CheckRedDot()
self.model:Fire(FosterConst.UPDATE_FOSTER_ASSIST_FLAG, vo.type, vo.grade)
else
ErrorCodeShow(vo.errcode)
end
end
function FosterController:on14617()
local vo = SCMD14617.New(true)
self.model:SetFosterSubSkinData(vo.type, vo.skins)
self.model:Fire(FosterConst.AnsSubSkinInfo, vo.type, vo.skins)
self:CheckRedDot()
end
function FosterController:on14618()
local vo = SCMD14618.New(true)
if vo.result == 1 then -- 操作成功
self:CheckRedDot()
--激活成功
if vo.star == 1 then
self.model:Fire(FosterConst.ReqSubSkinChange, vo.type, vo.id, vo.star)
end
self.model:Fire(FosterConst.ReqSubSkinInfo, vo.type)
self.model:Fire(FosterConst.OPEN_SUCCESS_VIEW, vo.type, vo.id, vo.star)
else
ErrorCodeShow(vo.result)
end
self.model:Fire(FosterConst.AnsSubSkinActiveOrUpGrade, vo)
end
function FosterController:on14619()
local vo = SCMD14619.New(true)
if vo.result == 1 then -- 操作成功
-- self:CheckRedDot()
self.model:Fire(FosterConst.ReqSubSkinInfo, vo.type)
else
ErrorCodeShow(vo.result)
end
self.model:Fire(FosterConst.AnsSubSkinChange, vo)
end
function FosterController:on14620()
local vo = SCMD14620.New(true)
if vo.result == 1 then -- 使用材料成功
self:CheckRedDot()
elseif vo.result ~= 1003 then
ErrorCodeShow(vo.result)
end
self.model:Fire(FosterConst.AnsSubUpgrade, vo.result, vo.type, vo.material_type, vo.lv, vo.exp)
end
function FosterController:on14621()
local vo = SCMD14621.New(true)
self.model:Fire(FosterConst.ReqBasicInfo, vo.type)
end
-------------------------
--进阶消耗材料变更
function FosterController:UpGradeGoodsChange( )
for k,v in pairs(FosterConst.ModuleId) do
if GetModuleIsOpen(146,v) then
self.model:CanUpgrade(true,v)
end
end
self:CheckRedDot()
--贵族培养丹兑换需要检测材料数量变化
SupremeVipModel:getInstance():Fire(SupremeVipConst.UPDATE_TRAIN_DRUG_NUM)
end
--属性丹消耗材料变更
function FosterController:UpKernelGoodsChange( )
for k,v in pairs(FosterConst.ModuleId) do
if GetModuleIsOpen(146,v) then
self.model:CanKernel( true, v )
end
end
self:CheckRedDot()
end
function FosterController:UpHorseEquipChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FHorse) then
local bool_i = self.model:CanDressNewEquipWithType(true,FosterConst.ModuleId.FHorse)
local bool_i = self.model:CanDressUpEquipWithType(true,FosterConst.ModuleId.FHorse)
local bool_i = self.model:CanUpEquipWithType( true,FosterConst.ModuleId.FHorse )
self:CheckRedDot()
end
end
function FosterController:SkillGoodsChange( )
for k,v in pairs(FosterConst.ModuleId) do
if GetModuleIsOpen(146,v) then
self.model:CanSkillUpgradeByType( true, v )
end
end
self:CheckRedDot()
end
function FosterController:UpAIEquipChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FJarvis) then
self.model:CanDressUpEquipWithType(true,FosterConst.ModuleId.FJarvis)
self.model:CanDressUpEquipWithType(true,FosterConst.ModuleId.FJarvis)
self.model:CanUpEquipWithType( true,FosterConst.ModuleId.FJarvis )
self:CheckRedDot()
end
end
--刷新AI娘SKin红点
function FosterController:UpAISkinChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FJarvis) then
self.model:CanSkinActOrUp( true,FosterConst.ModuleId.FJarvis )
self:CheckRedDot()
end
end
--刷新磁炮皮肤红点
function FosterController:UpFGunChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FJarvis) then
self.model:CanSkinActOrUp( true,FosterConst.ModuleId.FGun )
self:CheckRedDot()
end
end
--刷新星翼皮肤红点
function FosterController:UpFcloudChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FJarvis) then
self.model:CanSkinActOrUp( true,FosterConst.ModuleId.FCloud )
self:CheckRedDot()
end
end
--刷新幻甲SKin红点
function FosterController:UpFArmourChange( )
if GetModuleIsOpen(146,FosterConst.ModuleId.FJarvis) then
self.model:CanSkinActOrUp( true,FosterConst.ModuleId.FArmour )
self:CheckRedDot()
end
end
function FosterController:CheckRedDot( )
local function call_backack( )
local list = {
[1] = {
FosterConst.ModuleId.FHorse, FosterConst.ModuleId.FWing,
FosterConst.ModuleId.FPearl, FosterConst.ModuleId.FWeapon,
},
[2] = {
FosterConst.ModuleId.FJarvis, FosterConst.ModuleId.FGun,
FosterConst.ModuleId.FCloud, FosterConst.ModuleId.FArmour,
}
}
local bool_1,bool_2 = false,false
for k,v in pairs(list[1]) do
if GetModuleIsOpen(146,v) then
bool_1 = bool_1 or self.model:CheckRedDot( false,v )
end
end
for k,v in pairs(list[2]) do
if GetModuleIsOpen(146,v) then
bool_2 = bool_2 or self.model:CheckRedDot( false,v )
end
end
GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 146, bool_1)
GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 146555, bool_2)
-------------------------
self.model:Fire(FosterConst.RedDotRefresh)
self.model:CheckBlessClock( )--祝福值清空提示机制
end
TimeManager.GetInstance():StartTime("FosterController_CheckRedDot", 0.5, call_backack)
end
function FosterController:ShowUpSuccess( type_id, grade, reward_data )
local function call_up_success( )
if (not type_id) or (not grade) then return end
local cur_data = self.model:GetBaseConfOne( type_id, grade, 0 )
if not cur_data then return end
local attr_new = stringtotable(cur_data.attrs)
local data = {}
data.extra_type_id = type_id
data.extra_grade = grade
data.close_time = 10
data.big_title_effect = {
{res = "ui_jinjiechenggong01"},
{res = "ui_jinjiechenggong02"},
}
data.grade_change = {
old_grade = string.format("%s阶",grade-1),
new_grade = string.format("%s阶",grade),
old_star = grade - 1,
new_star = grade,
max_star_old = 0,--self.model:GetCurMaxStar( type_id,grade - 1 ),
max_star_new = 0,--self.model:GetCurMaxStar( type_id,grade ),
}
data.model_info = {
model_type = FosterConst.ModelMatch[type_id],
model_id = cur_data.resource,
name = Trim(cur_data.name),
name_des = string.format("%s阶",grade)
}
-------------------------
data.special_attr = {}
for i=#attr_new,1,-1 do
if WordManager:GetAttrIsSpecial(attr_new[i][1]) then
table.insert(data.special_attr, table.remove(attr_new,i))
end
end
-------------------------
if grade == 1 then
data.power_data = {
new_power = GetFighting(attr_new),
change_power = 0,
}
data.attr_data = {
title_name = string.format("%s属性",FosterConst.ModelName[type_id]),
attr_old = attr_new,
attr_new = {},
}
else
local attr_old = stringtotable(self.model:GetBaseConfOne( type_id, grade-1, self.model:GetCurMaxStar( type_id,grade-1 ) ).attrs)
-------------------------
--把特殊属性删掉
for i=#attr_old,1,-1 do
if WordManager:GetAttrIsSpecial(attr_old[i][1]) then
table.remove(attr_old,i)
end
end
-------------------------
data.power_data = {
new_power = GetFighting(attr_new),
change_power = GetFighting(attr_new) - GetFighting(attr_old),
}
data.attr_data = {
title_name = string.format("%s属性",FosterConst.ModelName[type_id]),
attr_old = attr_old,
attr_new = attr_new,
}
--特殊指定的奖励数据
if reward_data then
data.reward_data = reward_data
data.reward_data.show_name = Trim(cur_data.name)
else
data.reward_data = {
show_list = stringtotable(cur_data.award)
}
end
end
-------------------------
data.attr_data.pos_type = #data.special_attr == 0 and "default" or "foster"
-------------------------
if self.FosterSkillTips then
self.FosterSkillTips:Close()
end
GlobalEventSystem:Fire(EventName.OPEN_UPGRADE_SHOW_VIEW,data)
end
if self.model.wait_new_func_open then
self.wait_show_up_success_call = call_up_success
else
call_up_success()
self.wait_show_up_success_call = false
end
end
--时装(这里就不触发更改,只调整数据)
function FosterController:ChangeRoleFashionInfo(scmd, role_id)
local role_vo = SceneManager.Instance:GetRoleVo(role_id)
local role = Scene.Instance:GetRole(role_id)
if not role_vo then return end
local exchange_type_id = scmd.type_id
--如果不是武器或者翅膀就不处理
if not (FashionModel.FashionType.WING == exchange_type_id or FashionModel.FashionType.WEAPON == exchange_type_id) then return end
--时装的类型和进阶的类型进行转换
if exchange_type_id == FashionModel.FashionType.WING then
exchange_type_id = FosterConst.ModuleId.FWing
elseif exchange_type_id == FashionModel.FashionType.WEAPON then
exchange_type_id = FosterConst.ModuleId.FWeapon
end
--这里要把别的系统的数据清理掉 开始
for k,v in pairs(role_vo.foster_sub_skin_list) do
if v.type_id == exchange_type_id then
v.skin_id = 0
v.star = 0
break
end
end
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == exchange_type_id then
v.sub_id = 0
v.star = 0
v.skin_id = 0
break
end
end
--这里要把别的系统的数据清理掉 结束
end
--皮肤变更
function FosterController:ChangeRoleForsterSunSkinInfo(scmd, role_id)
local role_vo = SceneManager.Instance:GetRoleVo(role_id)
local role = Scene.Instance:GetRole(role_id)
if not role_vo then return end
role_vo.foster_sub_skin_list = role_vo.foster_sub_skin_list or {}
local is_have = false
for k,v in pairs(role_vo.foster_sub_skin_list) do
if v.type_id == scmd.type_id then
v.skin_id = scmd.skin_id
v.star = scmd.star
is_have = true
break
end
end
if not is_have then
table.insert(role_vo.foster_sub_skin_list, {type_id = scmd.type_id, skin_id = scmd.skin_id, star=scmd.star})
end
--这里要把别的系统的数据清理掉 开始
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == scmd.type_id then
v.sub_id = 0
v.star = 0
v.skin_id = 0
break
end
end
--这里要把别的系统的数据清理掉 结束
local exchange_type_id = scmd.type_id
local foster_res_id = false
for k,v in pairs(role_vo.foster_list) do
if v.type_id == exchange_type_id then
foster_res_id = self.model:GetModuleResIdByStage(v.type_id,v.stage_id)
end
end
local skin_res_id = false
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == exchange_type_id and v.skin_id > 0 then
skin_res_id = v.skin_id
end
end
local skin_sub_res_id = false
for k,v in pairs(role_vo.foster_sub_skin_list) do
if v.type_id == exchange_type_id and v.skin_id > 0 then
skin_sub_res_id = v.skin_id
end
end
if skin_sub_res_id or skin_res_id or foster_res_id then
role_vo:ChangeVar(FosterConst.CHANGE_TAG_LIST[exchange_type_id],skin_sub_res_id or skin_res_id or foster_res_id)
end
end
--珍宝
function FosterController:ChangeRoleForsterInfo( scmd,role_id, is_base_forster)
role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
local role_vo = SceneManager.Instance:GetRoleVo(role_id)
local role = Scene.Instance:GetRole(role_id)
if not role_vo then return end
if scmd.type > 1000 then
--珍宝的要特殊处理补齐参数哦
if scmd.type - 1000 == FosterConst.ModuleId.FWeapon then
--武器的珍宝需要手动折算2次成资源名
if tonumber(scmd.display[2]) > 0 then
scmd.skin_id = ShapeModel:GetModelRes( scmd.type-1000, tonumber(scmd.display[1]), tonumber(scmd.display[2]) )
scmd.skin_id = GameResPath:GetFWeaponResName( role_vo.career,scmd.skin_id)
else
scmd.skin_id = 0
end
else
scmd.skin_id = ShapeModel:GetModelRes( scmd.type-1000, tonumber(scmd.display[1]), tonumber(scmd.display[2]) )
end
scmd.sub_id = tonumber(scmd.display[1])
scmd.star = tonumber(scmd.display[2])
end
local function foster_have_change( type_id )
local have = false
for k,v in pairs(role_vo.foster_list) do
if v.type_id == type_id then
v.stage_id = scmd.display
have = true
break
end
end
return have
end
local function shape_have_change( type_id )
local have = false
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == type_id then
v.sub_id = scmd.sub_id
v.star = scmd.star
v.skin_id = scmd.skin_id
have = true
break
end
end
return have
end
-------------------------
if FosterConst.CHANGE_TAG_LIST[scmd.type] or FosterConst.CHANGE_TAG_LIST[scmd.type-1000] then
if scmd.type < 1000 then
--进阶普通的要换算
local have = foster_have_change(scmd.type)
if not have then
table.insert( role_vo.foster_list, {type_id = scmd.type,stage_id = scmd.display} )
end
else
--珍宝的直接就是资源id
local have = shape_have_change(scmd.type - 1000)
if not have then
table.insert( role_vo.foster_skin_list, {type_id = scmd.type,skin_id = scmd.skin_id,sub_id = scmd.sub_id,star = scmd.star} )
end
end
-------------------------
local exchange_type_id = (scmd.type > 1000) and (scmd.type - 1000) or scmd.type
--这里要把别的系统的数据清理掉 开始
for k,v in pairs(role_vo.foster_sub_skin_list) do
if v.type_id == exchange_type_id then
v.skin_id = 0
v.star = 0
break
end
end
if is_base_forster then
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == exchange_type_id then
v.sub_id = 0
v.star = 0
v.skin_id = 0
break
end
end
end
--这里要把别的系统的数据清理掉 结束
local foster_res_id = false
for k,v in pairs(role_vo.foster_list) do
if v.type_id == exchange_type_id then
foster_res_id = self.model:GetModuleResIdByStage(v.type_id,v.stage_id)
end
end
local skin_res_id = false
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == exchange_type_id and v.skin_id > 0 then
skin_res_id = v.skin_id
end
end
local skin_sub_res_id = false
for k,v in pairs(role_vo.foster_sub_skin_list) do
if v.type_id == exchange_type_id and v.skin_id > 0 then
skin_sub_res_id = v.skin_id
end
end
if skin_sub_res_id or skin_res_id or foster_res_id then
role_vo:ChangeVar(FosterConst.CHANGE_TAG_LIST[exchange_type_id],skin_sub_res_id or skin_res_id or foster_res_id)
end
elseif scmd.type == 1000 + FosterConst.ModuleId.FWeapon then
--武器珍宝
local res_id = scmd.skin_id
local have = false
for k,v in pairs(role_vo.foster_skin_list) do
if v.type_id == FosterConst.ModuleId.FWeapon then
v.skin_id = res_id
have = true
break
end
end
if not have then
table.insert( role_vo.foster_skin_list, {type_id = FosterConst.ModuleId.FWeapon,skin_id = scmd.skin_id,sub_id = scmd.sub_id,star = scmd.star} )
end
-------------------------
if role then
role:ChangeWeapon( )
end
elseif scmd.type == FosterConst.ModuleId.FWeapon then
local have_add = false
for k,v in pairs(role_vo.level_model_list) do
if v.part_pos == FashionPartPos.Weapon then
v.level_model_id = GameResPath:GetFWeaponResName( role_vo.career,self.model:GetModuleResIdByStage(scmd.type,scmd.display) )
have_add = true
end
end
if not have_add then
table.insert( role_vo.level_model_list, {part_pos = FashionPartPos.Weapon,level_model_id = scmd.display} )
end
if role then
role:ChangeWeapon( )
end
end
end