|
--大血条
|
|
BigBloodBar = BigBloodBar or BaseClass(BaseComponent)
|
|
local BigBloodBar= BigBloodBar
|
|
function BigBloodBar:__init(parent, max_value, curr_value)
|
|
self.hp_width = 64
|
|
self.hp_height = 6
|
|
self:InitData(max_value, curr_value)
|
|
self:CreateGameObject(UIType.BigBloodBar)
|
|
end
|
|
|
|
function BigBloodBar:InitData(max_value, curr_value)
|
|
self.ab_name = "uicomponent_asset"
|
|
self.max_value = max_value or 100 --最大值
|
|
self.curr_value = curr_value or 1 --当前值
|
|
self.last_value = self.curr_value --上一次值
|
|
end
|
|
|
|
function BigBloodBar:LoadSuccess()
|
|
self.bg_img = self:GetChild("bg_img")
|
|
-- self.virtual_img = self:GetChild("virtual_img")
|
|
self.realy_img = self:GetChild("realy_img"):GetComponent("Image")
|
|
self:SetValue()
|
|
end
|
|
|
|
function BigBloodBar:SetValue(value,max_value)
|
|
self.curr_value = value or self.curr_value
|
|
self.max_value = max_value or self.max_value
|
|
self.curr_value = math.min(self.curr_value,self.max_value)
|
|
self.last_value = math.min(self.last_value,self.max_value)
|
|
self.realy_img.fillAmount = math.min(self.curr_value / self.max_value,1)
|
|
end
|
|
|
|
function BigBloodBar:SetFrontImageStyle(front_img_name)
|
|
if self.front_img_name == front_img_name then return end
|
|
self.front_img_name = front_img_name
|
|
lua_resM:setImageSprite(self,self.realy_img:GetComponent("Image"),self.ab_name,self.front_img_name)
|
|
end
|
|
|
|
|
|
function BigBloodBar:__delete()
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
destroy(self.gameObject)
|
|
end
|