StarPointItem = StarPointItem or BaseClass(BaseItem) function StarPointItem:__init() self.base_file = "starMap" self.layout_file = "StarPointItem" self.data = nil self.model = StarMapModel:getInstance() self:Load() end function StarPointItem:Load_callback() self.light = self:GetChild("checkmark").gameObject self.select = self:GetChild("select").gameObject self.bg = self:GetChild("bg").gameObject if self.need_refreshData then self:SetData(self.data) end if self.need_setLight then self:SetLight(self.is_light) end if self.need_setSelect then self:SetSelect(self.is_select) end if self.need_setNext then self:SetIsNext(self.is_next) end self:InitEvent() end function StarPointItem:InitEvent() local function onClick(target) if target == self.bg then self.model:Fire(StarMapModel.CLICK_POINT_ITEM,self.data.point_id,self.data.star_map_id) end end AddClickEvent(self.bg,onClick) end function StarPointItem:SetData(data) if data == nil then return end self.data = data if self.is_loaded then local pos = self.model:GetPointPos(data.star_map_id) if pos then self:SetPosition(pos.x,pos.y) end self.need_refreshData = false else self.need_refreshData = true end end function StarPointItem:SetLight(bool) self.is_light = bool if self.is_loaded then self.light:SetActive(bool) self.need_setLight = false else self.need_setLight = true end end function StarPointItem:SetSelect(bool) self.is_select = bool if self.is_loaded then self.select:SetActive(bool) self.need_setSelect = false else self.need_setSelect = true end end function StarPointItem:SetIsNext(bool) self.is_next = bool if self.is_loaded then --self.can:SetActive(bool) if bool then self.light:SetActive(true) self:AlphaAnimation(0.35) self.need_setNext = false else self.light:GetComponent("Image").alpha = 1 self:StopAnim() end else self.need_setNext = true end end --图片上下移动 function StarPointItem:AlphaAnimation(time) local call_fun = function () local function onCompleted() self:AlphaAnimation(time) end self.tween_id3 =TweenLite.to(self, self.light:GetComponent("Image"),TweenLite.UiAnimationType.ALPHA,0.8,time,onCompleted) end local onDelay = function( ) self.tween_id2 =TweenLite.to(self, self.light:GetComponent("Image"),TweenLite.UiAnimationType.ALPHA,0, time, call_fun) end self.arrow_timer_id = setTimeout(onDelay, time) end function StarPointItem:StopAnim() if self.tween_id2 then TweenLite.Stop(self.tween_id2) self.tween_id2 = nil end if self.tween_id3 then TweenLite.Stop(self.tween_id3) self.tween_id3 = nil end if self.arrow_timer_id then GlobalTimerQuest:CancelQuest(self.arrow_timer_id) self.arrow_timer_id = nil end end function StarPointItem:__delete() self:StopAnim() end