|
|
- LightTabItem = LightTabItem or BaseClass(BaseItem)
- local LightTabItem = LightTabItem
-
- LightTabItem.Width = 121
- LightTabItem.Height = 125
-
- function LightTabItem:__init(parent_wnd,prefab_asset,layer_name)
- self.base_file = "light"
- self.layout_file = "LightTabItem"
- self.layer_name = layer_name
- self.model = LightModel:GetInstance()
-
- self:Load()
- end
-
- function LightTabItem:Load_callback()
- self.nodes = {
- "di_can:obj", "lock:obj", "lb_lock_des:tmp", "icon:img", "di:img:obj", "red_dot:obj",
- "mask:obj", "light:obj", "di_name:obj",
- }
- self:GetChildren(self.nodes)
- self:AddEvents()
-
- if self.need_refreshData then
- self:UpdateView()
- end
- end
-
- function LightTabItem:AddEvents( )
- local function call_back( target )
- if self.call_back then
- self.call_back(self.data.id)
- end
- if self.index == 1 then
- --完成引导
- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,3)
- if helpVo and helpVo.step == 3 then
- GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
- end
- end
- end
- AddClickEvent(self.di_obj,call_back,false)
-
- local function onGuideTrigger()
- self:AddToStageHandler()
- end
- self.guide_trigger_id = GlobalEventSystem:Bind(EventName.TRIGGER_GUIDE_TYPE,onGuideTrigger)
- end
-
- function LightTabItem:UpdateView( )
- if not self.data then
- return
- end
-
- local can_active = self.model:CanLightActive( false,self.data.id )
- local is_active = self.model:GetLightIsActive( self.data.id )
- local conf = self.model:GetLightConfOne(self.data.id)
- local cur_is_me = self.data.id == self.cur_select_id
- self.lock_obj:SetActive(not is_active)
- self.di_can_obj:SetActive(can_active)
- self.di_name_obj:SetActive(not is_active)
- self.lb_lock_des_tmp.text = (is_active or can_active) and "" or Trim(self.data.desc)
-
- -- lua_resM:setImageSprite(self, self.di_img, "light_asset", cur_is_me and "light_di_19" or "light_di_20",true)
- lua_resM:setImageSprite(self, self.di_img, "light_asset", "light_di_19" .. "_" .. conf.color,true)
-
- local function call_back( )
- local x,y = GetSizeDeltaXY(self.icon.transform)
- local scale = 1
- if x > y then
- if x > 104 then
- scale = 104/x
- end
- else
- if y > 104 then
- scale = 104/y
- end
- end
- SetLocalScale(self.icon.transform, scale,scale,scale)
- end
- lua_resM:setOutsideImageSprite(self,self.icon_img,"/client/assets/icon/light/light_head_" .. self.data.id .. ".png",true,call_back)
-
- self.mask_obj:SetActive( not is_active )
- self.light_obj:SetActive(cur_is_me)
- self:UpdateRed()
- end
-
- function LightTabItem:UpdateRed( )
- if not self.is_loaded then return end
- if not self.data then
- return
- end
- local can_active = self.model:CanLightActive( false,self.data.id )
- self.red_dot_obj:SetActive(can_active or self.model:CanLightUpGrade( false,self.data.id ))
- self:AddToStageHandler()
- end
-
- function LightTabItem:SetData( index, data, call_back, cur_select_id )
- self.index = index
- self.data = data
- self.call_back = call_back
- self.cur_select_id = cur_select_id
- if self.is_loaded then
- self.need_refreshData = false
- self:UpdateView()
- else
- self.need_refreshData = true
- end
- end
-
- function LightTabItem:__delete( )
- if self.guide_trigger_id then
- GlobalEventSystem:UnBind(self.guide_trigger_id)
- self.guide_trigger_id = nil
- end
- end
-
- function LightTabItem:AddToStageHandler()
- if self.index ~= 1 then return end
- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,3)
- if not helpVo then return end
- local help_type = helpVo.help_type
- local step = helpVo.step
- local button = false
- if help_type == HelpType.TYPE_LIGHT and step == 3 then
- button = self.di_obj
- end
- if button then
- GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, self.transform, call_back, helpVo, self.layout_file)
- end
- end
|