前端红点

特点:主要用于需要频繁检测的条件功能
前端无法获取玩家自定义变量

在要添加红点的UI组件上添加 事件 script=”topwindowbtn#clicktopbtn”
topwindowbtn=文件名,clicktopbtn=入口函数

可在入口函数下创建一个定时器

local visualElement=nil
function clicktopbtn(ve)
    visualElement = ve;
    visualElement:AddTimer(scale,"scale"):StartingIn(200);
end

function scale(ve,repet,id)
    --获取红点条件数据
    --增加红点
    --local equips = User.Equipment;获取玩家装备列表
    --local items = User.Inventory;获取玩家背包列表
    --PanelDic 角色面板字段
    --StatDic 角色属性字典
    --User.Stats.Values 面板数据的值
    --先在目标位置将红点放好 并隐藏 style="display: none;"
    --再在需要的时候显示出来
    local items = User.Inventory
    local num = 0
    for i = 0, items.Length - 1, 1 do
        if items[i] == nil then
            --print(items[i].Info.Name)
            num = num + 1
        end
    end
    if num < 5 then
        ve:SetStyle("display","flex")--显示红点
    else
        ve:SetStyle("display","none")--隐藏红点
    end
    return false--返回true是关闭计时器
end
    CS.UIManager.Instance:UpdateUIElement([[<New path="#Main > #SideMenu > #text">
    <div name="text">
        <label text = "显示文字"/>
        --这样可在前端动态添加组件
    </div>    
    </New>]])

后端红点

特点:主要用于触发试条件功能

作者:yilin01  创建时间:2025-05-08 11:09
最后编辑:yilin01  更新时间:2025-08-20 18:55