|
|
-
- GetWayTipsView = GetWayTipsView or BaseClass(BaseView)
- function GetWayTipsView:__init()
- self.base_file = "common"
- self.layout_file = "GetWayTipsView"
- self.layer_name = "Top"
- self.destroy_imm = true
- self.use_background = false
- self.background_alpha = 0
- self.pos_x = nil
- self.pos_y = nil
- self.type_id = nil
- self.item_list = {} --item列表
- self.show_animation = false
- self.hide_background = false
- self:AddPreLoadList("common",{"GetWayTipsItem"})
- self.load_callback = function()
- self:LoadSuccess()
- self:InitEvent()
- end
- self.open_callback = function()
- self:SetPosAndAnimation()
- self:InitViewInfo()
- end
- self.close_callback = function ()
-
- end
- self.destroy_callback = function()
- self:Remove()
- end
- end
-
- function GetWayTipsView:SetPosAndAnimation()
- if self.transform and self.pos_x and self.pos_y then
- local pos = self.transform.localPosition
- if self.show_animation then
- self.transform.localPosition = Vector3(self.transform.localPosition.x, self.pos_y, self.transform.localPosition.z)
- self.canvasGroup.alpha = 0
- local end_fun = function ()
-
- end
- TweenLite.to(self, self.transform, TweenLite.UiAnimationType.POS, Vector3(self.pos_x, self.pos_y, pos.z), 0.3, end_fun)
- TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 1, 0.5)
- self.clickBg.transform.localPosition = Vector3(-self.pos_x, -self.pos_y, -pos.z)
- else
- self.transform.localPosition = Vector3(self.pos_x, self.pos_y, pos.z)
- self.clickBg.transform.localPosition = Vector3(-self.pos_x, -self.pos_y, -pos.z)
- end
- if self.hide_background and self.clickBg then
- self.clickBg:SetActive(false)
- end
-
- end
- end
-
- function GetWayTipsView:Open(type_id, x, y, show_animation, hide_background)
- self.type_id = type_id
- self.pos_x = x
- self.pos_y = y
- self.show_animation = show_animation
- self.hide_background = hide_background
- BaseView.Open(self)
- end
-
- function GetWayTipsView:Remove()
- for i,v in ipairs(self.item_list) do
- v:DeleteMe()
- v = nil
- end
- self.item_list = {}
- if self.event_id then
- GlobalEventSystem:UnBind(self.event_id)
- self.event_id = nil
- end
- if self.event_id2 then
- GlobalEventSystem:UnBind(self.event_id2)
- self.event_id2 = nil
- end
- if self.event_id3 then
- GlobalEventSystem:UnBind(self.event_id3)
- self.event_id3 = nil
- end
- end
-
- function GetWayTipsView:LoadSuccess()
- self.canvasGroup = self.transform:GetComponent("CanvasGroup")
- self.bg = self:GetChild("bg")
- self.ScrollView = self:GetChild("ScrollView/Viewport/Content")
- self.clickBg = self:GetChild("clickBg").gameObject
- self.desc_bg_img = self:GetChild("layout/desc_bg"):GetComponent("Image")
- lua_resM:setOutsideImageSprite(self,self.desc_bg_img,GameResPath.GetViewBigBg("goods_tool_tip_bg"),false)
- SetSizeDelta(self.bg, ScreenWidth, ScreenHeight)
- end
-
- function GetWayTipsView:InitEvent()
- local call_fun = function ()
- if self then
- self:Close()
- GlobalEventSystem:Fire(EventName.CLICK_GET_WAY_CLOSE)
- end
- end
- self.event_id = GlobalEventSystem:Bind(EventName.CLICK_GET_WAY_ITEM, call_fun)
- self.event_id2 = GlobalEventSystem:Bind(EventName.GOODS_TOOLTIP_CLOSE, call_fun)
- self.event_id3 = GlobalEventSystem:Bind(CultureEvent.CLOSE_EQUIP_CULTURE_TIPS_VIEW, call_fun)
-
- AddClickEvent(self.clickBg,call_fun)
-
- end
-
- function GetWayTipsView:InitViewInfo()
- local goodsVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
- if goodsVo == nil then
- -- print("没有找到对应的物品vo----------:", self.type_id)
- return
- end
-
- self:ShowGainWay(goodsVo)
- end
-
- function GetWayTipsView:ShowGainWay(goodsVo)
- -- local list = ErlangParser:GetInstance():Parse(goodsVo.getway)
- -- goodsVo.getway = "1,2,3,4"
- local arr = Split(goodsVo.getway,",")
- -- print("--------------goodsVo.getway---:", goodsVo.getway)
- -- PrintTable(arr)
- for i,v in ipairs(self.item_list) do
- v:DeleteMe()
- v = nil
- end
- self.item_list = {}
- if not IsTableEmpty(arr) then
- for k,v in ipairs(arr) do
- local item = self.item_list[k]
- if item == nil then
- item = GetWayTipsItem.New(self.ScrollView)
- self.item_list[k] = item
- end
- item:SetPosition(0,-85*(k - 1))
- item:SetData(v)
- end
- self.ScrollView.sizeDelta = Vector2(290,#arr*85)
- end
- end
|