diff --git a/Assets/ManagedResources/~Lua/Modules/HomeLand/TrainBuildLvUpPanel.lua b/Assets/ManagedResources/~Lua/Modules/HomeLand/TrainBuildLvUpPanel.lua index b1d8bac723..ec5e472857 100644 --- a/Assets/ManagedResources/~Lua/Modules/HomeLand/TrainBuildLvUpPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/HomeLand/TrainBuildLvUpPanel.lua @@ -10,7 +10,8 @@ local parent local sortingOrder=0 local data=nil local Obj=nil - +local endCostNum=0 +local pro=0 function TrainBuildLvUpPanel:InitComponent() this.spLoader = SpriteLoader.New() --当前两个名字 @@ -48,7 +49,7 @@ function TrainBuildLvUpPanel:BindEvent() Util.AddClick(this.fastDoneBtn, function() -- local priviId = PrivilegeManager.GetPrivilegeRemainValue() TrainBuildManager.ResumeCost(data.dataSingle,string.split(costOneSec,"#"),function (num) - MsgPanel.ShowTwo(string.format("是否花费%s妖晶立即升级?",num),function() end,function() + MsgPanel.ShowTwo(string.format("是否花费%s妖晶立即升级?",endCostNum),function() end,function() NetManager.TrainingArchitectureUpRequest(data.dataMain.Id,2,function () --特效 Obj.effect2:SetActive(true) @@ -127,16 +128,49 @@ function TrainBuildLvUpPanel:OnShow() end this.fastDoneIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(tonumber(str[1]))) - LogError("curData.Time===================="..curData.Time) - this.fastDoneNum.text = math.ceil(curData.Time/60)*tonumber(str[2]) + --LogError("curData.Time===================="..curData.Time) + LogError("curdata.endTime==="..data.endTime.." curData endtime-curtime==="..data.endTime - GetTimeStamp()) + local leftTime=0 + if data.endTime>0 then + leftTime=data.endTime - GetTimeStamp() + else + leftTime=curData.Time + end + + pro=tonumber(str[2]) + endCostNum=math.ceil(leftTime/60)*pro + this.fastDoneNum.text = endCostNum this.doneNum.text = string.format("耗时:%s",this:CulculateTime(curData.Time)) - + if data.endTime>0 then + this:SetTime(leftTime) + end + ForceRebuildLayout(this.gain.transform) ForceRebuildLayout(this.Obtain.transform) ForceRebuildLayout(this.Cost.transform) ForceRebuildLayout(this.Content.transform) end + + +function TrainBuildLvUpPanel:SetTime(_num) + if self.timer then + self.timer:Stop() + self.timer = nil + end + local aaa=_num + self.timer = Timer.New(function () + aaa=aaa-1 + --LogError("lefttime================"..leftTime2.." data.endTime=="..data.endTime) + endCostNum=math.ceil(aaa/60)*pro + this.fastDoneNum.text = endCostNum + + end, 1, -1, true) + self.timer:Start() +end + + + function TrainBuildLvUpPanel:CulculateTime(time) if time < 60 then return time.."秒" @@ -156,6 +190,10 @@ end function TrainBuildLvUpPanel:OnDestroy() this.spLoader:Destroy() + if self.timer then + self.timer:Stop() + self.timer = nil + end end return TrainBuildLvUpPanel \ No newline at end of file