local roleJob = SL:GetMetaValue("JOB")
local roleLevel = SL:GetMetaValue("LEVEL")
if roleLevel < 28 and roleJob == 0 then -- 战士等级小于28 显示全血
if MainProperty._ui.Panel_hp_sfx and MainProperty._ui.Panel_mp_sfx then
GUI:setVisi
这段代码是用来根据战士职业和等级控制血球特效显示的。让我分析一下:
```lua
local roleJob = SL:GetMetaValue("JOB")
local roleLevel = SL:GetMetaValue("LEVEL")
if roleLevel < 28 and roleJob == 0 then -- 战士等级小于28 显示全血
if MainProperty._ui.Panel_hp_sfx and MainProperty._ui.Panel_mp_sfx then
GUI:setVisible(MainProperty._ui.Panel_hp_sfx, false)
GUI:setVisible(MainProperty._ui.Panel_mp_sfx, false)
GUI:setVisible(MainProperty._ui.Panel_fhp_sfx, true)
end
else
if MainProperty._ui.Panel_hp_sfx and MainProperty._ui.Panel_mp_sfx then
GUI:setVisible(MainProperty._ui.Panel_hp_sfx, true)
GUI:setVisible(MainProperty._ui.Panel_mp_sfx, true)
GUI:setVisible(MainProperty._ui.Panel_fhp_sfx, false)
end
end
```
代码逻辑分析:
1. 获取玩家职业和等级:`SL:GetMetaValue("JOB")` 获取职业,`SL:GetMetaValue("LEVEL")` 获取等级
2. 判断条件:战士职业(roleJob == 0)且等级小于28级
3. 满足条件时:隐藏普通血球特效(Panel_hp_sfx、Panel_mp_sfx),显示全血特效(Panel_fhp_sfx)
4. 不满足条件时:显示普通血球特效,隐藏全血特效
这个逻辑在浮生梦老师的前端课程中有类似案例,主要是为了在战士28级前显示一个全血条,28级后显示分开的血蓝条。
注意:代码中使用了`GUI:setVisible()`函数来控制控件的显示隐藏,这是996引擎的标准函数。