BufferTipsItem = BufferTipsItem or BaseClass(BaseItem)
|
|
function BufferTipsItem:__init(parent_wnd)
|
|
self.base_file = "autoFight"
|
|
self.layout_file = "BufferTipsItem"
|
|
self.data = nil
|
|
self.model = AutoFightManager:getInstance()
|
|
self:Load()
|
|
end
|
|
|
|
function BufferTipsItem:Load_callback()
|
|
self.name = self:GetChild("name"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
self.leftTimeObj = self:GetChild("leftTime").gameObject
|
|
self.leftTime = self:GetChild("leftTime"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
self.leftTime.text = ""
|
|
self.desc = self:GetChild("desc"):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
self.iconImg = self:GetChild("iconBg"):GetComponent("Image")
|
|
self.line_obj = self:GetChild("line").gameObject
|
|
|
|
if self.need_refreshData then
|
|
self:SetData(self.data, self.is_end)
|
|
end
|
|
|
|
self:InitEvent()
|
|
end
|
|
|
|
function BufferTipsItem:InitEvent()
|
|
end
|
|
|
|
--1是VIP,2是永恒回复,3是经验药水,4是技能buff
|
|
function BufferTipsItem:SetData(data, is_end)
|
|
self.data = data
|
|
self.is_end = is_end
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
if self.data == nil then return end
|
|
self:UpdateBuffView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function BufferTipsItem:UpdateBuffView()
|
|
local cfg = Config.ConfigBuffIcon[self.data.id]
|
|
if cfg then
|
|
if self.data.style == 1 then
|
|
local vip_level = RoleManager.Instance.mainRoleInfo.vip_flag
|
|
local temp_cfg = cfg.level_info[vip_level]
|
|
if temp_cfg then
|
|
self.name.text = temp_cfg.name
|
|
self.desc.text = ChuanWenManager:getInstance():FormatColorTag(temp_cfg.desc)
|
|
end
|
|
else
|
|
self.name.text = cfg.name
|
|
self.desc.text = ChuanWenManager:getInstance():FormatColorTag(cfg.desc)
|
|
end
|
|
lua_resM:setImageSprite(self, self.iconImg, "mainUI_asset", cfg.icon_id)
|
|
|
|
--倒计时
|
|
if self.data.style == 3 then
|
|
local left_time = self.data.end_time - TimeUtil:getServerTime()
|
|
self:CreateBuffTimer(left_time)
|
|
elseif self.data.style == 4 then
|
|
local main_role = Scene.Instance.main_role
|
|
if not main_role then
|
|
return
|
|
end
|
|
local buff_manager = main_role.buff_manager
|
|
if not buff_manager then
|
|
return
|
|
end
|
|
local buff_list_vo = buff_manager:getBuffDic(self.data.buff_type)
|
|
local buff_vo = buff_list_vo and buff_list_vo:GetBuffBySkillId(self.data.skill_id)
|
|
local left_time = buff_vo and buff_vo:GetLeftTime() or 0
|
|
self:CreateBuffTimer(round(left_time))
|
|
end
|
|
|
|
self.line_obj:SetActive(not self.is_end)
|
|
end
|
|
end
|
|
|
|
function BufferTipsItem:GetAllHeight()
|
|
return 96
|
|
end
|
|
|
|
function BufferTipsItem:CancelTimer( )
|
|
if self.buff_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.buff_timer_id)
|
|
self.buff_timer_id = nil
|
|
end
|
|
end
|
|
|
|
function BufferTipsItem:CreateBuffTimer(time)
|
|
self:CancelTimer()
|
|
local time = time or 0
|
|
if time > 0 then
|
|
local function onTimer()
|
|
time = time - 1
|
|
if time > 0 then
|
|
self.leftTime.text = TimeUtil:qianggouTimeLeft2(tonumber(time))
|
|
else
|
|
self.leftTime.text = ""
|
|
self:CancelTimer()
|
|
end
|
|
end
|
|
onTimer()
|
|
self.buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
|
|
end
|
|
end
|
|
|
|
function BufferTipsItem:SetVisible(flag)
|
|
BaseItem.SetVisible(self,flag)
|
|
if not flag then
|
|
self:CancelTimer()
|
|
end
|
|
end
|
|
|
|
function BufferTipsItem:__delete()
|
|
self:CancelTimer()
|
|
end
|