117 lines
3.6 KiB
Lua
117 lines
3.6 KiB
Lua
|
--[[
|
|||
|
* @ClassName WarPowerChangeNotifyPanelV2
|
|||
|
* @Description 战力升级提醒
|
|||
|
* @Date 2019/9/10 9:54
|
|||
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|||
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|||
|
--]]
|
|||
|
---@class WarPowerChangeNotifyPanelV2
|
|||
|
local WarPowerChangeNotifyPanelV2 = quick_class("WarPowerChangeNotifyPanelV2", BasePanel)
|
|||
|
local isChanging = false
|
|||
|
|
|||
|
function WarPowerChangeNotifyPanelV2:InitComponent()
|
|||
|
self.bg = Util.GetGameObject(self.transform, "bg")
|
|||
|
|
|||
|
self.powerValue = Util.GetGameObject(self.transform, "bg/powerValue"):GetComponent("Text")
|
|||
|
|
|||
|
self.changeValueDown = Util.GetGameObject(self.powerValue.gameObject, "changeValueDown"):GetComponent("Text")
|
|||
|
self.changeValueUp = Util.GetGameObject(self.powerValue.gameObject, "changeValueUp"):GetComponent("Text")
|
|||
|
|
|||
|
self.countNumber = 0
|
|||
|
|
|||
|
--self.cacheData = {}
|
|||
|
end
|
|||
|
|
|||
|
function WarPowerChangeNotifyPanelV2:OnOpen(context)
|
|||
|
self.countNumber = self.countNumber + 1
|
|||
|
--table.insert(self.cacheData, context)
|
|||
|
--if self.thread then
|
|||
|
-- return
|
|||
|
--end
|
|||
|
--local progress = function()
|
|||
|
-- while #self.cacheData > 0 do
|
|||
|
-- local context = table.remove(self.cacheData, 1)
|
|||
|
-- self:SetValue(context)
|
|||
|
-- coroutine.wait(0.05)
|
|||
|
-- --coroutine.yield(self.thread)
|
|||
|
-- end
|
|||
|
-- self.cacheData = {}
|
|||
|
-- coroutine.wait(0.5)
|
|||
|
-- self:ClosePanel()
|
|||
|
--end
|
|||
|
--self.thread = coroutine.start(progress)
|
|||
|
self:SetValue(context)
|
|||
|
end
|
|||
|
|
|||
|
function WarPowerChangeNotifyPanelV2:SetValue(context)
|
|||
|
self.countNumber = self.countNumber - 1
|
|||
|
local changeValue = context.newValue - context.oldValue
|
|||
|
self.powerValue.text = context.oldValue
|
|||
|
-- self.changeValueDown.transform.localPosition = Vector3.New(240 + string.len(context.oldValue) * 30, -6.23, 0)
|
|||
|
-- self.changeValueUp.transform.localPosition = Vector3.New(240 + string.len(context.oldValue) * 30, -6.23, 0)
|
|||
|
|
|||
|
self.changeValueUp.gameObject:SetActive(changeValue > 0)
|
|||
|
self.changeValueDown.gameObject:SetActive(changeValue < 0)
|
|||
|
|
|||
|
if self.tweener then
|
|||
|
self.tweener:Kill()
|
|||
|
end
|
|||
|
if isChanging then
|
|||
|
if changeValue > 0 then
|
|||
|
self.changeValueUp.text = changeValue
|
|||
|
else
|
|||
|
self.changeValueDown.text = -changeValue
|
|||
|
end
|
|||
|
self:DelayClose()
|
|||
|
return
|
|||
|
end
|
|||
|
|
|||
|
self.tweener = DoTween.To(DG.Tweening.Core.DOGetter_int(function()
|
|||
|
return 0
|
|||
|
end),DG.Tweening.Core.DOSetter_int(function(progress)
|
|||
|
if changeValue > 0 then
|
|||
|
self.changeValueUp.text = progress
|
|||
|
else
|
|||
|
self.changeValueDown.text = -progress
|
|||
|
end
|
|||
|
end), changeValue, 0.7):SetEase(Ease.Linear)
|
|||
|
:OnComplete(function()
|
|||
|
--if self.thread then
|
|||
|
-- coroutine.resume(self.thread)
|
|||
|
--end
|
|||
|
|
|||
|
--if self.countNumber == 0 then
|
|||
|
-- self:ClosePanel()
|
|||
|
--end
|
|||
|
self:DelayClose()
|
|||
|
end)
|
|||
|
isChanging = true
|
|||
|
end
|
|||
|
function WarPowerChangeNotifyPanelV2:DelayClose()
|
|||
|
if self.closeTweener then
|
|||
|
self.closeTweener:Kill()
|
|||
|
end
|
|||
|
self.closeTweener = DoTween.To(DG.Tweening.Core.DOGetter_int(function() return 0 end),
|
|||
|
DG.Tweening.Core.DOSetter_int(function(progress)end),
|
|||
|
0, 0.3):OnComplete(function()
|
|||
|
isChanging = false
|
|||
|
if self.countNumber == 0 then
|
|||
|
self:ClosePanel()
|
|||
|
end
|
|||
|
end)
|
|||
|
end
|
|||
|
|
|||
|
function WarPowerChangeNotifyPanelV2:OnClose()
|
|||
|
self.countNumber = 0
|
|||
|
--self:Reset()
|
|||
|
end
|
|||
|
|
|||
|
--function WarPowerChangeNotifyPanelV2:Reset()
|
|||
|
-- if self.thread then
|
|||
|
-- coroutine.stop(self.thread)
|
|||
|
-- end
|
|||
|
-- self.thread = nil
|
|||
|
--end
|
|||
|
|
|||
|
return WarPowerChangeNotifyPanelV2
|