require("Base/BasePanel") RoleGetInfoPopup = Inherit(BasePanel) local this=RoleGetInfoPopup local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) local heroBackData local isGet local heroSId local heroStar local allSkillDatas = {} --初始化组件(用于子类重写) function RoleGetInfoPopup:InitComponent() this.BtnBack=Util.GetGameObject(self.transform, "bg/btnBack") this.liveRoot=Util.GetGameObject(self.transform, "bg/liveRoot") this.heroName = Util.GetGameObject(self.transform, "RoleInfo/nameAndPossLayout/heroName"):GetComponent("Text") this.starGrid = Util.GetGameObject(self.transform, "bg/NameButtom/star") this.starPre = Util.GetGameObject(self.transform, "bg/NameButtom/starPre") this.starGrid = Util.GetGameObject(self.transform, "RoleInfo/sartAndLvLayout/starGrid") --定位描述 this.posBgImage=Util.GetGameObject(self.transform,"pos"):GetComponent("Image") this.posImage=Util.GetGameObject(self.transform,"pos/posImage"):GetComponent("Image") this.posText=Util.GetGameObject(self.transform,"pos/posText"):GetComponent("Text") -- this.posImage = Util.GetGameObject(self.transform, "RoleInfo/nameAndPossLayout/posImage/posImage/posImage"):GetComponent("Image") -- this.posText = Util.GetGameObject(self.transform, "RoleInfo/nameAndPossLayout/posText/posText"):GetComponent("Text") this.profession = Util.GetGameObject(self.transform, "RoleInfo/nameAndPossLayout/proImage/proImage"):GetComponent("Image") -- this.qualityImage=Util.GetGameObject(self.transform,"quality"):GetComponent("Image") -- this.quality=Util.GetGameObject(self.transform,"quality/qualityText") -- this.doubleQuality=Util.GetGameObject(self.transform,"quality/qualityDoubleText") -- this.heroTypeText=Util.GetGameObject(self.transform,"RoleInfo/heroTypeText"):GetComponent("Text") Util.GetGameObject(self.transform,"bg/RoleInfo/pro/atk/proName"):GetComponent("Text").text = propertyConfig[2].Info Util.GetGameObject(self.transform,"bg/RoleInfo/pro/hp/proName"):GetComponent("Text").text = propertyConfig[1].Info Util.GetGameObject(self.transform,"bg/RoleInfo/pro/phyDef/proName"):GetComponent("Text").text = propertyConfig[3].Info Util.GetGameObject(self.transform,"bg/RoleInfo/pro/magDef/proName"):GetComponent("Text").text = propertyConfig[4].Info -- Util.GetGameObject(self.transform,"bg/RoleInfo/pro/speed/proName"):GetComponent("Text").text = propertyConfig[5].Info this.atk = Util.GetGameObject(self.transform, "bg/RoleInfo/pro/atk/proValue"):GetComponent("Text") this.hp = Util.GetGameObject(self.transform, "bg/RoleInfo/pro/hp/proValue"):GetComponent("Text") this.phyDef = Util.GetGameObject(self.transform, "bg/RoleInfo/pro/phyDef/proValue"):GetComponent("Text") this.magDef = Util.GetGameObject(self.transform, "bg/RoleInfo/pro/magDef/proValue"):GetComponent("Text") -- this.speed = Util.GetGameObject(self.transform, "bg/RoleInfo/pro/speed/proValue"):GetComponent("Text") -- this.skillGrid=Util.GetGameObject(self.transform, "bg/RoleInfo/skill") -- this.skill1=Util.GetGameObject(self.transform, "bg/RoleInfo/skill/s1") -- this.skill2=Util.GetGameObject(self.transform, "bg/RoleInfo/skill/s2") -- this.selsectSkillImage=Util.GetGameObject(self.transform, "selsectSkillImage") -- this.radar = Util.GetGameObject(self.transform, "bg/RoleInfo/proRadarImage/radar"):GetComponent("RadarChart") self.skillName=Util.GetGameObject(self.transform,"RoleInfo/skillName") self.skillLine=Util.GetGameObject(self.transform,"RoleInfo/skillLine") this.skillGrid=Util.GetGameObject(self.transform,"RoleInfo/Panel/Skill/skill") -- this.skill1 = Util.GetGameObject(this.skillGrid, "sBg1/SkillTypeImage") -- this.skill2 = Util.GetGameObject(this.skillGrid, "sBg2/SkillTypeImage") this.selsectSkillImage=Util.GetGameObject(self.transform,"RoleInfo/selsectSkillImage") this.talismanBtn=Util.GetGameObject(self.transform,"RoleInfo/Panel/Other/TalismanBtn") -- this.talismanFrame=Util.GetGameObject(self.transform,"RoleInfo/Panel/Other/TalismanBtn"):GetComponent("Image") this.talismanIcon=Util.GetGameObject(self.transform,"RoleInfo/Panel/Other/TalismanBtn/Icon"):GetComponent("Image") this.talentBtn=Util.GetGameObject(self.transform,"RoleInfo/Panel/Other/talentBtn") this.talentProgress=Util.GetGameObject(self.transform,"RoleInfo/Panel/Other/talentBtn/progress"):GetComponent("Text") end local triggerCallBack --绑定事件(用于子类重写) function RoleGetInfoPopup:BindEvent() Util.AddClick(this.BtnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) -- Util.AddClick(this.skill1, function() -- if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then -- Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) -- end -- this:SetSkillSelectImage(this.skill1.transform,true) -- local skillData=allSkillDatas[1] -- local maxLv= HeroManager.GetHeroSkillMaxLevel(heroSId, skillData.skillConfig.Type) -- local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,3,10,maxLv,1) -- this.skillGrid:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1 -- triggerCallBack = function (panelType, p) -- if panelType == UIName.SkillInfoPopup and p == panel then --监听到SkillInfoPopup关闭,把层级设回去 -- this.skillGrid:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1 -- Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) -- this:SetSkillSelectImage(self.transform,false) -- end -- end -- Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- end) -- Util.AddClick(this.skill2, function() -- if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then -- Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) -- end -- this:SetSkillSelectImage(this.skill2.transform,true) -- local skillData=allSkillDatas[2] -- local maxLv= HeroManager.GetHeroSkillMaxLevel(heroSId, skillData.skillConfig.Type) -- local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,3,10,maxLv,2) -- this.skillGrid:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1 -- triggerCallBack = function (panelType, p) -- if panelType == UIName.SkillInfoPopup and p == panel then --监听到SkillInfoPopup关闭,把层级设回去 -- this.skillGrid:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1 -- Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) -- this:SetSkillSelectImage(self.transform,false) -- end -- end -- Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- end) end --添加事件监听(用于子类重写) function RoleGetInfoPopup:AddListener() end --移除事件监听(用于子类重写) function RoleGetInfoPopup:RemoveListener() end --界面打开时调用(用于子类重写) function RoleGetInfoPopup:OnOpen(...) local data={...} isGet=data[1] if isGet then heroBackData=data[2] heroSId= heroBackData.heroId heroStar= heroBackData.star else heroSId=data[2] heroStar=data[3] end end function RoleGetInfoPopup:OnShow() allSkillDatas = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas(heroSId,heroStar) local heroSData=ConfigManager.GetConfigData(ConfigName.HeroConfig, heroSId) if isGet then this.GetShowPanelData() else this.NoGetShowPanelData() end --技能 布局变动 self.skillLine.gameObject:SetActive(not (heroSData.OpenPassiveSkillRules == nil and heroSData.EquipTalismana==nil)) if heroSData.OpenPassiveSkillRules == nil and heroSData.EquipTalismana==nil then Util.GetGameObject(self.transform,"RoleInfo/Panel/Skill"):GetComponent("LayoutElement").minWidth=500 Util.GetGameObject(self.transform,"RoleInfo/Panel/Skill/skill"):GetComponent("GridLayoutGroup").startAxis=0 self.skillName.transform:DOAnchorPos(Vector3.New(230,158,0),0) else Util.GetGameObject(self.transform,"RoleInfo/Panel/Skill"):GetComponent("LayoutElement").minWidth=150 Util.GetGameObject(self.transform,"RoleInfo/Panel/Skill/skill"):GetComponent("GridLayoutGroup").startAxis=1 self.skillName.transform:DOAnchorPos(Vector3.New(90,158,0),0) end --技能点击特殊处理 this.selsectSkillImage:SetActive(false) this.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1 local triggerCallBack local skillList = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas(heroSData.Id,heroSData.Star) for i = 1, this.skillGrid.transform.childCount do this.skillGrid.transform:GetChild(i-1).gameObject:SetActive(false) end for i = 1, #skillList do if skillList[i] and skillList[i].skillConfig and skillList[i].skillConfig.Name then local go = this.skillGrid.transform:GetChild(i-1).gameObject go:SetActive(true) Util.GetGameObject(go.transform,"s"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(skillList[i].skillConfig.Icon)) Util.GetGameObject(go.transform,"s/Text"):GetComponent("Text").text=skillList[i].skillConfig.Name--Language[10470].. 1(skillList[i].skillConfig.Id % 10) Util.GetGameObject(go.transform,"SkillTypeImage"):GetComponent("Image").sprite=Util.LoadSprite(GetSkillType(allSkillDatas[i])) Util.AddOnceClick(Util.GetGameObject(go.transform,"s"), 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,"s").transform.position local skillData = {} skillData.skillConfig = skillList[i].skillConfig local maxLv= HeroManager.GetHeroSkillMaxLevel(heroSData.Id,skillData.skillConfig.Type) local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i) this.skillGrid:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1 triggerCallBack = function (panelType, p) if panelType == UIName.SkillInfoPopup and panel == p then --监听到SkillInfoPopup关闭,把层级设回去 this.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1 Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) this.selsectSkillImage:SetActive(false) end end Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) end) end end --天赋 this.talentBtn:SetActive(heroSData.OpenPassiveSkillRules ~= nil) if heroSData.OpenPassiveSkillRules then local openlists,compoundOpenNum,compoundNum = HeroManager.GetAllPassiveSkillIds(heroSData,0,0) this.talentProgress.text = #openlists - compoundOpenNum .."/"..#heroSData.OpenPassiveSkillRules - compoundNum end Util.AddOnceClick(this.talentBtn,function() UIManager.OpenPanel(UIName.RoleTalentPopup,heroSData,0,0) end) --法宝 self.talismanBtn.gameObject:SetActive(heroSData.EquipTalismana~=nil) if heroSData.EquipTalismana~=nil then -- self.talismanFrame.sprite=Util.LoadSprite(TalismanBubble[itemConfig[heroSData.EquipTalismana[2]].Quantity]) this.talismanIcon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[heroSData.EquipTalismana[2]].ResourceID)) end Util.AddOnceClick(this.talismanBtn.gameObject,function() UIManager.OpenPanel(UIName.TalismanInfoPopup,heroSData,1,1) end) end function this.ShowHeroLive(_heroSConfigData) this.testLiveGO = poolManager:LoadLive(GetResourcePath(_heroSConfigData.Live), this.liveRoot.transform, Vector3.one * _heroSConfigData.Scale*0.7, Vector3.New(_heroSConfigData.PositionView[1], _heroSConfigData.PositionView[2], 0)) local SkeletonGraphic = this.testLiveGO:GetComponent("SkeletonGraphic") local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle poolManager:SetLiveClearCall(GetResourcePath(_heroSConfigData.Live), this.testLiveGO, function () SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle end) --资质相关 -- this.qualityImage.sprite=GetQuantityImage(_heroSConfigData.Natural) -- this.quality:SetActive(_heroSConfigData.Natural < 10) -- this.doubleQuality:SetActive(_heroSConfigData.Natural >= 10) -- this.quality:GetComponent("Text").text = _heroSConfigData.Natural -- this.doubleQuality:GetComponent("Text").text = _heroSConfigData.Natural --定位描述相关 this.posBgImage.sprite=Util.LoadSprite(GetHeroPosBgStr(_heroSConfigData.Profession)) this.posImage.sprite=Util.LoadSprite(GetHeroPosStr(_heroSConfigData.Profession)) this.posText.text=_heroSConfigData.HeroLocation this.heroName.text = _heroSConfigData.ReadingName -- this.posText.text = HeroOccupationDef[_heroSConfigData.Profession] -- this.posImage.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(_heroSConfigData.Profession)) this.profession.sprite = Util.LoadSprite(GetProStrImageByProNum(_heroSConfigData.PropertyName)) -- this.heroTypeText.text = "定位:".."".._heroSConfigData.HeroLocation.."" -- this.radar:SetEdges({_heroSConfigData.AttackScale/100,_heroSConfigData.DefenseScale/100,_heroSConfigData.AssistScale/100}) -- this.radar.color = Color.New(238/255,211/255,156/255,102/255) end function this.GetShowPanelData() local heroSData=ConfigManager.GetConfigData(ConfigName.HeroConfig, heroBackData.heroId) this.ShowHeroLive(heroSData) --星级 SetHeroStars(this.starGrid, heroBackData.star) --属性 local allAddProVal=HeroManager.CalculateHeroAllProValList(1,heroBackData.id,false) this.atk.text=allAddProVal[HeroProType.Attack] this.hp.text=allAddProVal[HeroProType.Hp] this.phyDef.text=allAddProVal[HeroProType.PhysicalDefence] this.magDef.text=allAddProVal[HeroProType.MagicDefence] -- this.speed.text= allAddProVal[HeroProType.Speed] --技能 -- this.selsectSkillImage:SetActive(false) -- this.skillGrid:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1 -- if allSkillDatas[1] and allSkillDatas[1].skillConfig and allSkillDatas[1].skillConfig.Name then -- this.skill1:SetActive(true) -- this.skill1.transform:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(allSkillDatas[1].skillConfig.Icon)) -- Util.GetGameObject(this.skill1.transform,"Text"):GetComponent("Text").text="等级"..(allSkillDatas[1].skillId % 10) -- else -- this.skill1:SetActive(false) -- end -- if allSkillDatas[2] and allSkillDatas[2].skillConfig and allSkillDatas[2].skillConfig.Name then -- this.skill2:SetActive(true) -- this.skill2.transform:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(allSkillDatas[2].skillConfig.Icon)) -- Util.GetGameObject(this.skill2.transform,"Text"):GetComponent("Text").text="等级"..(allSkillDatas[2].skillId % 10) -- else -- this.skill2:SetActive(false) -- end end function this.NoGetShowPanelData() local heroSData=ConfigManager.GetConfigData(ConfigName.HeroConfig, heroSId) this.ShowHeroLive(heroSData) --星级 --Util.ClearChild(this.starGrid.transform) SetHeroStars(this.starGrid, heroStar) --属性 local allAddProVal = this.CalculateHeroAllProValList(heroSData,heroStar,heroStar ~= heroSData.Star) this.atk.text=allAddProVal[HeroProType.Attack] this.hp.text=allAddProVal[HeroProType.Hp] this.phyDef.text=allAddProVal[HeroProType.PhysicalDefence] this.magDef.text=allAddProVal[HeroProType.MagicDefence] -- this.speed.text= heroSData.Speed --技能 -- Log("#allSkillDatas "..#allSkillDatas) -- this.selsectSkillImage:SetActive(false) -- this.skillGrid:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1 -- if allSkillDatas[1] and allSkillDatas[1].skillConfig and allSkillDatas[1].skillConfig.Name then -- this.skill1:SetActive(true) -- this.skill1.transform:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(allSkillDatas[1].skillConfig.Icon)) -- Util.GetGameObject(this.skill1.transform,"Text"):GetComponent("Text").text="等级"..(allSkillDatas[1].skillId % 10) -- else -- this.skill1:SetActive(false) -- end -- if allSkillDatas[2] and allSkillDatas[2].skillConfig and allSkillDatas[2].skillConfig.Name then -- this.skill2:SetActive(true) -- this.skill2.transform:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(allSkillDatas[2].skillConfig.Icon)) -- Util.GetGameObject(this.skill2.transform,"Text"):GetComponent("Text").text="等级"..(allSkillDatas[2].skillId % 10) -- else -- this.skill2:SetActive(false) -- end end function this:SetSkillSelectImage(_goTran,_type)--_goTran父级 _type==true 显示 =false 隐藏 this.selsectSkillImage:SetActive(_type) --this.selsectSkillImage.transform:SetParent(_goTran) --this.selsectSkillImage.transform.localScale = Vector3.one --this.selsectSkillImage.transform.localPosition=Vector3.zero this.selsectSkillImage.transform.position=_goTran.position end local heroLevelConfig = ConfigManager.GetConfig(ConfigName.HeroLevelConfig) --计算英雄属性 1 初始 2 满星 function this.CalculateHeroAllProValList(heroConFigData,_starNum,isCalculateStarVal) local allAddProVal = {} for i, v in ConfigPairs(propertyConfig) do allAddProVal[i] = 0 end local heroRankupConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.HeroRankupConfig, "Star", heroConFigData.Star, "OpenStar", _starNum) local curLvNum = 1 local breakId = 0 local upStarId = 0 if isCalculateStarVal then curLvNum = heroLevelConfig[heroRankupConfig.OpenLevel].CharacterLevelPara for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do if v.Star == heroConFigData.Star then if v.Type == 1 then breakId = v.Id end if v.Type == 2 then upStarId = v.Id end end end end allAddProVal[HeroProType.Attack]=HeroManager.CalculateProVal(heroConFigData.Attack, curLvNum, breakId,upStarId,HeroProType.Attack) allAddProVal[HeroProType.Hp]=HeroManager.CalculateProVal(heroConFigData.Hp, curLvNum, breakId,upStarId,HeroProType.Hp) allAddProVal[HeroProType.PhysicalDefence]=HeroManager.CalculateProVal(heroConFigData.PhysicalDefence, curLvNum, breakId,upStarId,HeroProType.PhysicalDefence) allAddProVal[HeroProType.MagicDefence]=HeroManager.CalculateProVal(heroConFigData.MagicDefence, curLvNum, breakId,upStarId,HeroProType.MagicDefence) --allAddProVal[HeroProType.Speed]= math.floor(((curSpeedFormulaData[1] * math.pow(breakId, 3) + curSpeedFormulaData[2] * math.pow(breakId, 2) + curSpeedFormulaData[3] * breakId + curSpeedFormulaData[4]) + heroConFigData.Speed * speedNum)) -- for i = 1, #heroConFigData.SecondaryFactor do -- local proId = heroConFigData.SecondaryFactor[i][1] -- if propertyConfig[proId].Style ==2 then -- allAddProVal[heroConFigData.SecondaryFactor[i][1]] = heroConFigData.SecondaryFactor[i][2]/10000 -- else -- allAddProVal[heroConFigData.SecondaryFactor[i][1]] = heroConFigData.SecondaryFactor[i][2] -- end -- end Util.AddOnceClick(this.talentBtn,function() UIManager.OpenPanel(UIName.RoleTalentPopup,heroConFigData,breakId,upStarId) end) if heroConFigData.OpenPassiveSkillRules then local openlists,compoundOpenNum,compoundNum = HeroManager.GetAllPassiveSkillIds(heroConFigData,breakId,upStarId) this.talentProgress.text = #openlists - compoundOpenNum .."/"..#heroConFigData.OpenPassiveSkillRules - compoundNum end return allAddProVal end --界面关闭时调用(用于子类重写) function RoleGetInfoPopup:OnClose() poolManager:UnLoadLive(this.testLiveGO.name, this.testLiveGO) this.testLiveGO = nil end --界面销毁时调用(用于子类重写) function RoleGetInfoPopup:OnDestroy() end return RoleGetInfoPopup