【皮肤】添加倒计时

dev_chengFeng
jiaoyangna 2020-11-05 18:26:38 +08:00
parent 5026bdd0c3
commit ccf02fb171
5 changed files with 7108 additions and 6092 deletions

File diff suppressed because it is too large Load Diff

View File

@ -415,5 +415,8 @@ GameEvent = {
StartXiaoYao="XiaoYao.StartXiaoYao",--执行逍遥游跑图
RefreshEventShow="XiaoYao.RefreshEventShow",--刷新逍遥游地图界面事件按钮显示隐藏
PlayEventEffect="XiaoYao.PlayEventEffect",--播放事件特效
},
Role={
UpdateSkin="Role.UpdateSkin",-- 刷新皮肤
}
}

View File

@ -3348,5 +3348,6 @@ function this.ChangeDownSkinId(heroSId,skinId)
v.position = v.skinConfig.Position
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.Role.UpdateSkin)
end
return this

View File

@ -69,6 +69,15 @@ function this.IsExist(id)
end
end
function this.GetSkins(id)
LogGreen("id:"..id.." IsExist:"..tostring(this.skinDatas[id]))
if this.skinDatas[id] then
return this.skinDatas[id]
else
return nil
end
end
function this.CaculateSkinProVal(_heroId)
local heroSkinSingleProVal = {}
local heroSkinAllHeroProVal = {}

View File

@ -16,13 +16,25 @@ function RoleSkinPanel:InitComponent(gameObject)
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)
skinPres[i] = {}
skinPres[i].obj = this.skinGrid.transform:GetChild(i - 1)
skinPres[i].data = nil
end
return this
end
function RoleSkinPanel:BindEvent()
end
--添加事件监听(用于子类重写)
function RoleSkinPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Role.UpdateSkin, this.UpdateShow)
end
--移除事件监听(用于子类重写)
function RoleSkinPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Role.UpdateSkin,this.UpdateShow)
end
this.UpdateShow = this:OnShow(0,parent,curHeroData)
--界面打开时调用
function RoleSkinPanel:OnShow(_sortinglayer,_parent,_curHerodata)
@ -36,18 +48,24 @@ function RoleSkinPanel:OnShow(_sortinglayer,_parent,_curHerodata)
skins[configs[i].Type] = configs[i]
end
end
for k,v in ipairs(skinPres) do
v.gameObject:SetActive(false)
for k,v in pairs(skinPres) do
v.obj.gameObject:SetActive(false)
v.data = nil
end
local index = 1
for i,v in pairs(skins) do
if not skinPres[index] then
skinPres[index] = newObjToParent(self.skinPre,self.skinGrid)
skinPres[index] = {}
end
skinPres[index].gameObject:SetActive(true)
self:SetSingleData(skinPres[index],v)
if not skinPres[index].obj then
skinPres[index].obj = newObjToParent(this.skinPre,this.skinGrid)
end
skinPres[index].data = v
skinPres[index].obj.gameObject:SetActive(true)
self:SetSingleData(skinPres[index].obj,v)
index = index + 1
end
this:ShowTime()
end
function RoleSkinPanel:SetSingleData(go,data)
@ -94,8 +112,8 @@ function RoleSkinPanel:SetSingleData(go,data)
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
this.Select.transform:SetParent(Util.GetGameObject(go,"skinState").transform)
this.Select:GetComponent("RectTransform").localPosition = Vector3.zero
end
Util.AddOnceClick(go.gameObject,function()
local skinId = data.IsDefault == 1 and 0 or data.Type
@ -124,9 +142,54 @@ function RoleSkinPanel:BtnAction(skinId,data)
Vector3.one * data.Scale, Vector3.New(data.Position[1], data.Position[2], 0))
PopupTipPanel.ShowTip("未获得此皮肤!")
end
end
function this:ShowTime()
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
for k,v in pairs(skinPres) do
if v.data then
Util.GetGameObject(v.obj,"skinTime"):SetActive(true)
local skindata = HeroSkinManager.GetSkins(v.data.Type)
if v.data.IsDefault == 1 or not skindata then
Util.GetGameObject(v.obj,"skinTime"):SetActive(false)
elseif skindata.overTime == -1 then
Util.GetGameObject(v.obj,"skinTime/time"):GetComponent("Text").text = "永久"
else
local time = skindata.overTime
if time < 0 then
Util.GetGameObject(v.obj,"skinTime/time"):GetComponent("Text").text = 0
else
time = this:TimeToFormat(time)
Util.GetGameObject(v.obj,"skinTime/time"):GetComponent("Text").text = time
end
end
end
end
end,1,-1,true)
this.timer:Start()
end
function RoleSkinPanel:TimeToFormat(time)
local day = math.floor(time / (24 * 3600))
local minute = math.floor(time / 60) % 60
local sec = time % 60
local hour = math.floor(math.floor(time - day * 24 * 3600 - sec - minute * 60) / 3600)
if day > 0 then
return string.format("%d天",day)
elseif hour > 0 then
return string.format("%2d时",hour)
elseif minute > 0 then
return string.format("%0d分",minute)
else
return string.format("",1)
end
end
function RoleSkinPanel:OnHide()
this.gameObject:SetActive(false)
end
@ -137,5 +200,9 @@ function RoleSkinPanel:OnDestroy()
skinPres = {}
porpertys = {}
curHeroData = {}
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
return RoleSkinPanel