StarLineItem = StarLineItem or BaseClass(BaseItem)
|
|
|
|
function StarLineItem:__init()
|
|
self.base_file = "starMap"
|
|
self.layout_file = "StarLineItem"
|
|
self.data = nil
|
|
self.is_delay_callback = true
|
|
self.model = StarMapModel:getInstance()
|
|
self:Load()
|
|
end
|
|
|
|
function StarLineItem:Load_callback()
|
|
self.checkmark = self:GetChild("checkmark"):GetComponent("ImageExtend")
|
|
if self.need_refreshData then
|
|
self:SetData(self.data)
|
|
end
|
|
if self.need_setLight then
|
|
self:SetLight(self.is_light)
|
|
end
|
|
end
|
|
|
|
function StarLineItem:SetData(data)
|
|
if data == nil then return end
|
|
self.data = data
|
|
if self.is_loaded then
|
|
local pos1 = self.model:GetPointPos(data.star_map_id)
|
|
local pos2 = self.model:GetPointPos(data.star_map_id+1)
|
|
if pos1 == nil or pos2 == nil then return end
|
|
local pos_x = math.floor((pos1.x + pos2.x)/2)
|
|
local pos_y = math.floor((pos1.y + pos2.y)/2)
|
|
local length = math.floor(GameMath.GetDistance(pos1.x,pos1.y,pos2.x,pos2.y,true))
|
|
local angle = math.atan((pos2.y-pos1.y)/(pos2.x-pos1.x))*180/math.pi
|
|
|
|
self.transform.sizeDelta = Vector2(length,14)
|
|
--self.checkmark.transform.sizeDelta = Vector2(length,4)
|
|
self:SetPosition(pos_x,pos_y)
|
|
self:SetRotation(0,0,angle)
|
|
self.need_refreshData = false
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function StarLineItem:SetLight(bool)
|
|
self.is_light = bool
|
|
if self.is_loaded then
|
|
self.checkmark.gray = not bool
|
|
self.need_setLight = false
|
|
else
|
|
self.need_setLight = true
|
|
end
|
|
end
|
|
|
|
function StarLineItem:__delete()
|
|
|
|
end
|