local MapMoveUI = class( "MapMoveUI", function ()
return cc.Layer:create()
end)
function MapMoveUI:ctor(obj, data)
self.obj = obj
self.cfgnpc = obj.cfgnpc --传送NPC的配置
self.cfgdel = obj.cfgdel
self.root = nil
self.ui = nil
self.npcidx = data
self:initUI(data)
end
function MapMoveUI:initUI(data)
self.root = ssrCreateExport(self.obj.ssrobjcfg.EXPORT_PATH)
self.ui = ssr.UIQuickChild(self.root)
ssrAddTouchEventListener({
widget = self.ui.img_bg,
callback = function ()
--ssrPrint("我是防点击穿透")
end,
scale = 1,
})
ssrAddTouchEventListener({
widget = self.ui.bg_close,
callback = function ()
--ssrPrint("我是关闭背景")
ssrUIManager:CLOSE(ssrObjCfg.MapMove)
end,
scale = 1,
})
ssrAddTouchEventListener({
widget = self.ui.btn_close,
callback = function ()
ssrUIManager:CLOSE(ssrObjCfg.MapMove)
end,
scale = 1,
})
ssrAddTouchEventListener({
widget = self.ui.btn_chuanshong,
callback = function ()
self:RequestZS()
end,
scale = 1,
})
self:updateUI()
self:addChild(self.root)
end
function MapMoveUI:updateUI()
local cfgnpc = self.obj.cfgnpc
local cfgdel = self.obj.cfgdel
local parent = self.ui.bg_di
local nparent = self.ui.SlV_jieshao
ssr.GUI:removeAllChildren(nparent)
for i=1,#cfgnpc do --循环显示界面出来
if cfgnpc[i]["npcidx"] == self.npcidx then
self.csid = cfgnpc[i]["Id"]
local hanld = self.ui.tx_mapname --最上面的名称
ssr.GUI:Text_setString(hanld,cfgnpc[i]["npc"])
-- local hanld = self.ui.tx_btn_jieshao --按钮上的 进入
-- ssr.GUI:Text_setString(hanld,cfgnpc[i]["anniu"])
if cfgdel[cfgnpc[i]["Id"]]["cost"] ~= nil then
local hanld = self.ui.tx_xiaohao --显示价格
local itemname = ssrDataPlayer:getItemNameByIdx(cfgdel[cfgnpc[i]["Id"]]["cost"][1][1])
ssr.GUI:Text_setString(hanld,itemname..":"..cfgdel[cfgnpc[i]["Id"]]["cost"][1][2])
else
local hanld = self.ui.tx_xiaohao --显示价格
ssr.GUI:Text_setString(hanld,"免费进入")
end
--local Effhanld = ssr.GUI:Effect_Create(parent, "monster", 215, 200, 0, cfgnpc[i]["img"], 0, 0, 3, 1) --怪物模型
local str = cfgnpc[i]["mapDesc"]
ssr.GUI:RichText_Create(nparent, "p_xh_pos", 115, 20, str, ssrConstCfg.width)
local itemparent = self.ui.lv_item
ssr.GUI:ListView_setItemsMargin(itemparent, 12)
for j=1,#cfgnpc[i]["yulan"] do
local itemdata = {}
itemdata.index = cfgnpc[i]["yulan"][j]
itemdata.look = true
itemdata.bgVisible = true
itemdata.count = 1
itemdata.color = 225
ssr.GUI:ItemShow_Create(itemparent, "item_"..j, 190+(120*j), 0, itemdata)
end
ssr.GUI:Text_setString(self.ui.tx_title,cfgnpc[i]["mapname"])
break
end
end
end
-------------------------------↓↓↓ 网络消息 ↓↓↓---------------------------------------
function MapMoveUI:RequestZS() --转生按钮进入
local csid = self.csid
self.obj:RequestZS(csid) --转入obj
end
return MapMoveUI