GuanMingOBJ = {}
GuanMingOBJ.__cname = "GuanMingOBJ"
GuanMingOBJ.config = ssrRequireCsvCfg("cfg_GuanMing")
GuanMingOBJ.cost = {{}}
GuanMingOBJ.give = {{}}
-- [1] = {
-- need = 3000,
-- give = {
-- [1] = {
-- [1] = "冠名大哥[称号]",
-- [2] = 1,
-- },
-- [2] = {
-- [1] = "龙行天下[时装]",
-- [2] = 1,
-- },
-- },
-- title = "冠名大哥",
-- effect = {
-- [1] = 40183,
-- [2] = 63062,
-- },
-- },
-------------------------------↓↓↓ UI操作 ↓↓↓---------------------------------------
function GuanMingOBJ:main(objcfg)
local parent = GUI:Win_Create(self.__cname, -20, 0, 0, 0, false, false, true, true, true, objcfg.NPCID)
GUI:LoadExport(parent, objcfg.UI_PATH)
self._parent = parent
self.ui = GUI:ui_delegate(parent)
ssrSetWidgetPosition(parent, self.ui.ImageBG, 2,-60)
GUI:addOnClickEvent(self.ui.ImageBG, function()
--ssrPrint("我是防点击穿透")
end)
--关闭按钮
GUI:addOnClickEvent(self.ui.CloseButton, function()
GUI:Win_Close(self._parent)
end)
-- 打开窗口缩放动画
GUI:Timeline_Window1(self._parent)
--网络消息示例
GUI:addOnClickEvent(self.ui.Button_1, function()
ssrMessage:sendmsg(ssrNetMsgCfg.GuanMing_Request)
end)
GuanMingOBJ:UpdateUI()
end
function GuanMingOBJ:UpdateUI()
for i=1,#GuanMingOBJ.config[1].give do
local _Handle = GUI:GetWindow(self.ui.ImageBG,"item"..i)
if _Handle then
local item_data = {}
item_data.index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", GuanMingOBJ.config[1].give[i][1])
item_data.look = true
item_data.bgVisible = false
item_data.count = GuanMingOBJ.config[1].give[i][3]
item_data.color = 250
GUI:setVisible(_Handle, true)
GUI:ItemShow_updateItem(_Handle,item_data)
end
end
local Effect_1 = GUI:Effect_Create(self.ui.ImageBG, "Effect_1", 350.00, 160, 4, GuanMingOBJ.config[1].effect[1], 0, 0, 2, 1)
GUI:setTag(Effect_1, 0)
-- Create Effect_1
Effect_1 = GUI:Effect_Create(self.ui.ImageBG, "Effect_2", 370.00, 320.00, 0, GuanMingOBJ.config[1].effect[2], 0, 0, 0, 1)
GUI:setTag(Effect_1, 0)
end
-------------------------------↓↓↓ 网络消息 ↓↓↓---------------------------------------
function GuanMingOBJ:SyncResponse(arg1, arg2, arg3, data)
if GUI:GetWindow(nil, self.__cname) then
self:UpdateUI()
end
end
return GuanMingOBJ
冠名大哥
local ui = {}
local _V = function(v) return SL:GetMetaValue(v) end
local FUNCQUEUE = {}
local TAGOBJ = {}
function ui.init(parent, __data__, __update__)
if __update__ then return ui.update(__data__) end
-- Create ImageBG
local ImageBG = GUI:Image_Create(parent, "ImageBG", 103.00, 33.00, "res/custom/guanming/bgk.png")
GUI:setAnchorPoint(ImageBG, 0.00, 0.00)
GUI:setTouchEnabled(ImageBG, false)
GUI:setTag(ImageBG, -1)
-- Create CloseButton
local CloseButton = GUI:Button_Create(ImageBG, "CloseButton", 1004.00, 458.00, "res/custom/guanming/close.png")
GUI:Button_setTitleText(CloseButton, [[]])
GUI:Button_setTitleColor(CloseButton, "#ffffff")
GUI:Button_setTitleFontSize(CloseButton, 14)
GUI:Button_titleEnableOutline(CloseButton, "#000000", 1)
GUI:setAnchorPoint(CloseButton, 0.00, 0.00)
GUI:setTouchEnabled(CloseButton, true)
GUI:setTag(CloseButton, -1)
-- Create Button_1
local Button_1 = GUI:Button_Create(ImageBG, "Button_1", 683.00, 45.00, "res/custom/guanming/button.png")
GUI:Button_setTitleText(Button_1, [[]])
GUI:Button_setTitleColor(Button_1, "#ffffff")
GUI:Button_setTitleFontSize(Button_1, 16)
GUI:Button_titleDisableOutLine(Button_1)
GUI:setAnchorPoint(Button_1, 0.00, 0.00)
GUI:setTouchEnabled(Button_1, true)
GUI:setTag(Button_1, 0)
-- Create item1
local item1 = GUI:ItemShow_Create(ImageBG, "item1", 728.00, 200.00, {index = 1, count = 1, look = true, bgVisible = false})
GUI:setAnchorPoint(item1, 0.50, 0.50)
GUI:setTag(item1, 0)
-- Create item2
local item2 = GUI:ItemShow_Create(ImageBG, "item2", 849.00, 200.00, {index = 1, count = 1, look = true, bgVisible = false})
GUI:setAnchorPoint(item2, 0.50, 0.50)
GUI:setTag(item2, 0)
ui.update(__data__)
return ImageBG
end
function ui.update(data)
for _, func in pairs(FUNCQUEUE) do
if func then func(data) end
end
end
return ui
local GuanMing = {}
GuanMing.ID = "冠名"
local npcID = 117
GuanMing.config = include("QuestDiary/cfgcsv/cfg_GuanMing.lua") --配置
local cost = {{}}
local give = {{}}
--接收请求
function GuanMing.Request(actor)
local receive = getflagstatus(actor,VarCfg["F_冠名领取"])
if receive == 1 then
Player.sendmsgEx(actor, "提示#251|:#255|你已经领取过冠名了!")
return ""
end
if getplaydef(actor,VarCfg["U_真实充值"] ) < GuanMing.config[1].need then
Player.sendmsgEx(actor, "提示#251|:#255|你的累计充值少于"..GuanMing.config[1].need.."元,无法领取!")
return ""
end
if getbagblank(actor) < 10 then
Player.sendmsgEx(actor, "提示#251|:#255|请给背包留足够的位置,在领取!")
return ""
end
--if not checktitle(actor,GuanMing.config[1].title) then
-- confertitle(actor,GuanMing.config[1].title,1)
--end
--release_print(tbl2json(GuanMing.config[1].give[2]))
sendmail("#"..getbaseinfo(actor,1),1,"冠名奖励","恭喜获得冠名奖励,称号直接配带,此处只发放时装",GuanMing.config[1].give[1][1].."#"..GuanMing.config[1].give[1][2].."#307&"..GuanMing.config[1].give[2][1].."#"..GuanMing.config[1].give[2][2].."#307")
--Player.giveItemByTable(actor, {GuanMing.config[1].give[2]}, "冠名奖励", 1, true)
setflagstatus(actor,VarCfg["F_冠名领取"],1)
Player.sendmsgEx(actor, "提示#251|:#255|领取冠名成功!")
return ""
end
--同步消息
function GuanMing.SyncResponse(actor, logindatas)
local data = {}
local _login_data = {ssrNetMsgCfg.GuanMing_SyncResponse, 0, 0, 0, data}
if logindatas then
table.insert(logindatas, _login_data)
else
Message.sendmsg(actor, ssrNetMsgCfg.GuanMing_SyncResponse, 0, 0, 0, data)
end
end
--登录触发
local function _onLoginEnd(actor, logindatas)
GuanMing.SyncResponse(actor, logindatas)
end
-- --事件派发
GameEvent.add(EventCfg.onLoginEnd, _onLoginEnd, GuanMing)
--注册网络消息
Message.RegisterNetMsg(ssrNetMsgCfg.GuanMing, GuanMing)
return GuanMing