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 skillConfig = ConfigManager.GetConfig(ConfigName.SkillConfig)
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local passiveSkillLogicConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
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 oldLv = 0
local curHeroData--当前英雄信息
local parent = {}
local isUpZhen = false--当前英雄是否上阵
local isHeroUpStar
local herodatas = {}
this.isPressed = false
local proSort = {
[1] = HeroProType.Attack,
[2] = HeroProType.Hp,
[3] = HeroProType.PhysicalDefence,
[4] = HeroProType.MagicDefence,
}
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.playplyanim = Util.GetGameObject(self.gameObject,"playplyanim")
this.lvRoot = Util.GetGameObject(self.gameObject,"content/lv")
this.lv = Util.GetGameObject(self.gameObject,"content/lv/proValue"):GetComponent("Text")
this.proList = {}
for i = 1,4 do
this.proList[i] = {}
this.proList[i].go = Util.GetGameObject(self.gameObject,"content/pro/proPre"..i)
this.proList[i].proImage = Util.GetGameObject(this.proList[i].go,"Image"):GetComponent("Image")
this.proList[i].value = Util.GetGameObject(this.proList[i].go,"proValue"):GetComponent("Text")
end
this.allProButton = Util.GetGameObject(self.gameObject,"content/pro")
this.posBtn = Util.GetGameObject(self.gameObject,"content/posBtn")
this.posInfo = Util.GetGameObject(this.posBtn,"PosInfo"):GetComponent("Text")
this.proTip = Util.GetGameObject(self.gameObject,"content/pro/tishi")
this.skillGrid=Util.GetGameObject(self.gameObject,"content/skill")
this.selsectSkillImage=Util.GetGameObject(this.skillGrid,"selsectSkillImage")
this.skillList = {}
for i = 1,6 do
this.skillList[i] = {}
this.skillList[i].go = Util.GetGameObject(this.skillGrid,"sBg"..i)
this.skillList[i].icon = Util.GetGameObject(this.skillList[i].go,"icon"):GetComponent("Image")
this.skillList[i].pos = Util.GetGameObject(this.skillList[i].go,"pos"):GetComponent("Image")
this.skillList[i].pro = Util.GetGameObject(this.skillList[i].go,"pro"):GetComponent("Image")
this.skillList[i].proText = Util.GetGameObject(this.skillList[i].pro.gameObject,"Text"):GetComponent("Text")
this.skillList[i].skillName = Util.GetGameObject(this.skillList[i].go,"skillName"):GetComponent("Text")
this.skillList[i].frame = Util.GetGameObject(this.skillList[i].go,"frame"):GetComponent("Image")
end
this.line1 = Util.GetGameObject(this.skillGrid,"line1")
this.line2 = Util.GetGameObject(this.skillGrid,"line2")
this.upLv = Util.GetGameObject(self.gameObject,"content/upLv")
--升级
this.itemPre=Util.GetGameObject(this.upLv,"costPre")
this.itemGrid=Util.GetGameObject(this.upLv,"itemGrid")
this.costList = {}
for i = 1,this.itemGrid.transform.childCount do
this.costList[i] = {}
this.costList[i].go = this.itemGrid.transform:GetChild(i - 1)
this.costList[i].icon = Util.GetGameObject( this.costList[i].go,"icon"):GetComponent("Image")
this.costList[i].costText = Util.GetGameObject( this.costList[i].go,"Text"):GetComponent("Text")
end
this.upLvBtn=Util.GetGameObject(this.upLv,"upLvBtn")
this.upLvBtnRedPoint=Util.GetGameObject(this.upLvBtn,"redPoint")
this.upLvTrigger = Util.GetEventTriggerListener(this.upLvBtn)
this.upLvBtnText=Util.GetGameObject(this.upLvBtn,"Text"):GetComponent("Text")
this.upLvBtnImage=this.upLvBtn:GetComponent("Image")
this.tipUpLv=Util.GetGameObject(this.upLv,"tip"):GetComponent("Text")
this.noUpLvText=Util.GetGameObject(self.gameObject,"content/noUpLvText")
this.gongmingText=Util.GetGameObject(self.gameObject,"gongming")
this.hognmengzhenTip = Util.GetGameObject(this.gongmingText,"hognmengzhenTip")
this.hognmengbeiTip = Util.GetGameObject(this.gongmingText,"hognmengbeiTip")
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:OnPointerUp(Pointgo,data)--抬起
if self.isPressed then
self.isPressed = false
self:RefreshBottom(true)
end
end
--点击或长按处理升级处理
function RoleInfoLayout:OnPointerDown(Pointgo,data)--按下
self.isPressed = true
end
--绑定事件(用于子类重写)
function RoleInfoLayout:BindEvent()
--角色定位按钮
Util.AddClick(this.posBtn,function()
UIManager.OpenPanel(UIName.RolePosInfoPopup,curHeroData.heroConfig,curHeroData.star)
end)
--升级
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)
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, this.SkillInfoPopupClose)
end
--移除事件监听(用于子类重写)
function RoleInfoLayout:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.UpdateHeroUpLvAndBreakMaterialShow)
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, this.SkillInfoPopupClose)
end
function this.SkillInfoPopupClose(panelType, p)
if panelType == UIName.SkillInfoPopup and this.skillPanel == p then --监听到SkillInfoPopup关闭,把层级设回去
this.selsectSkillImage:SetActive(false)
this.skillPanel = nil
end
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()--升级
--角色定位按钮
this.posBtn.gameObject:SetActive(curHeroData.heroConfig.ShowHeroLocation==1)
this.posInfo.text = curHeroData.heroConfig.HeroLocationDesc1
end
--更新英雄情报数据
function this:UpdateHeroInfoData()
curTuPoRankUpConfig = heroRankupConfig[curHeroData.breakId]
curStarRankUpConfig = heroRankupConfig[curHeroData.upStarId]
--计算面板属性
local WarPower
if isUpZhen then
allAddProVal = HeroPropManager.GetHeroProp(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
else
allAddProVal = HeroPropManager.GetHeroProp(curHeroData.dynamicId)
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
end
for i = 1,#this.proList do
this:ProShow(this.proList[i],allAddProVal,proSort[i])
end
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
this.lv.text= curHeroData.lv.."/"..curLvEnd
end
ForceRebuildLayout(this.lvRoot.transform)
--技能点击特殊处理
this.selsectSkillImage:SetActive(false)
this.UpdateHeroUpStarProUpSkillShow()
end
function this:ProShow(go,allAddProVal,HeroProType,nextallAddProVal)
--go.proName.text = GetLanguageStrById(curProSConFig.Info)..":"
go.proImage.sprite = this.spLoader:LoadSprite(PropertyTypeIconDef[HeroProType])
go.value.text = allAddProVal[HeroProType]
end
function this.GetSkillsData()
local skillList = {}
local skillIdList = {}
if curHeroData.heroConfig.OpenSkillRules then
for i = 1, #curHeroData.heroConfig.OpenSkillRules do
if not skillIdList[curHeroData.heroConfig.OpenSkillRules[i][2]] then
local heroSkill = {}
heroSkill.skillId = curHeroData.heroConfig.OpenSkillRules[i][2]
heroSkill.skillConfig = skillConfig[heroSkill.skillId]
if curHeroData.star >= curHeroData.heroConfig.OpenSkillRules[i][1] then
heroSkill.state = 1
else
heroSkill.state = 0
end
heroSkill.star = curHeroData.heroConfig.OpenSkillRules[i][1]
heroSkill.quality = 0
heroSkill.skillType = 0
skillIdList[curHeroData.heroConfig.OpenSkillRules[i][2]] = curHeroData.heroConfig.OpenSkillRules[i][2]
table.insert(skillList, heroSkill)
end
end
end
if curHeroData.star < 11 then
if curHeroData.heroConfig.OpenPassiveSkillRules then
for i = 1, #curHeroData.heroConfig.OpenPassiveSkillRules do
if curHeroData.heroConfig.OpenPassiveSkillRules[i][1] == 2 and passiveSkillLogicConfig[curHeroData.heroConfig.OpenPassiveSkillRules[i][3]].Judge == 1 then
if not skillIdList[curHeroData.heroConfig.OpenPassiveSkillRules[i][3]] then
local heroSkill = {}
heroSkill.skillId = curHeroData.heroConfig.OpenPassiveSkillRules[i][3]
heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId]
if curHeroData.star >= curHeroData.heroConfig.OpenPassiveSkillRules[i][2] - 1 then
heroSkill.state = 1
else
heroSkill.state = 0
end
heroSkill.star = curHeroData.heroConfig.OpenPassiveSkillRules[i][2] - 1
heroSkill.quality = 0
heroSkill.skillType = 1
skillIdList[curHeroData.heroConfig.OpenPassiveSkillRules[i][3]] = curHeroData.heroConfig.OpenPassiveSkillRules[i][3]
table.insert(skillList, heroSkill)
end
end
end
end
else
local heroSkillList = this.GetAwakenSkill()
if heroSkillList then
for i = 1, #heroSkillList do
table.insert(skillList, heroSkillList[i])
end
end
if curHeroData.heroConfig.MaxRank > 11 then
for i = 1, #curHeroData.heroConfig.Awaken do
if curHeroData.heroConfig.Awaken[i][1] == 2 and curHeroData.heroConfig.Awaken[i][2] == 27 then
local heroSkill = {}
heroSkill.skillId = curHeroData.heroConfig.Awaken[i][3]
heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId]
if curHeroData.star == 14 then
heroSkill.state = 1
else
heroSkill.state = 0 --是否置灰
end
heroSkill.star = 14
heroSkill.quality = 1 --决定技能的品质框
heroSkill.skillType = 0 --是否显示对比技能
table.insert(skillList, heroSkill)
break
end
end
end
end
return skillList
end
function this.GetAwakenSkill()
local starIdlist = {}
local skillIdList = {}
local skillList = {}
if curHeroData.heroConfig.Awaken then
for i = 1, #curHeroData.heroConfig.Awaken do
if curHeroData.heroConfig.Awaken[i][1] == 2 and passiveSkillLogicConfig[curHeroData.heroConfig.Awaken[i][3]].Judge == 1 and curHeroData.heroConfig.Awaken[i][2] < 12 then
if not skillIdList[curHeroData.heroConfig.Awaken[i][3]] and not starIdlist[curHeroData.heroConfig.Awaken[i][2]] then
local heroSkill = {}
heroSkill.skillId = curHeroData.heroConfig.Awaken[i][3]
heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId]
if curHeroData.star >= curHeroData.heroConfig.Awaken[i][2] - 1 then
heroSkill.state = 1
else
heroSkill.state = 0
end
heroSkill.star = curHeroData.heroConfig.Awaken[i][2] - 1
heroSkill.quality = 1
heroSkill.skillType = 0
starIdlist[curHeroData.heroConfig.Awaken[i][2]] = curHeroData.heroConfig.Awaken[i][2]
skillIdList[curHeroData.heroConfig.Awaken[i][3]] = curHeroData.heroConfig.Awaken[i][3]
table.insert(skillList, heroSkill)
end
end
end
end
return skillList
end
function this.SetSelectSkillImage(parent)
this.selsectSkillImage:SetActive(true)
this.selsectSkillImage.transform:SetParent(parent.transform)
this.selsectSkillImage.transform.localPosition = Vector3.zero
this.selsectSkillImage.transform.localScale = Vector3.one
end
--单个技能显示
function this.UpdateHeroUpStarProUpSkillShow(skillGridGO,skillTabs,passiveSkills)
this.skillData = this.GetSkillsData()
for i = 1,math.max(#this.skillList,#this.skillData) do
this.skillList[i].icon.gameObject:GetComponent("Button").onClick:RemoveAllListeners()
if not this.skillData[i] then
this.skillList[i].go.gameObject:SetActive(false)
else
this.skillList[i].go.gameObject:SetActive(true)
if this.skillData[i].quality == 0 then
this.skillList[i].frame.gameObject:SetActive(false)
else
this.skillList[i].frame.gameObject:SetActive(true)
end
this.skillList[i].pos.sprite=this.spLoader:LoadSprite(SkillIconType[this.skillData[i].skillConfig.Type])--被动技
if this.skillData[i].skillConfig.Skilltips and this.skillData[i].skillConfig.Skilltips > 0 then
if this.skillData[i].skillConfig.Skilltips == 6 then
this.skillList[i].pro.sprite=this.spLoader:LoadSprite("r_hero_lvdi")--被动技
else
this.skillList[i].pro.sprite=this.spLoader:LoadSprite("r_hero_hongdi")--被动技
end
this.skillList[i].pro.gameObject:SetActive(true)
this.skillList[i].proText.text=SkillProType[this.skillData[i].skillConfig.Skilltips]
else
this.skillList[i].pro.gameObject:SetActive(false)
end
this.skillList[i].skillName.text= GetLanguageStrById(this.skillData[i].skillConfig.Name)--(curSkillData.skillId % 10)
this.skillList[i].icon.sprite=this.spLoader:LoadSprite(GetResourcePath(this.skillData[i].skillConfig.Icon))--被动技
if this.skillData[i].state == 0 then
LogGreen("this.skillData[i].star:"..this.skillData[i].star)
local str = NumToChinese[this.skillData[i].star].."星"
if this.skillData[i].star > 11 then
str = "飞升"..NumToChinese[this.skillData[i].star - 11]
end
this.skillList[i].skillName.text = str.."解锁"
Util.SetGray(this.skillList[i].go,true)
else
Util.SetGray(this.skillList[i].go,false)
end
Util.AddOnceClick(this.skillList[i].icon.gameObject, function()
this.SetSelectSkillImage(this.skillList[i].icon.gameObject)
local maxLv= HeroManager.GetHeroSkillMaxLevel(curHeroData.heroConfig.Id,this.skillData[i].skillConfig.Type)
if this.skillData[i].skillType == 0 then
this.skillPanel = UIManager.OpenPanel(UIName.SkillInfoPopup,this.skillData[i],1,10,maxLv,i,nil,GodSoulManager.GetGodSoulLv(curHeroData.dynamicId))
else
local awakenSkillList = this.GetAwakenSkill()
this.skillPanel = UIManager.OpenPanel(UIName.SkillInfoPopup,this.skillData[i],1,10,maxLv,i,nil,GodSoulManager.GetGodSoulLv(curHeroData.dynamicId),awakenSkillList[i-2])
end
end)
end
end
if #this.skillData > 2 then
this.line1.gameObject:SetActive(true)
else
this.line1.gameObject:SetActive(false)
end
if #this.skillData > 5 then
this.line2.gameObject:SetActive(true)
else
this.line2.gameObject:SetActive(false)
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)
else
this.noUpLvText:SetActive(false)
this.upLv:SetActive(true)
isUpLvMaterials=true
for i = 1, math.max(#this.costList,#costItemList) do
this.costList[i].go.gameObject:GetComponent("Button").onClick:RemoveAllListeners()
if not costItemList[i] then
this.costList[i].go.gameObject:SetActive(false)
else
if not this.costList[i] then
else
this.costList[i].go.gameObject:SetActive(true)
this.costList[i].icon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(costItemList[i][1]))
if BagManager.GetItemCountById(costItemList[i][1])%s",costItemList[i][2])
else
this.costList[i].costText.text=string.format("%s",costItemList[i][2])
end
Util.AddOnceClick(this.costList[i].go.gameObject,function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,costItemList[i][1])
end)
end
end
end
end
this.isGongMing = HarmonyManager.IsGongMing(curHeroData)
if this.isGongMing then
this.gongmingText:SetActive(true)
this.hognmengbeiTip.gameObject:SetActive(not (HarmonyManager:HongMengTowerUpLimit() > 0))
this.hognmengzhenTip.gameObject:SetActive(HarmonyManager:HongMengTowerUpLimit() > 0)
this.upLv:SetActive(false)
this.noUpLvText:SetActive(false)
return
else
this.gongmingText:SetActive(false)
end
--红点检测
local upLvRedpoint = HeroManager.LvUpBtnRedPoint(curHeroData)
this.upLvBtnRedPoint:SetActive(upLvRedpoint)
parent:CheckRedPointType(RoleInfoPanelIndex.qingbao,upLvRedpoint)
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 isHeroUpStar and upStarRankUpConfig and curTuPoRankUpConfig and curTuPoRankUpConfig.JudgeClass==1 and curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then--当前突破全部完成
this.tipUpLv.text=Language[11804]
this.tipUpLv.gameObject:SetActive(true)
this.itemGrid.gameObject:SetActive(false)
this.upLvBtnText.text=Language[11805]
this.upLvBtnImage.sprite = this.spLoader:LoadSprite("r_hero_button_001")--r_chouka_button_004
_isClicked = false
_isReqLvUp = false
else
this.itemGrid.gameObject:SetActive(true)
-- if curHeroData.lv < 30 then--策划规定三十级之前一直显示持续长按可快速升级
-- this.tipUpLv.gameObject:SetActive(false)
-- this.tipUpLv.text = Language[11807]
-- else
-- this.tipUpLv.gameObject:SetActive(false)
-- end
this.tipUpLv.gameObject:SetActive(false)
this.upLvBtnText.text=Language[11063]
this.upLvBtnImage.sprite = this.spLoader:LoadSprite("r_hero_button_002")
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.text=Language[11804]
this.tipUpLv.gameObject:SetActive(false)
end
else--从未进阶过处理
this.tipUpLv.text=Language[11804]
this.tipUpLv.gameObject:SetActive(false)
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
if curHeroData.star >= curHeroData.heroConfig.MaxRank then
MsgPanel.ShowOne("当前神将已达最大星级")
return
end
_isClicked = false
_isReqLvUp = false
local showTipStr = Language[11808]
local showIndex = RoleInfoPanelIndex.jinjie
local showBtnTipStr = Language[11809]
if curHeroData.star == HeroManager.awakeStarIndex then
showTipStr = Language[11810]
showBtnTipStr = Language[11811]
showIndex = RoleInfoPanelIndex.juexing
end
if showIndex == RoleInfoPanelIndex.juexing 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--是否是单次升级
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(RoleInfoPanelIndex.jinjie)
parent:OnPageTabChange(RoleInfoPanelIndex.jinjie)
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
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)
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.proList = {}
this.skillList = {}
this.costList = {}
end
return RoleInfoLayout