require("Base/BasePanel")
RoleInfoLayout = Inherit(BasePanel)
local this = RoleInfoLayout
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local heroSkinConfig = ConfigManager.GetConfig(ConfigName.HeroSkin)
local costItemList--升级突破静态材料
local isUpLvMaterials=true--升级 突破 材料是否充足
local allAddProVal={}--所有属性加成值
local lvUpShowProList={}--升级后展示的属性提升list
local isHeroUpTuPo=false--是否可突破
local upTuPoRankUpConfig={}--即将要突破的数据
local upStarRankUpConfig={}--即将要升星的数据
local curStarRankUpConfig={}--当前升星的数据
local curTuPoRankUpConfig={}--当前突破的数据
--长按升级状态
local _isClicked = false
local _isReqLvUp = false
local _isLongPress = false
this.timePressStarted = 0--监听长按事件
this.priThread = nil--协同程序播放升级属性提升值动画用
local isTriggerLongClick = false--长按是否升过级
local pinjieImage={"r_hero_pinjiebiao_01","r_hero_pinjiebiao_02"} --该死的品阶图片 1是未激活 2是激活
local oldLv = 0
local curHeroData--当前英雄信息
local parent = {}
local isUpZhen = false--当前英雄是否上阵
local isHeroUpStar
local herodatas = {}
this.isPressed = false
function RoleInfoLayout:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = RoleInfoLayout })
return b
end
--初始化组件(用于子类重写)
function RoleInfoLayout:InitComponent()
this.spLoader = SpriteLoader.New()
--情报
this.atkPro=Util.GetGameObject(self.gameObject,"pro/atk")
this.hpPro=Util.GetGameObject(self.gameObject,"pro/hp")
this.phyDef=Util.GetGameObject(self.gameObject,"pro/phyDef")
this.magDef=Util.GetGameObject(self.gameObject,"pro/magDef")
this.lv = Util.GetGameObject(self.gameObject,"pro/lv/proValue"):GetComponent("Text")
this.skillGrid=Util.GetGameObject(self.gameObject,"skill")
this.selsectSkillImage=Util.GetGameObject(self.gameObject,"selsectSkillImage")
this.baseAttri = Util.GetGameObject(self.gameObject,"Ima/Text"):GetComponent("Text")
this.allProButton=Util.GetGameObject(self.gameObject,"allProButton")
this.pinjieList={}--品阶预设容器
this.pinjieRoot=Util.GetGameObject(self.gameObject,"Pinjie")
this.pinjiePre=Util.GetGameObject(self.gameObject,"Pre")
--升级
this.itemPre=Util.GetGameObject(self.gameObject,"upLv/itemPre")
this.itemGrid=Util.GetGameObject(self.gameObject,"upLv/itemGrid")
this.upLvBtn=Util.GetGameObject(self.gameObject,"upLvBtn")
this.upLvBtnRedPoint=Util.GetGameObject(self.gameObject,"upLvBtn/redPoint")
this.upLvTrigger = Util.GetEventTriggerListener(this.upLvBtn)
this.upLvBtnText=Util.GetGameObject(self.gameObject,"upLvBtn/Text"):GetComponent("Text")
this.upLvBtnImage=Util.GetGameObject(self.gameObject,"upLvBtn"):GetComponent("Image")
this.upLvBtnTiShiText=Util.GetGameObject(self.gameObject,"upLv/Image/Text"):GetComponent("Text")
this.upLvGoldBtn=Util.GetGameObject(self.gameObject,"upLv/gold")
this.upLvGoldText=Util.GetGameObject(self.gameObject,"upLv/gold/Text"):GetComponent("Text")
this.tipUpLv=Util.GetGameObject(self.gameObject,"upLv/tip")
this.noUpLvText=Util.GetGameObject(self.gameObject,"noUpLvText")
this.gongmingText=Util.GetGameObject(self.gameObject,"gongmingText")
Util.GetGameObject(this.gongmingText,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite("h_hongmengbei_gongmingzhong_zh")
this.upLv=Util.GetGameObject(self.gameObject,"upLv")
this.lvUpGo=Util.GetGameObject(self.gameObject,"lvUpGo")
this.lvUpGoImage=Util.GetGameObject(self.gameObject,"lvUpGo/Image")
for i = 1, 5 do
lvUpShowProList[i]=Util.GetGameObject(this.lvUpGo.transform,"proPreParent/proPre"..i)
end
lvUpShowProList[5]:SetActive(false)
end
--绑定事件(用于子类重写)
function RoleInfoLayout:BindEvent()
--升级
Util.AddClick(this.upLvBtn, function()
if this.isGongMing then
PopupTipPanel.ShowTip("神将正在共鸣中,无法升级!")
return
end
if Time.realtimeSinceStartup - RoleInfoLayout.timePressStarted <= 0.4 then
this:LvUpClick(true)
end
end)
--长按升级按下状态
this._onPointerDown = function(Pointgo, data)
if this.isGongMing then
return
end
isTriggerLongClick = false
_isClicked = true
RoleInfoLayout.timePressStarted = Time.realtimeSinceStartup
oldLv = curHeroData.lv
this.isPressed = true
end
--长按升级抬起状态
this._onPointerUp = function(Pointgo, data)
if this.isGongMing then
PopupTipPanel.ShowTip("神将正在共鸣中,无法升级!")
return
end
if _isLongPress and isTriggerLongClick then
--连续升级抬起请求升级
this:LongLvUpClick(oldLv)
end
_isClicked = false
_isLongPress = false
this.isPressed = false
end
this.upLvTrigger.onPointerDown = this.upLvTrigger.onPointerDown + this._onPointerDown
this.upLvTrigger.onPointerUp = this.upLvTrigger.onPointerUp + this._onPointerUp
--显示所有属性
Util.AddClick(this.allProButton, function()
UIManager.OpenPanel(UIName.RoleProInfoPopup,allAddProVal,curHeroData.heroConfig,true,nil)
end)
end
--添加事件监听(用于子类重写)
function RoleInfoLayout:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.UpdateHeroUpLvAndBreakMaterialShow)
end
--移除事件监听(用于子类重写)
function RoleInfoLayout:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.UpdateHeroUpLvAndBreakMaterialShow)
end
function RoleInfoLayout:OnShow()
self.gameObject:SetActive(true)
FixedUpdateBeat:Add(this.OnUpdate, self)--长按方法注册
end
function RoleInfoLayout:SetData(_sortinglayer,_parent,_curHerodata,_isUpZhen,_heroDatas)
this.sortingOrder = _sortinglayer
curHeroData = _curHerodata
parent = _parent
isUpZhen = _isUpZhen
herodatas = _heroDatas
this:UpdateHeroInfoData()
this:GetCurHeroUpLvOrUpStarSData()
this:UpdateHeroUpLvAndBreakData()--升级
end
--更新英雄情报数据
function this:UpdateHeroInfoData()
curTuPoRankUpConfig = heroRankupConfig[curHeroData.breakId]
curStarRankUpConfig=heroRankupConfig[curHeroData.upStarId]
local EquipSignUnlock = ConfigManager.GetConfigData(ConfigName.GameSetting,1).EquipSignUnlock
--动态品阶
local pId=0 --当前突破的阶数
if curHeroData.breakId~=0 then
pId= heroRankupConfig[curHeroData.breakId].Phase[2]
end
local hruConfig= ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.HeroRankupConfig,"Star",curHeroData.heroConfig.Star,"Show",1) --动态获取不同英雄最大突破等阶
for i = 1, #hruConfig do --动态生成
local item=this.pinjieList[i]
if not item then
item= newObjToParent(this.pinjiePre,this.pinjieRoot)
item.name="Pre"..i
this.pinjieList[i]=item
end
this.pinjieList[i]:GetComponent("Image").sprite=this.spLoader:LoadSprite(i<=pId and pinjieImage[2] or pinjieImage[1])
end
for n = 0, this.pinjieRoot.transform.childCount-1 do --超过品阶关闭显示
this.pinjieRoot.transform:GetChild(n).gameObject:SetActive(n+1<=#hruConfig)
end
--计算面板属性
if isUpZhen then
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,curHeroData.dynamicId)
allAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
else
allAddProVal=HeroManager.CalculateHeroAllProValList(1,curHeroData.dynamicId,false)
end
this:ProShow(this.atkPro,allAddProVal,HeroProType.Attack)
this:ProShow(this.hpPro,allAddProVal,HeroProType.Hp)
this:ProShow(this.phyDef,allAddProVal,HeroProType.PhysicalDefence)
this:ProShow(this.magDef,allAddProVal,HeroProType.MagicDefence)
local curLvEnd = 30
if curHeroData.breakId > 0 then
curLvEnd = heroRankupConfig[curHeroData.breakId].OpenLevel
end
if curHeroData.upStarId > 0 then
if heroRankupConfig[curHeroData.upStarId].OpenLevel > curLvEnd then
curLvEnd = heroRankupConfig[curHeroData.upStarId].OpenLevel
end
end
if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
-- body#FFCC00
this.lv.text= ""..curHeroData.lv..""
elseif HarmonyManager:IsEnvoy(curHeroData.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then
this.lv.text= ""..curHeroData.lv..""
else
-- body
this.lv.text= curHeroData.lv.."/"..curLvEnd
end
--技能点击特殊处理
this.selsectSkillImage:SetActive(false)
this.baseAttri.alignment = GetCurLanguage() ~= 2 and "MiddleCenter" or "MiddleRight"
this.UpdateHeroUpStarProUpSkillShow(this.skillGrid,curHeroData.skillIdList,curHeroData.passiveSkillList)
end
function this:ProShow(go,allAddProVal,HeroProType,nextallAddProVal)
local curProSConFig = ConfigManager.GetConfigData(ConfigName.PropertyConfig,HeroProType)
Util.GetGameObject(go,"proName"):GetComponent("Text").text = GetLanguageStrById(curProSConFig.Info)..":"
Util.GetGameObject(go,"proValue"):GetComponent("Text").text = allAddProVal[HeroProType]
Util.GetGameObject(go,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyTypeIconDef[HeroProType])
if nextallAddProVal then
Util.GetGameObject(go,"nextproValue"):GetComponent("Text").text = nextallAddProVal[HeroProType]
end
end
--更新英雄升级 和 突破 的材料显示
function this:UpdateHeroUpLvAndBreakMaterialShow()
if isHeroUpTuPo and upTuPoRankUpConfig and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
costItemList=upTuPoRankUpConfig.ConsumeMaterial
else
costItemList=ConfigManager.GetConfigData(ConfigName.HeroLevelConfig, curHeroData.lv).Consume
end
if curHeroData.lv>=HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then
this.noUpLvText:SetActive(true)
this.upLv:SetActive(false)
-- this.upLvBtn:SetActive(false)
--移除没有隐私是为了按钮抬起检测 不能隐藏 注意哦
this.upLvBtn:GetComponent("RectTransform").anchoredPosition = Vector2.New(2098, -42.00134 )
else
Util.ClearChild(this.itemGrid.transform)
this.noUpLvText:SetActive(false)
this.upLv:SetActive(true)
-- this.upLvBtn:SetActive(true)
this.upLvBtn:GetComponent("RectTransform").anchoredPosition = Vector2.New(322.3, -90)
isUpLvMaterials=true
for i = 1, #costItemList do
if costItemList[i][1]~=14 then
local go=newObject(this.itemPre)
go.transform:SetParent(this.itemGrid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition=Vector3.zero;
go:SetActive(true)
--Log("costItemList[i][1] "..costItemList[i][1])
if BagManager.GetItemCountById(costItemList[i][1])%s/%s",PrintWanNum2(BagManager.GetItemCountById(costItemList[i][1])),PrintWanNum2(costItemList[i][2]))
else
go.transform:Find("Image").gameObject:SetActive(false)--隐藏加号
Util.GetGameObject(go.transform,"Text"):GetComponent("Text").text=string.format("%s/%s",PrintWanNum2(BagManager.GetItemCountById(costItemList[i][1])),PrintWanNum2(costItemList[i][2]))
end
Util.GetGameObject(go.transform, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[costItemList[i][1]].ResourceID))
go.transform:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[costItemList[i][1]].Quantity))
Util.AddOnceClick(Util.GetGameObject(go.transform,"icon"),function ()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,costItemList[i][1])
end)
else
if BagManager.GetItemCountById(costItemList[i][1])%s",costItemList[i][2])
else
this.upLvGoldText.text=string.format("%s",costItemList[i][2])
end
Util.AddOnceClick(this.upLvGoldBtn,function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,costItemList[i][1])
end)
end
end
end
this.isGongMing = HarmonyManager.IsGongMing(curHeroData)
if this.isGongMing then
this.gongmingText:SetActive(true)
this.upLv:SetActive(false)
-- this.upLvBtn:SetActive(false)
this.noUpLvText:SetActive(false)
this.upLvBtn:GetComponent("RectTransform").anchoredPosition = Vector2.New(2098, -42.00134 )
return
else
this.gongmingText:SetActive(false)
end
--红点检测
local upLvRedpoint = HeroManager.LvUpBtnRedPoint(curHeroData)
this.upLvBtnRedPoint:SetActive(upLvRedpoint)
parent:CheckRedPointType(1,upLvRedpoint)
end
--单个技能显示
function this.UpdateHeroUpStarProUpSkillShow(skillGridGO,skillTabs,passiveSkills)
skillGridGO:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1
local triggerCallBack
for i = 1, skillGridGO.transform.childCount do
local go= skillGridGO.transform:GetChild(i-1).gameObject
local skillType = Util.GetGameObject(go.transform,"skillType")
if #skillTabs>=i then--(#passiveSkills+#skillTabs)>=i then
local curSkillData = skillTabs[i]
if curSkillData and curSkillData.skillConfig and curSkillData.skillConfig.Name then
go:SetActive(true)
local skillTypeImage = Util.GetGameObject(go.transform,"skillImage/Image"):GetComponent("Image")
--if skillType then
if curSkillData.skillConfig.Type == SkillType.Pu then
--skillType:GetComponent("Text").text=SkillTypeStr[SkillType.Pu]
skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Pu])--普技
elseif curSkillData.skillConfig.Type == SkillType.Jue then
--skillType:GetComponent("Text").text=SkillTypeStr[SkillType.Jue]
skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Jue])--绝技
elseif curSkillData.skillConfig.Type == SkillType.Bei then
--skillType:GetComponent("Text").text=SkillTypeStr[SkillType.Bei]
skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Bei])--被动技
end
--end
local upGo = Util.GetGameObject(go.transform,"up")
if upGo then
if curSkillData.isShowUpImage ~= nil and curSkillData.isShowUpImage == false then
upGo:SetActive(false)
else
upGo:SetActive(true)
end
end
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(curSkillData.skillConfig.Icon))--"i_act_ygmd2_2")
if GetCurLanguage() ~= 0 and LengthString(GetLanguageStrById(curSkillData.skillConfig.Name)) > 10 then
Util.GetGameObject(go.transform,"skillImage/skillName"):GetComponent("Text").text = SubString(GetLanguageStrById(curSkillData.skillConfig.Name),10).."..."
else
Util.GetGameObject(go.transform,"skillImage/skillName"):GetComponent("Text").text= GetLanguageStrById(curSkillData.skillConfig.Name)--(curSkillData.skillId % 10)
end
else
go:SetActive(false)
end
Util.AddOnceClick(Util.GetGameObject(go.transform,"icon"), function()
if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
end
this.selsectSkillImage:SetActive(true)
this.selsectSkillImage.transform.position=Util.GetGameObject(go.transform,"icon").transform.position
local maxLv= HeroManager.GetHeroSkillMaxLevel(curHeroData.heroConfig.Id,curSkillData.skillConfig.Type)
local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,curSkillData,1,10,maxLv,i)
skillGridGO:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1
triggerCallBack = function (panelType, p)
if panelType == UIName.SkillInfoPopup and panel == p then --监听到SkillInfoPopup关闭,把层级设回去
skillGridGO:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
this.selsectSkillImage:SetActive(false)
end
end
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
end)
else
go:SetActive(false)
end
end
end
--获取当前英雄的下一突破 和 升星 静态数据
function RoleInfoLayout:GetCurHeroUpLvOrUpStarSData()
isHeroUpTuPo = false
isHeroUpStar = false
upTuPoRankUpConfig = {}
upStarRankUpConfig = {}
local heroRankUpConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
for i, v in ConfigPairs(heroRankUpConfig) do
if v.Star==curHeroData.heroConfig.Star then--初始星级相等
if v.Show==1 then -- 1 突破
if v.Id ~= curHeroData.breakId and curHeroData.lv == v.LimitLevel then--and curHeroData.star == v.LimitStar
--Log("突破 "..v.Id)
isHeroUpTuPo = true
upTuPoRankUpConfig = v
end
end
if v.Show==2 then -- 2 升星
if v.Id ~= curHeroData.upStarId and curHeroData.star == v.LimitStar then
--Log("升星 "..v.Id)
upStarRankUpConfig=v
isHeroUpStar=true
end
end
end
end
end
--更新英雄升级 和 突破数据
function this:UpdateHeroUpLvAndBreakData()
-- 升级获取突破 和 升星相应heroRankUpConfig静态数据
-- LogError("curHeroData "..curHeroData.breakId)
if isHeroUpTuPo and upTuPoRankUpConfig and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
this.tipUpLv:GetComponent("Text").text=Language[11804]
this.tipUpLv:SetActive(true)
this.upLvBtnText.text=Language[11805]
this.upLvBtnImage.sprite = this.spLoader:LoadSprite("r_hero_button_001")--r_chouka_button_004
this.upLvBtnTiShiText.text=Language[11806]
_isClicked = false
_isReqLvUp = false
else
if curHeroData.lv < 30 then--策划规定三十级之前一直显示持续长按可快速升级
this.tipUpLv:SetActive(true)
this.tipUpLv:GetComponent("Text").text = Language[11807]
else
this.tipUpLv:SetActive(false)
end
this.upLvBtnText.text=Language[11063]
this.upLvBtnImage.sprite = this.spLoader:LoadSprite("r_hero_button_002")
this.upLvBtnTiShiText.text=Language[11434]
if isHeroUpStar and upStarRankUpConfig and curTuPoRankUpConfig and curTuPoRankUpConfig.JudgeClass==1 and curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then--当前突破全部完成
if curStarRankUpConfig then--进阶过处理
if curHeroData.lv == curStarRankUpConfig.OpenLevel then
this.tipUpLv:GetComponent("Text").text=Language[11804]
this.tipUpLv:SetActive(true)
end
else--从未进阶过处理
this.tipUpLv:GetComponent("Text").text=Language[11804]
this.tipUpLv:SetActive(true)
end
end
end
this:UpdateHeroUpLvAndBreakMaterialShow()
end
function RoleInfoLayout:OnSortingOrderChange()
end
--升级按钮点击事件处理
function RoleInfoLayout:LvUpClick(isSingleLvUp)
--是否为最大等级
-- --LogGreen("isSingleLvUp "..tostring(isSingleLvUp))
if curHeroData.lv>=HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then
PopupTipPanel.ShowTip(Language[11788])
_isClicked = false
_isReqLvUp = false
return
end
--如果此时需要进阶 每次都要跳转
if isHeroUpStar and upStarRankUpConfig and curTuPoRankUpConfig and curTuPoRankUpConfig.JudgeClass==1 and curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then--当前突破全部完成
if curStarRankUpConfig then--进阶过处理
if curHeroData.lv == curStarRankUpConfig.OpenLevel then
_isClicked = false
_isReqLvUp = false
local showTipStr = Language[11808]
local showIndex = 2
local showBtnTipStr = Language[11809]
if curHeroData.star == HeroManager.awakeStarIndex then
showTipStr = Language[11810]
showBtnTipStr = Language[11811]
showIndex = 3
end
if showIndex == 3 then
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.RoleAwake) then
MsgPanel.ShowTwo(showTipStr, nil, function()
parent:SetSelectBtn(showIndex)
parent:OnPageTabChange(showIndex)
end,Language[10731],showBtnTipStr)
else
PopupTipPanel.ShowTip(Language[11812])--需要先进行觉醒!
end
else
MsgPanel.ShowTwo(showTipStr, nil, function()
parent:SetSelectBtn(showIndex)
parent:OnPageTabChange(showIndex)
end,Language[10731],showBtnTipStr)
end
else
if isUpLvMaterials then
if isSingleLvUp then--是否是单次升级
if not curTuPoRankUpConfig or curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then
PopupTipPanel.ShowTip("无法升级")
return
end
NetManager.HeroLvUpEvent(curHeroData.dynamicId,curHeroData.lv + 1,curHeroData.lv,function (msg)
this:DeleteLvUpMaterials(isSingleLvUp,msg)
end)
else
isTriggerLongClick = true
this:DeleteLvUpMaterials(isSingleLvUp)
end
else
_isClicked = false
_isReqLvUp = false
if isHeroUpTuPo and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
PopupTipPanel.ShowTip(Language[11813])
else
PopupTipPanel.ShowTip(Language[11814])
end
end
end
else--从未进阶过处理
_isClicked = false
_isReqLvUp = false
MsgPanel.ShowTwo(Language[11808], nil, function()
parent:SetSelectBtn(2)
parent:OnPageTabChange(2)
end,Language[10731],Language[11809])
end
else
if isUpLvMaterials then
if isSingleLvUp then--是否是单次升级
local curUpLv = curHeroData.lv
if isHeroUpTuPo and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
curUpLv = curHeroData.lv
else
curUpLv = curHeroData.lv + 1
end
-- --LogGreen("isSingleLvUp "..tostring(isSingleLvUp))
NetManager.HeroLvUpEvent(curHeroData.dynamicId,curUpLv,curHeroData.lv,function (msg)
this:DeleteLvUpMaterials(isSingleLvUp,msg)
end)
else
isTriggerLongClick = true
this:DeleteLvUpMaterials(isSingleLvUp)
end
else
_isClicked = false
_isReqLvUp = false
if isHeroUpTuPo and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
PopupTipPanel.ShowTip(Language[11813])
else
PopupTipPanel.ShowTip(Language[11814])
end
end
end
end
--长按升级结束后请求协议
function RoleInfoLayout:LongLvUpClick(oldLv)
if not curTuPoRankUpConfig or curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then
PopupTipPanel.ShowTip("无法升级")
return
end
NetManager.HeroLvUpEvent(curHeroData.dynamicId,curHeroData.lv,oldLv,function (msg)
this:DeleteLvUpMaterials2(msg)
end)
end
--扣除升级 突破 消耗的材料 更新英雄数据
function RoleInfoLayout:DeleteLvUpMaterials(isSingleLvUp,msg)
if isSingleLvUp == false then--连续升级的时候需要自己先扣除
for i = 1, #costItemList do
--Log(string.format("扣除id=%s 数量=%s",costItemList[i][1],costItemList[i][2]))
BagManager.HeroLvUpUpdateItemsNum(costItemList[i][1],costItemList[i][2])
end
end
-- for i, v in pairs(heroDatas) do
-- if curHeroData == v then
if isHeroUpTuPo and upTuPoRankUpConfig and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then
UIManager.OpenPanel(UIName.RoleUpLvBreakSuccessPanel,curHeroData,upTuPoRankUpConfig.Id,upTuPoRankUpConfig.OpenLevel)
curHeroData.breakId=upTuPoRankUpConfig.Id
curHeroData.breakId=curHeroData.breakId
--突破有可能会升星
if curHeroData.star 0.4 then
_isLongPress = true
if not _isReqLvUp then
_isReqLvUp = true
this:LvUpClick(false)
end
end
end
end
--播放升级 属性提升动画
function this.ShowProAddVal(allAddProValOld)
this.lvUpGo:SetActive(true)
Util.GetGameObject(lvUpShowProList[1], "proPre/vale"):GetComponent("Text").text="+"..allAddProVal[HeroProType.Attack]-allAddProValOld[HeroProType.Attack]
Util.GetGameObject(lvUpShowProList[2], "proPre/vale"):GetComponent("Text").text="+"..allAddProVal[HeroProType.Hp]-allAddProValOld[HeroProType.Hp]
Util.GetGameObject(lvUpShowProList[3], "proPre/vale"):GetComponent("Text").text="+"..allAddProVal[HeroProType.PhysicalDefence]-allAddProValOld[HeroProType.PhysicalDefence]
Util.GetGameObject(lvUpShowProList[4], "proPre/vale"):GetComponent("Text").text="+"..allAddProVal[HeroProType.MagicDefence]-allAddProValOld[HeroProType.MagicDefence]
--Util.GetGameObject(lvUpShowProList[5], "proPre/vale"):GetComponent("Text").text="+"..allAddProVal[HeroProType.Speed]-allAddProValOld[HeroProType.Speed]
this.ThreadShowProAddVal()
end
function this.ThreadShowProAddVal()
if this.priThread then
coroutine.stop(this.priThread)
this.priThread = nil
end
table.walk(lvUpShowProList, function(privilegeItem)
privilegeItem:SetActive(false)
end)
this.priThread = coroutine.start(function()
for i = 1, 4 do
lvUpShowProList[i]:SetActive(false)
PlayUIAnims(lvUpShowProList[i])
coroutine.wait(0.04)
lvUpShowProList[i]:SetActive(true)
coroutine.wait(0.08)
end
this.lvUpGo:SetActive(false)
end)
end
function RoleInfoLayout:OnHide()
self.gameObject:SetActive(false)
end
function RoleInfoLayout:OnClose()
FixedUpdateBeat:Remove(this.OnUpdate, self)
if this.priThread then
coroutine.stop(this.priThread)
-- 关闭显示
for i = 1, 4 do
lvUpShowProList[i]:SetActive(false)
end
this.lvUpGo:SetActive(false)
this.priThread = nil
end
this.pinjieList={}
end
return RoleInfoLayout