2020-11-03 15:17:48 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
RoleSkinPanel = Inherit(BasePanel)
|
|
|
|
|
local this = RoleSkinPanel
|
|
|
|
|
local porpertyConfigs = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
|
|
|
local artResConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
|
local skinPres = {}
|
|
|
|
|
local porpertys = {}
|
|
|
|
|
local curHeroData = {}
|
|
|
|
|
local skins = {}
|
|
|
|
|
local parent = {}
|
2020-11-03 17:27:32 +08:00
|
|
|
|
local curLiveName = ""
|
|
|
|
|
local isUnLoadLive = false
|
2020-11-03 15:17:48 +08:00
|
|
|
|
function RoleSkinPanel:InitComponent(gameObject)
|
|
|
|
|
this.gameObject = gameObject
|
|
|
|
|
this.skinPre = Util.GetGameObject(gameObject,"skinPre")
|
|
|
|
|
this.Select = Util.GetGameObject(gameObject,"selectLight")
|
|
|
|
|
this.skinGrid = Util.GetGameObject(gameObject,"skinGrid")
|
|
|
|
|
for i = 1, this.skinGrid.transform.childCount do
|
|
|
|
|
skinPres[i] = this.skinGrid.transform:GetChild(i - 1)
|
|
|
|
|
end
|
|
|
|
|
return this
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleSkinPanel:BindEvent()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用
|
2020-11-03 17:27:32 +08:00
|
|
|
|
function RoleSkinPanel:OnShow(_sortinglayer,_parent,_curHerodata)
|
|
|
|
|
this.gameObject:SetActive(true)
|
|
|
|
|
curHeroData = _curHerodata
|
|
|
|
|
parent = _parent
|
2020-11-03 15:17:48 +08:00
|
|
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.HeroSkin,"HeroId",curHeroData.id)
|
|
|
|
|
local skins = {}
|
|
|
|
|
for i = 1 ,#configs do
|
|
|
|
|
if not skins[configs[i].Type] then
|
|
|
|
|
skins[configs[i].Type] = configs[i]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for k,v in ipairs(skinPres) do
|
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
local index = 1
|
|
|
|
|
for i,v in pairs(skins) do
|
|
|
|
|
if not skinPres[index] then
|
|
|
|
|
skinPres[index] = newObjToParent(self.skinPre,self.skinGrid)
|
|
|
|
|
end
|
|
|
|
|
skinPres[index].gameObject:SetActive(true)
|
|
|
|
|
self:SetSingleData(skinPres[index],v)
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleSkinPanel:SetSingleData(go,data)
|
|
|
|
|
LogGreen("皮肤Id:"..data.Type)
|
|
|
|
|
local icon = Util.GetGameObject(go,"skinIcon"):GetComponent("Image")
|
|
|
|
|
local lock = Util.GetGameObject(go,"skinState/Off")
|
|
|
|
|
local infoPre = Util.GetGameObject(go,"skinInfo/infoPre")
|
|
|
|
|
local infoGrid = Util.GetGameObject(go,"skinInfo/grid")
|
|
|
|
|
local skinName = Util.GetGameObject(go,"skinName/name"):GetComponent("Text")
|
|
|
|
|
skinName.text = data.ReadingName
|
|
|
|
|
icon.sprite = Util.LoadSprite(artResConfig[data.Painting].Name)
|
|
|
|
|
if not porpertys then
|
|
|
|
|
porpertys = {}
|
|
|
|
|
end
|
|
|
|
|
if not porpertys[go] then
|
|
|
|
|
porpertys[go] = {}
|
|
|
|
|
end
|
|
|
|
|
for i = 1, infoGrid.transform.childCount do
|
|
|
|
|
porpertys[go][i] = infoGrid.transform:GetChild(i - 1)
|
|
|
|
|
porpertys[go][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if HeroSkinManager.IsExist(data.Type) or data.IsDefault == 1 then
|
|
|
|
|
if data.MonomerProperty and #data.MonomerProperty > 0 then
|
|
|
|
|
for i = 1, #data.MonomerProperty do
|
|
|
|
|
if not porpertys[go][i] then
|
|
|
|
|
porpertys[go][i] = newObjToParent(infoPre,infoGrid)
|
|
|
|
|
end
|
|
|
|
|
porpertys[go][i].gameObject:SetActive(true)
|
|
|
|
|
local tempProData = porpertyConfigs[data.MonomerProperty[i][1]]
|
|
|
|
|
Util.GetGameObject(porpertys[go][i],"info"):GetComponent("Text").text = tempProData.Info .. "+" ..GetPropertyFormatStr(tempProData.Style,data.MonomerProperty[i][2])
|
|
|
|
|
porpertys[go][i]:GetComponent("Button").enabled = false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
lock.gameObject:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
if not porpertys[go][1] then
|
|
|
|
|
porpertys[go][1] = newObjToParent(infoPre,infoGrid)
|
|
|
|
|
end
|
|
|
|
|
porpertys[go][1].gameObject:SetActive(true)
|
|
|
|
|
Util.GetGameObject(porpertys[go][1],"info"):GetComponent("Text").text = "获取途径"
|
|
|
|
|
Util.AddOnceClick(porpertys[go][1].gameObject,function()
|
2020-11-05 16:02:49 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, data.Id,function() end)
|
2020-11-03 15:17:48 +08:00
|
|
|
|
end)
|
|
|
|
|
lock.gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
if data.Type == curHeroData.skinId or (curHeroData.skinId == 0 and data.IsDefault == 1) then
|
|
|
|
|
self.Select.transform:SetParent(Util.GetGameObject(go,"skinState").transform)
|
|
|
|
|
self.Select:GetComponent("RectTransform").localPosition = Vector3.zero
|
2020-11-05 16:02:49 +08:00
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(go.gameObject,function()
|
|
|
|
|
local skinId = data.IsDefault == 1 and 0 or data.Type
|
|
|
|
|
this:BtnAction(skinId,data)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleSkinPanel:BtnAction(skinId,data)
|
|
|
|
|
if skinId == curHeroData.skinId then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if HeroSkinManager.IsExist(skinId) or skinId == 0 then
|
|
|
|
|
NetManager.ChangeHeroSkin(curHeroData.dynamicId,skinId,function()
|
2020-11-03 15:17:48 +08:00
|
|
|
|
poolManager:UnLoadLive(curHeroData.live, parent.curLiveObj)
|
2020-11-05 16:02:49 +08:00
|
|
|
|
HeroManager.ChangeSkinId(curHeroData.dynamicId,skinId)
|
|
|
|
|
local tempdata = HeroManager.GetSingleHeroData(curHeroData.dynamicId)
|
|
|
|
|
curLiveName = tempdata.Live
|
|
|
|
|
parent.curLiveObj = HeroManager.LoadHerolive(tempdata,parent.curObj)
|
|
|
|
|
PopupTipPanel.ShowTip("已更换皮肤!")
|
|
|
|
|
this:OnShow(0,parent,tempdata)
|
2020-11-03 15:17:48 +08:00
|
|
|
|
end)
|
2020-11-05 16:02:49 +08:00
|
|
|
|
else
|
|
|
|
|
poolManager:UnLoadLive(curHeroData.live, parent.curLiveObj)
|
|
|
|
|
curLiveName = GetResourcePath(data.Live)
|
|
|
|
|
parent.curLiveObj = poolManager:LoadLive(GetResourcePath(data.Live), parent.curObj.transform,
|
|
|
|
|
Vector3.one * data.Scale, Vector3.New(data.Position[1], data.Position[2], 0))
|
|
|
|
|
PopupTipPanel.ShowTip("未获得此皮肤!")
|
2020-11-03 15:17:48 +08:00
|
|
|
|
end
|
2020-11-05 16:02:49 +08:00
|
|
|
|
|
2020-11-03 15:17:48 +08:00
|
|
|
|
end
|
2020-11-05 16:02:49 +08:00
|
|
|
|
|
2020-11-03 15:17:48 +08:00
|
|
|
|
function RoleSkinPanel:OnHide()
|
2020-11-05 16:02:49 +08:00
|
|
|
|
this.gameObject:SetActive(false)
|
2020-11-03 15:17:48 +08:00
|
|
|
|
end
|
|
|
|
|
function RoleSkinPanel:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
function RoleSkinPanel:OnDestroy()
|
|
|
|
|
skinPres = {}
|
|
|
|
|
porpertys = {}
|
|
|
|
|
curHeroData = {}
|
|
|
|
|
end
|
|
|
|
|
return RoleSkinPanel
|