[皮肤]倒计时修改

dev_chengFeng
jiaoyangna 2020-11-04 18:29:49 +08:00
parent d7b9563e35
commit 14812dab65
2 changed files with 24 additions and 11 deletions

View File

@ -3301,7 +3301,7 @@ end
function this.ChangeDownSkinId(heroSId,skinId)
for k,v in pairs(heroDatas) do
if v.id == heroSId and v.skinId == skinId then
v.vskinId = 0
v.skinId = 0
v.skinConfig = heroConfig[v.id]
v.live = GetResourcePath(v.skinConfig.Live)
v.painting = GetResourcePath(v.skinConfig.Painting)

View File

@ -11,11 +11,19 @@ function this.InitialSkin(msg,index)
for i = 1, #msg.skinInfo do
this.skinDatas[msg.skinInfo[i].skinId] = {}
this.skinDatas[msg.skinInfo[i].skinId].id = msg.skinInfo[i].skinId
local config = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",msg.skinInfo[i].skinId)
this.skinDatas[msg.skinInfo[i].skinId].heroId = config.HeroId
this.skinDatas[msg.skinInfo[i].skinId].UnlockProperty = config.UnlockProperty
this.skinDatas[msg.skinInfo[i].skinId].MonomerProperty = config.MonomerProperty
this.skinDatas[msg.skinInfo[i].skinId].overTime = msg.skinInfo[i].overTime - PlayerManager.serverTime
end
else
this.skinDatas[msg.skinInfo.skinId] = {}
this.skinDatas[msg.skinInfo.skinId].id = msg.skinInfo.skinId
local config = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",msg.skinInfo.skinId)
this.skinDatas[msg.skinInfo.skinId].heroId = config.HeroId
this.skinDatas[msg.skinInfo.skinId].UnlockProperty = config.UnlockProperty
this.skinDatas[msg.skinInfo.skinId].MonomerProperty = config.MonomerProperty
this.skinDatas[msg.skinInfo.skinId].overTime = msg.skinInfo.overTime - PlayerManager.serverTime
end
this.UpdateSkinDatasOverTime()
@ -27,13 +35,19 @@ function this.UpdateSkinDatasOverTime()
this.timer = nil
end
this.timer = Timer.New(function()
if LengthOfTable(this.skinDatas) < 1 then
if this.timer then
this.timer:Stop()
this.timer = nil
end
return
end
for k,v in pairs(this.skinDatas) do
if v and v.overTime > 0 then
v.overTime = v.overTime - 1
if v.overTime == 0 then
if v.overTime <= 0 then
this.RemoveSkin(v.id)
local heroId = ConfigManager.GetConfigData(ConfigName.HeroSkin,v.id).HeroId
HeroManager.ChangeDownSkinId(heroId,v.id)
HeroManager.ChangeDownSkinId(v.heroId,v.id)
end
end
end
@ -43,6 +57,7 @@ end
function this.RemoveSkin(id)
this.skinDatas[id] = nil
LogGreen("id:"..id.." IsExist:"..tostring(this.skinDatas[id]))
end
function this.IsExist(id)
@ -58,10 +73,9 @@ function this.CaculateSkinProVal(_heroId)
local heroSkinSingleProVal = {}
local heroSkinAllHeroProVal = {}
local heroData = HeroManager.GetSingleHeroData(_heroId)
if heroData.skinId ~= 0 then
local config = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId)
if config.MonomerProperty and #config.MonomerProperty > 0 then
for _,v in ipairs(config.MonomerProperty) do
if heroData.skinId ~= 0 then
if this.skinDatas[heroData.skinId].MonomerProperty and #this.skinDatas[heroData.skinId].MonomerProperty > 0 then
for _,v in ipairs(this.skinDatas[heroData.skinId].MonomerProperty) do
if not heroSkinSingleProVal[v[1]] then
heroSkinSingleProVal[v[1]] = 0
end
@ -74,9 +88,8 @@ function this.CaculateSkinProVal(_heroId)
end
for _,v in pairs(this.skinDatas) do
if heroData.skinId ~= v.id then
local config = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",v.id)
if config.UnlockProperty and #config.UnlockProperty > 0 then
for _,n in ipairs(config.UnlockProperty) do
if this.skinDatas[v.id].UnlockProperty and #this.skinDatas[v.id].UnlockProperty > 0 then
for _,n in ipairs(this.skinDatas[v.id].UnlockProperty) do
if not heroSkinAllHeroProVal[n[1]] then
heroSkinAllHeroProVal[n[1]] = 0
end