主站
首页
案例中心
UI编辑 - 数字华容道
UI编辑 - 数字华容道
树林花园 更新时间: 2022-08-30 17:47:00

 

脚本:

--按地图实际修改变量/列表里的内容即可
uiid=[[7057027238849384889]]--数字华容道的UI界面的ID
digital_slider={[[7057027238849384889_6]],[[7057027238849384889_30]],[[7057027238849384889_10]],[[7057027238849384889_2]],[[7057027238849384889_14]],[[7057027238849384889_26]],[[7057027238849384889_8]],[[7057027238849384889_22]],[[7057027238849384889_16]],[[7057027238849384889_4]],[[7057027238849384889_18]],[[7057027238849384889_12]],[[7057027238849384889_20]],[[7057027238849384889_24]],[[7057027238849384889_28]],0}--数字滑块的ID(别忘了空的那一格为0哦)
elementid_x={2,115,228,341,2,115,228,341,2,115,228,341,2,115,228,341}--数字滑块的x坐标
elementid_y={2,2,2,2,115,115,115,115,228,228,228,228,341,341,341,341}--数字滑块的y坐标
layout={3,15,5,1,7,13,4,11,8,2,9,6,10,12,14,0}--数字滑块的数字布局
determine=[[7057027238849384889_45]]--确定按钮ID
reset=[[7057027238849384889_47]]
slider_num=16--这里输入的数值是数字滑块数量+1

a={[[7057027238849384889_6]],[[7057027238849384889_30]],[[7057027238849384889_10]],[[7057027238849384889_2]],[[7057027238849384889_14]],[[7057027238849384889_26]],[[7057027238849384889_8]],[[7057027238849384889_22]],[[7057027238849384889_16]],[[7057027238849384889_4]],[[7057027238849384889_18]],[[7057027238849384889_12]],[[7057027238849384889_20]],[[7057027238849384889_24]],[[7057027238849384889_28]],0}
b={3,15,5,1,7,13,4,11,8,2,9,6,10,12,14,0}

--[[digital_slider列表和determine变量内储存内容是否与地图实际UI匹配测试
i=1
a=1--如测试digital_slider列表则为1,测试determine变量则为2
local function try(e)
    if a==1 then
        if e.btnelenemt==digital_slider[i] then--测试digital_slider列表时要注意按照列表内排列的元件顺序去点击UI上的数字滑块,否则测试无效
            print(layout[i]..":#Gtrue#n")
            i=i+1
        else
            print(layout[i]..":#Rfalse#n")
            i=i+1
        end
    elseif a==2 then
        if e.btnelenemt==determine then
            print("确定按钮:#Gtrue#n")
        else
            print("确定按钮:#Rfalse#n")
        end
    end
end
ScriptSupportEvent:registerEvent([=[UI.Button.Click]=],try)--]]

right=0
loading=0
local function click_slider(e)
    if loading==0 and e.btnelenemt~=determine and e.btnelenemt~=reset then
        for ii=1,slider_num do
            if e.btnelenemt==digital_slider[ii] then
                moving_slider(e.eventobjid,e.btnelenemt,ii,layout[ii])
                break
            end
        end
    elseif e.btnelenemt==determine then
        Customui:hideElement(e.eventobjid,uiid,determine)
        loading=1
        for ll=1,slider_num-1 do
            if ll==layout[ll] then
                right=right+1
            end
        end
        if right==slider_num-1 then
            Actor:playSoundEffectById(e.eventobjid,10946,100,1,false)
            --可在这里继续添加游戏成功后执行的内容
        elseif right<slider_num-1 then
            right=0
            loading=0
            Customui:showElement(e.eventobjid,uiid,determine)
            --这里可继续添加游戏失败时执行的内容,若该游戏只能挑战一次则要先删掉上面三行语句再继续添加语句
            Actor:playSoundEffectById(e.eventobjid,10949,100,1,false)
        end
    elseif e.btnelenemt==reset then
        loading=1
        for rr=1,15 do
            digital_slider[rr]=a[rr]
            layout[rr]=b[rr]
            Coustomui:setPosition(e.eventobjid,uiid,a[rr],elementid_x[rr],elementid_y[rr])
        end
        digital_slider[16]=0
        layout[16]=0
        loading=0
    end
end
ScriptSupportEvent:registerEvent([=[UI.Button.Click]=],click_slider)
function moving_slider(eventobjid,btnelenemt,sliderN,sliderD)
    if layout[sliderN-4]==0 and sliderN-4>0 then
        Coustomui:setPosition(eventobjid,uiid,btnelenemt,elementid_x[sliderN-4],elementid_y[sliderN-4])
        digital_slider[sliderN-4]=btnelenemt
        digital_slider[sliderN]=0
        layout[sliderN-4]=sliderD
        layout[sliderN]=0
        Actor:playSoundEffectById(eventobjid,10648,100,1,false)
    elseif layout[sliderN+4]==0 and sliderN+4<17 then
        Coustomui:setPosition(eventobjid,uiid,btnelenemt,elementid_x[sliderN+4],elementid_y[sliderN+4])
        digital_slider[sliderN+4]=btnelenemt
        digital_slider[sliderN]=0
        layout[sliderN+4]=sliderD
        layout[sliderN]=0
        Actor:playSoundEffectById(eventobjid,10648,100,1,false)
    elseif layout[sliderN-1]==0 and (sliderN-1)%4>0 then
        Coustomui:setPosition(eventobjid,uiid,btnelenemt,elementid_x[sliderN-1],elementid_y[sliderN-1])
        digital_slider[sliderN-1]=btnelenemt
        digital_slider[sliderN]=0
        layout[sliderN-1]=sliderD
        layout[sliderN]=0
        Actor:playSoundEffectById(eventobjid,10648,100,1,false)
    elseif layout[sliderN+1]==0 and sliderN%4>0 then
        Coustomui:setPosition(eventobjid,uiid,btnelenemt,elementid_x[sliderN+1],elementid_y[sliderN+1])
        digital_slider[sliderN+1]=btnelenemt
        digital_slider[sliderN]=0
        layout[sliderN+1]=sliderD
        layout[sliderN]=0
        Actor:playSoundEffectById(eventobjid,10648,100,1,false)
    else
        Actor:playSoundEffectById(eventobjid,10984,100,1,false)
    end
end
站点有内容要更新是否更新。
更新
忽略