GetPicItem = GetPicItem or BaseClass(BaseItem)
|
|
local GetPicItem = GetPicItem
|
|
|
|
function GetPicItem:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "GetGoodsItem"
|
|
self.is_delay_callback = true
|
|
self.can_go = true
|
|
|
|
self.model = ComposeModel:getInstance()
|
|
self.need_refresh = false
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function GetPicItem:__delete()
|
|
if self.icon_item then
|
|
self.icon_item:DeleteMe()
|
|
self.icon_item = nil
|
|
end
|
|
end
|
|
|
|
function GetPicItem:Load_callback()
|
|
self.icon = self:GetChild("icon"):GetComponent("Image")
|
|
self.icon_trans = self:GetChild("icon").transform
|
|
--self.bg = self:GetChild("bg"):GetComponent("Image")
|
|
self.name = self:GetChild("desc/name"):GetComponent("Text")
|
|
self.hint = self:GetChild("desc/hint"):GetComponent("Text")
|
|
self.level = self:GetChild("level"):GetComponent("Text")
|
|
self.go = self:GetChild("go").gameObject
|
|
self.mask = self:GetChild("mask").gameObject
|
|
self.recommend = self:GetChild("recommend").gameObject
|
|
self.click = self:GetChild("click").gameObject
|
|
|
|
self:InitEvent()
|
|
|
|
if self.need_refresh then
|
|
self:SetData(self.data, self.pic_id, self.callback)
|
|
end
|
|
end
|
|
|
|
function GetPicItem:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.click then
|
|
self:GoFunc()
|
|
end
|
|
end
|
|
AddClickEvent(self.click, onBtnClickHandler)
|
|
end
|
|
|
|
function GetPicItem:GoFunc()
|
|
if self.data[1] == "331" then
|
|
Message.show("请关注开启的各种精彩活动哦")
|
|
else
|
|
if self.can_go then
|
|
GlobalEventSystem:Fire(EventName.CLOSE_ALL_VIEW)
|
|
if self.data[1] == "132" then --野外挂机
|
|
self:FindWay()
|
|
elseif self.data[1] == "153" then --商城
|
|
local parm_1, parm_2
|
|
if self.data[2] == "6" then
|
|
parm_1 = 5
|
|
parm_2 = self.type_id
|
|
elseif self.data[2] == "7" then
|
|
parm_1 = self.type_id
|
|
parm_2 = 1
|
|
else
|
|
parm_1 = tonumber(self.data[2])
|
|
parm_2 = self.type_id
|
|
end
|
|
-- parm_2 = self.type_id
|
|
OpenFun.Open(self.data[1], self.data[2], parm_1, parm_2)
|
|
elseif self.data[1] == "150" then
|
|
local parm_1, parm_2
|
|
if self.data[2] == "1" then
|
|
-- parm_1 = ComposeModel.ComposePanelID.UPGRADE_ITEM
|
|
elseif self.data[2] == "2" then
|
|
parm_1 = ComposeModel.ComposePanelID.GOODS_JEWEL
|
|
elseif self.data[2] == "3" then
|
|
parm_1 = ComposeModel.ComposePanelID.GOODS_ITEM
|
|
elseif self.data[2] == "4" then
|
|
parm_1 = ComposeModel.ComposePanelID.GOODS_SUIT
|
|
elseif self.data[2] == "5" then
|
|
parm_1 = ComposeModel.ComposePanelID.UPGRADE_ITEM
|
|
end
|
|
parm_2 = Config.Goodscomposeindex[self.type_id].target_id
|
|
OpenFun.Open(self.data[1], self.data[2], parm_1, parm_2)
|
|
else
|
|
OpenFun.Open(self.data[1], self.data[2])
|
|
end
|
|
if self.callback then
|
|
self.callback()
|
|
end
|
|
else
|
|
Message.show("等级不足,快去升级吧!")
|
|
end
|
|
end
|
|
end
|
|
|
|
function GetPicItem:SetData(data, pic_id, callback)
|
|
self.data = data
|
|
self.pic_id = pic_id
|
|
self.callback = callback
|
|
if not self.data then return end
|
|
|
|
if self.is_loaded then
|
|
local main = tonumber(self.data[1])
|
|
local sub = tonumber(self.data[2])
|
|
local priority = self.data[3] == 1 and true or false
|
|
if main == 132 then --野外挂机
|
|
local cfg = Config.Ac["132@0@1"]
|
|
self.recommend:SetActive(priority)
|
|
self.name.text = Trim(cfg.ac_name)
|
|
lua_resM:setOutsideImageSprite(self, self.icon, GameResPath.GetDailyImage(Trim(cfg.ac_icon)), true)
|
|
else
|
|
local cfg = OpenFun.GetFunCfg(main, sub)
|
|
if cfg then
|
|
self.recommend:SetActive(priority)
|
|
self.name.text = cfg.name
|
|
local call_back = function( objs )
|
|
if not objs or not objs[0] then
|
|
lua_resM:setOutsideImageSprite(self,self.icon,GameResPath.GetDailyImage(cfg.icon_res),true)
|
|
end
|
|
end
|
|
local asset = cfg.icon_asset or "activityIcon_asset"
|
|
lua_resM:setImageSprite(self,self.icon,asset,cfg.icon_res, cfg.bool_fit,call_back)
|
|
|
|
if self.data[1] == "331" then --活动
|
|
self.hint.gameObject:SetActive(true)
|
|
self.hint.text = "请关注"..cfg.name.."的开启哦!"
|
|
self.go:SetActive(false)
|
|
self.level.text = ""
|
|
else
|
|
self.hint.gameObject:SetActive(false)
|
|
if RoleManager.Instance.mainRoleInfo.level < cfg.openLv then
|
|
self:SetState(false)
|
|
self.level.text = "<color="..ColorUtil.RED..">"..cfg.openLv.."级开启</color>"
|
|
else
|
|
self:SetState(true)
|
|
self.level.text = ""
|
|
end
|
|
end
|
|
end
|
|
end
|
|
else
|
|
self.need_refresh = true
|
|
end
|
|
end
|
|
|
|
function GetPicItem:SetState(bool)
|
|
self.can_go = bool
|
|
self.mask:SetActive(not bool)
|
|
self.go:SetActive(bool)
|
|
end
|
|
|
|
function GetPicItem:FindWay()
|
|
local onHookData = DailyModel:getInstance():GetOnhookConfig()
|
|
if onHookData then
|
|
local scene_id = tonumber(onHookData.scene_id)
|
|
local pointList = ErlangParser:GetInstance():Parse(onHookData.xy)
|
|
local index = math.random(1, #pointList)
|
|
local randomPoint = pointList[index]
|
|
local x = tonumber(randomPoint[1])
|
|
local y = tonumber(randomPoint[2])
|
|
|
|
local call_back = function ()
|
|
GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
|
|
end
|
|
local findVo = FindVo.New()
|
|
findVo.type = FindVo.POINT
|
|
findVo.sceneId = scene_id
|
|
findVo.x = x / SceneObj.LogicRealRatio.x
|
|
findVo.y = y / SceneObj.LogicRealRatio.y
|
|
findVo.call_back = call_back
|
|
|
|
GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
|
|
Scene.Instance:FindElement(findVo)
|
|
end
|
|
end
|