diff --git a/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua b/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua index ed3b94f9a0..f1ab63b16d 100644 --- a/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua @@ -226,10 +226,11 @@ function this.UpdateHeroDatas(_msgHeroData, isFindHandBook) --远征初始化血量 --ExpeditionManager.InitHeroHpValue(heroData) --特训数据 - heroData.HeroTraining=_msgHeroData.HeroTraining + heroData.HeroTraining=_msgHeroData.training + if not heroData.HeroTraining then heroData.HeroTraining={ - heroId=_id, + heroId=heroData.dynamicId, trainingLv=1, attackExp=0, defenseExp=0, @@ -237,6 +238,11 @@ function this.UpdateHeroDatas(_msgHeroData, isFindHandBook) unlockIds=nil, isTraining=0, } end + LogError("heroData.id=="..heroData.dynamicId) + LogError("heroData.HeroTraining.attackExp=="..heroData.HeroTraining.attackExp) + LogError("heroData.HeroTraining.defenseExp=="..heroData.HeroTraining.defenseExp) + LogError("heroData.HeroTraining.hpExp=="..heroData.HeroTraining.hpExp) + LogError("heroData.HeroTraining.trainingLv=="..heroData.HeroTraining.trainingLv) GodSoulManager.BindHeroDatas(_msgHeroData) end @@ -244,7 +250,13 @@ end --设置英雄特训数据 function this.SetHeroTraining(dyn,data) if heroDatas[dyn] then - heroDatas[dyn].HeroTraining=data + -- heroDatas[dyn].HeroTraining.trainingLv=data.HeroTraining.trainingLv + -- heroDatas[dyn].HeroTraining.attackExp=data.HeroTraining.attackExp + -- heroDatas[dyn].HeroTraining.defenseExp=data.HeroTraining.defenseExp + -- heroDatas[dyn].HeroTraining.hpExp=data.HeroTraining.hpExp + -- heroDatas[dyn].HeroTraining.unlockIds=data.HeroTraining.unlockIds + -- heroDatas[dyn].HeroTraining.isTraining=data.HeroTraining.isTraining + heroDatas[dyn].HeroTraining=data end end @@ -1292,6 +1304,19 @@ function this.GetSingleProScoreVal() end end +--设置英雄特训属性 +function this.CaculateAttributeByTraining(dyn,data) + if heroDatas[dyn] then + -- heroDatas[dyn].HeroTraining.trainingLv=data.HeroTraining.trainingLv + -- heroDatas[dyn].HeroTraining.attackExp=data.HeroTraining.attackExp + -- heroDatas[dyn].HeroTraining.defenseExp=data.HeroTraining.defenseExp + -- heroDatas[dyn].HeroTraining.hpExp=data.HeroTraining.hpExp + -- heroDatas[dyn].HeroTraining.unlockIds=data.HeroTraining.unlockIds + -- heroDatas[dyn].HeroTraining.isTraining=data.HeroTraining.isTraining + heroDatas[dyn].HeroTraining=data + end +end + --计算所有装备加成的属性值 local function CalculateHeroUpEquipsProAddVal(_heroId) local addAllProVal = {} @@ -3589,6 +3614,18 @@ function this.GetCurHeroUpLvOrUpStarSData(curHeroData) end end end +--获取某一个星级的所有英雄 +function this.GetAllNumStarData(star) + local heros = {} + local heros2 = {} + for i, v in pairs(heroDatas) do + if v.star==star then + table.insert(heros, v) + end + end + + return heros +end --单个英雄升级红点 function this.LvUpBtnRedPoint(curHeroData) HeroManager.GetCurHeroUpLvOrUpStarSData(curHeroData) @@ -4864,5 +4901,113 @@ function this.ChipIdToHeroId(chipId) return this._ChipToHero[chipId] end end - +--获取对应的属性描述 +function this.GetAttSingleText(id,value) + if propertyConfig[id].Style == 1 then + return propertyConfig[id].Info,string.format("+%s",value) + elseif propertyConfig[id].Style == 2 then + return propertyConfig[id].Info,string.format("+%s",value).."%" + end +end +--获取对应的特训属性 +function this.GetHeroTrainingAddPro(_id) + local hero=nil + for i=1,#this.heroDataLists do + if this.heroDataLists[i].dynamicId==_id then + hero=this.heroDataLists[i] + end + end + if not hero then + return nil + end + local level=hero.HeroTraining.trainingLv + local trainData=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.Train,"HeroID",hero.heroConfig.Id,"Level",level) + if trainData==nil then + return nil + end + local trainingsetting=ConfigManager.GetAllConfigsDataByKey(ConfigName.TrainSetting,"PoolID",trainData.TrainSettingID) + local datas={} + for i=1,#trainingsetting do + LogError(trainingsetting[i].Level) + if trainingsetting[i].Level< level then + for j=1 ,#trainingsetting[i].AttackProperty do + local tAttack=trainingsetting[i].AttackProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + for j=1 ,#trainingsetting[i].HpProperty do + local tAttack=trainingsetting[i].HpProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + for j=1 ,#trainingsetting[i].PhProperty do + local tAttack=trainingsetting[i].PhProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + elseif trainingsetting[i].Level==level then + if hero.HeroTraining.attackExp==trainingsetting[i].TrainExp1 then + for j=1 ,#trainingsetting[i].AttackProperty do + local tAttack=trainingsetting[i].AttackProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + end + if hero.HeroTraining.defenseExp==trainingsetting[i].TrainExp2 then + for j=1 ,#trainingsetting[i].PhProperty do + local tAttack=trainingsetting[i].PhProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + end + if hero.HeroTraining.hpExp==trainingsetting[i].TrainExp3 then + for j=1 ,#trainingsetting[i].HpProperty do + local tAttack=trainingsetting[i].HpProperty[j] + if not datas[tAttack[1]] then + datas[tAttack[1]]=tAttack[2] + else + datas[tAttack[1]]=datas[tAttack[1]]+tAttack[2] + end + end + end + end + end + return datas +end +--判断是否能解锁特训技能 +function this.CheckTrainingSKillCanUnlock(trainingData) + if not trainingData then + return false + end + local lock=false + local OtherCondition=trainingData.trainingData + local conditioncheckCount=0 + for i=1,#OtherCondition do + local t=OtherCondition[i] + for j=1,#this.heroDataLists do + if this.heroDataLists[j].HeroTraining.level>=t[2] and #this.heroDataLists[j].HeroTraining.unlockIds >=t[3] then + conditioncheckCount=conditioncheckCount+1 + end + end + end + if conditioncheckCount==#OtherCondition then + lock=true + end + return lock +end return this \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/Hero/HeroPropManager.lua b/Assets/ManagedResources/~Lua/Modules/Hero/HeroPropManager.lua index a73aa36c7e..0cd5620899 100644 --- a/Assets/ManagedResources/~Lua/Modules/Hero/HeroPropManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Hero/HeroPropManager.lua @@ -171,6 +171,7 @@ function this.CreateHeroCountData(dId) formationId = FormationTypeDef.FORMATION_NORMAL, zhenYingId=0, faxiang={}, + HeroTraining=nil } if not dId then return heroData @@ -196,6 +197,7 @@ function this.CreateHeroCountData(dId) heroData.formationId = FormationTypeDef.FORMATION_NORMAL heroData.zhenYingId = curHeroData.changeProId heroData.faxiang=curHeroData.faxiang + heroData.HeroTraining=curHeroData.HeroTraining return heroData end diff --git a/Assets/ManagedResources/~Lua/Modules/Hero/PropHero.lua b/Assets/ManagedResources/~Lua/Modules/Hero/PropHero.lua index 867b902cfc..262dd39dbd 100644 --- a/Assets/ManagedResources/~Lua/Modules/Hero/PropHero.lua +++ b/Assets/ManagedResources/~Lua/Modules/Hero/PropHero.lua @@ -23,6 +23,7 @@ Hero_Prop_Type = { GodPrint = 11, --神印 FaXiang= 12, --法相 Gift = 13, --礼物 + Training = 14, --特训 } @@ -723,4 +724,14 @@ Hero_Prop_Func = { end return allAddPro, conPropList, teamPropList, conTeamPropList, dePropList end, + [Hero_Prop_Type.Training] = function(_heroData) + local addPro=HeroManager.GetHeroTrainingAddPro(_heroData.dId) + if addPro==nil or #addPro==0 then + return nil + end + for key, value in pairs(addPro) do + LogError("Training key==="..key.." value=="..value) + end + return addPro + end, } \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua index 0d1375edb7..a9e49be1dc 100644 --- a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua @@ -7652,6 +7652,15 @@ function NetManager.TrainingRequest(_id,_heroId,_type,_func) end if msg.training then HeroManager.SetHeroTraining(_heroId,msg.training) + HeroPropManager.SetDirtyByType(_heroId,Hero_Prop_Type.Training) + local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + --获取新战力 + NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL) + local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + LogError("oldWarPower=="..oldWarPower.." tempPower=="..tempPower) + if oldWarPower ~= tempPower then + UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPower,newValue = tempPower}) + end end TrainBuildManager.SetBuildInfo(msg.info) if _func then @@ -7661,5 +7670,72 @@ function NetManager.TrainingRequest(_id,_heroId,_type,_func) end) end - +-- 英雄特训升级请求 +function NetManager.TrainingUpLvRequest(_heroid,_func) + local data=HeroInfoProto_pb.TrainingUpLvRequest() + data.heroId= _heroid + local msg = data:SerializeToString() + Network:SendMessageWithCallBack(MessageTypeProto_pb.TrainingUpLvRequest,MessageTypeProto_pb.TrainingUpLvResponse,msg,function(buffer) + local data = buffer:DataByte() + local msg = HeroInfoProto_pb.TrainingUpLvResponse() + msg:ParseFromString(data) + LogError("升级成功") + -- LogError("TrainBuildManager.trainHeroId len==="..#TrainBuildManager.trainHeroId) + if msg.training then + HeroManager.SetHeroTraining(_heroid,msg.training) + --Hero + local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + HeroPropManager.SetDirtyByType(_heroid,Hero_Prop_Type.Training) + + --获取新战力 + NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL) + local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + LogError("oldWarPower=="..oldWarPower.." tempPower=="..tempPower) + if oldWarPower ~= tempPower then + UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPower,newValue = tempPower}) + end + end + + if _func then + _func() + end + + end) +end +-- 英雄特训技能解锁请求 +function NetManager.TrainingUnlockSkillRequest(_heroid,_unlockId,pokemonIds,magicSoldierIds,TrainingUnlockSkillHeroItem,incarnationCards,playerGifts,_func) + local data=HeroInfoProto_pb.TrainingUnlockSkillRequest() + data.heroId= _heroid + data.unlockId= _unlockId + data.pokemonIds= pokemonIds + data.magicSoldierIds= magicSoldierIds + data.TrainingUnlockSkillHeroItem= TrainingUnlockSkillHeroItem + data.incarnationCards= incarnationCards + data.playerGifts= playerGifts + local msg = data:SerializeToString() + Network:SendMessageWithCallBack(MessageTypeProto_pb.TrainingUnlockSkillRequest,MessageTypeProto_pb.TrainingUnlockSkillResponse,msg,function(buffer) + local data = buffer:DataByte() + local msg = HeroInfoProto_pb.TrainingUnlockSkillResponse() + msg:ParseFromString(data) + LogError("解锁成功") + -- LogError("TrainBuildManager.trainHeroId len==="..#TrainBuildManager.trainHeroId) + if msg.training then + HeroManager.SetHeroTraining(_heroid,msg.training) + HeroPropManager.SetDirtyByType(_heroid,Hero_Prop_Type.Training) + local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + --获取新战力 + NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL) + local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) + LogError("oldWarPower=="..oldWarPower.." tempPower=="..tempPower) + if oldWarPower ~= tempPower then + UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPower,newValue = tempPower}) + end + end + + if _func then + _func() + end + + end) +end return this \ No newline at end of file