miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/MapRoleInfoPopup.lua

106 lines
4.4 KiB
Lua

require("Base/BasePanel")
MapRoleInfoPopup = Inherit(BasePanel)
local this = MapRoleInfoPopup
--初始化组件(用于子类重写)
function MapRoleInfoPopup:InitComponent()
this.spLoader = SpriteLoader.New()
self.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.heroName = Util.GetGameObject(self.transform, "RoleName"):GetComponent("Text")
this.pos = Util.GetGameObject(self.transform, "PropImg2"):GetComponent("Image")
this.pro = Util.GetGameObject(self.transform, "PropImg1"):GetComponent("Image")
this.lv = Util.GetGameObject(self.transform, "RoleLevel"):GetComponent("Text")
this.starPre = Util.GetGameObject(self.transform, "StarPre")
this.starGrid= Util.GetGameObject(self.transform, "StarsRoot")
this.atk = Util.GetGameObject(self.transform, "RoleInfo/pro/atk/proValue"):GetComponent("Text")
this.hp = Util.GetGameObject(self.transform, "RoleInfo/pro/hp/proValue"):GetComponent("Text")
this.phyDef = Util.GetGameObject(self.transform, "RoleInfo/pro/phyDef/proValue"):GetComponent("Text")
this.magDef = Util.GetGameObject(self.transform, "RoleInfo/pro/magDef/proValue"):GetComponent("Text")
this.speed = Util.GetGameObject(self.transform, "RoleInfo/pro/speed/proValue"):GetComponent("Text")
this.skillGrid=Util.GetGameObject(self.transform, "RoleInfo/skill")
this.power=Util.GetGameObject(self.transform, "RoleInfo/powerNum"):GetComponent("Text")
--this.xingDongExp=Util.GetGameObject(self.transform, "xingDongExp/expCurNum"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function MapRoleInfoPopup:BindEvent()
Util.AddClick(self.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function MapRoleInfoPopup:AddListener()
end
--移除事件监听(用于子类重写)
function MapRoleInfoPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function MapRoleInfoPopup:OnOpen(...)
local arg = { ... }
local curHeroData = arg[1]
local allPropValue = arg[2]
--this.profession.sprite = this.spLoader:LoadSprite(GetResourcePath(curHeroData.ProfessionResourceId))
-- 角色属性图标
this.pos.sprite = this.spLoader:LoadSprite(curHeroData.professionIcon)
this.pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(curHeroData.changeProId))
this.lv.text =string.format(Language[11487],curHeroData.lv)
this.heroName.text = curHeroData.name
local star,starType = curHeroData.GetStar(1)
SetHeroStars(this.spLoader, this.starGrid, star,starType)
Util.SetParticleSortLayer(this.starGrid,self.sortingOrder + 1)
--计算战斗力
this.power.text =Language[10104] .. HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
-- 计算属性
--显示队伍的属性数据
local allAddProVal=HeroPropManager.GetHeroProp(curHeroData.dynamicId)
local propList = FoodBuffManager.CalBuffPropValue(allPropValue)
this.atk.text = propList[4]
this.hp.text = propList[2]
this.phyDef.text = propList[5]
this.magDef.text = propList[6]
this.speed.text = propList[7]
--技能
local allSkillDatas = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas(curHeroData.id,curHeroData.star)
for i = 1, this.skillGrid.transform.childCount do
local go= this.skillGrid.transform:GetChild(i-1).gameObject
if #allSkillDatas>=i then
if allSkillDatas[i] and allSkillDatas[i].skillConfig and allSkillDatas[i].skillConfig.Name then
go:SetActive(true)
go.transform:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(allSkillDatas[i].skillConfig.Icon))
Util.GetGameObject(go.transform,"Text"):GetComponent("Text").text="lv."..(allSkillDatas[i].skillId % 10)
else
go:SetActive(false)
end
Util.AddClick(go, function()
local maxLv= HeroManager.GetHeroSkillMaxLevel(curHeroData.heroConfig.Id, allSkillDatas[i].skillConfig.Type)
UIManager.OpenPanel(UIName.SkillInfoPopup,allSkillDatas[i],2,10,maxLv,i)
end)
else
go:SetActive(false)
end
end
end
--界面关闭时调用(用于子类重写)
function MapRoleInfoPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function MapRoleInfoPopup:OnDestroy()
this.spLoader:Destroy()
end
return MapRoleInfoPopup