源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

122 行
2.8 KiB

  1. StarPointItem = StarPointItem or BaseClass(BaseItem)
  2. function StarPointItem:__init()
  3. self.base_file = "starMap"
  4. self.layout_file = "StarPointItem"
  5. self.data = nil
  6. self.model = StarMapModel:getInstance()
  7. self:Load()
  8. end
  9. function StarPointItem:Load_callback()
  10. self.light = self:GetChild("checkmark").gameObject
  11. self.select = self:GetChild("select").gameObject
  12. self.bg = self:GetChild("bg").gameObject
  13. if self.need_refreshData then
  14. self:SetData(self.data)
  15. end
  16. if self.need_setLight then
  17. self:SetLight(self.is_light)
  18. end
  19. if self.need_setSelect then
  20. self:SetSelect(self.is_select)
  21. end
  22. if self.need_setNext then
  23. self:SetIsNext(self.is_next)
  24. end
  25. self:InitEvent()
  26. end
  27. function StarPointItem:InitEvent()
  28. local function onClick(target)
  29. if target == self.bg then
  30. self.model:Fire(StarMapModel.CLICK_POINT_ITEM,self.data.point_id,self.data.star_map_id)
  31. end
  32. end
  33. AddClickEvent(self.bg,onClick)
  34. end
  35. function StarPointItem:SetData(data)
  36. if data == nil then return end
  37. self.data = data
  38. if self.is_loaded then
  39. local pos = self.model:GetPointPos(data.star_map_id)
  40. if pos then
  41. self:SetPosition(pos.x,pos.y)
  42. end
  43. self.need_refreshData = false
  44. else
  45. self.need_refreshData = true
  46. end
  47. end
  48. function StarPointItem:SetLight(bool)
  49. self.is_light = bool
  50. if self.is_loaded then
  51. self.light:SetActive(bool)
  52. self.need_setLight = false
  53. else
  54. self.need_setLight = true
  55. end
  56. end
  57. function StarPointItem:SetSelect(bool)
  58. self.is_select = bool
  59. if self.is_loaded then
  60. self.select:SetActive(bool)
  61. self.need_setSelect = false
  62. else
  63. self.need_setSelect = true
  64. end
  65. end
  66. function StarPointItem:SetIsNext(bool)
  67. self.is_next = bool
  68. if self.is_loaded then
  69. --self.can:SetActive(bool)
  70. if bool then
  71. self.light:SetActive(true)
  72. self:AlphaAnimation(0.35)
  73. self.need_setNext = false
  74. else
  75. self.light:GetComponent("Image").alpha = 1
  76. self:StopAnim()
  77. end
  78. else
  79. self.need_setNext = true
  80. end
  81. end
  82. --图片上下移动
  83. function StarPointItem:AlphaAnimation(time)
  84. local call_fun = function ()
  85. local function onCompleted()
  86. self:AlphaAnimation(time)
  87. end
  88. self.tween_id3 =TweenLite.to(self, self.light:GetComponent("Image"),TweenLite.UiAnimationType.ALPHA,0.8,time,onCompleted)
  89. end
  90. local onDelay = function( )
  91. self.tween_id2 =TweenLite.to(self, self.light:GetComponent("Image"),TweenLite.UiAnimationType.ALPHA,0, time, call_fun)
  92. end
  93. self.arrow_timer_id = setTimeout(onDelay, time)
  94. end
  95. function StarPointItem:StopAnim()
  96. if self.tween_id2 then
  97. TweenLite.Stop(self.tween_id2)
  98. self.tween_id2 = nil
  99. end
  100. if self.tween_id3 then
  101. TweenLite.Stop(self.tween_id3)
  102. self.tween_id3 = nil
  103. end
  104. if self.arrow_timer_id then
  105. GlobalTimerQuest:CancelQuest(self.arrow_timer_id)
  106. self.arrow_timer_id = nil
  107. end
  108. end
  109. function StarPointItem:__delete()
  110. self:StopAnim()
  111. end