源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 line
1.5 KiB

  1. StarLineItem = StarLineItem or BaseClass(BaseItem)
  2. function StarLineItem:__init()
  3. self.base_file = "starMap"
  4. self.layout_file = "StarLineItem"
  5. self.data = nil
  6. self.is_delay_callback = true
  7. self.model = StarMapModel:getInstance()
  8. self:Load()
  9. end
  10. function StarLineItem:Load_callback()
  11. self.checkmark = self:GetChild("checkmark"):GetComponent("ImageExtend")
  12. if self.need_refreshData then
  13. self:SetData(self.data)
  14. end
  15. if self.need_setLight then
  16. self:SetLight(self.is_light)
  17. end
  18. end
  19. function StarLineItem:SetData(data)
  20. if data == nil then return end
  21. self.data = data
  22. if self.is_loaded then
  23. local pos1 = self.model:GetPointPos(data.star_map_id)
  24. local pos2 = self.model:GetPointPos(data.star_map_id+1)
  25. if pos1 == nil or pos2 == nil then return end
  26. local pos_x = math.floor((pos1.x + pos2.x)/2)
  27. local pos_y = math.floor((pos1.y + pos2.y)/2)
  28. local length = math.floor(GameMath.GetDistance(pos1.x,pos1.y,pos2.x,pos2.y,true))
  29. local angle = math.atan((pos2.y-pos1.y)/(pos2.x-pos1.x))*180/math.pi
  30. self.transform.sizeDelta = Vector2(length,14)
  31. --self.checkmark.transform.sizeDelta = Vector2(length,4)
  32. self:SetPosition(pos_x,pos_y)
  33. self:SetRotation(0,0,angle)
  34. self.need_refreshData = false
  35. else
  36. self.need_refreshData = true
  37. end
  38. end
  39. function StarLineItem:SetLight(bool)
  40. self.is_light = bool
  41. if self.is_loaded then
  42. self.checkmark.gray = not bool
  43. self.need_setLight = false
  44. else
  45. self.need_setLight = true
  46. end
  47. end
  48. function StarLineItem:__delete()
  49. end