103 lines
3.7 KiB
Lua
103 lines
3.7 KiB
Lua
------------------------------------------------
|
|
--作者: 陈宇
|
|
--日期: 2019-07-17
|
|
--文件: LuaVariableSystem.lua
|
|
--模块: LuaVariableSystem
|
|
--描述: lua端的变量系统
|
|
------------------------------------------------
|
|
local LuaVariableSystem = {}
|
|
|
|
function LuaVariableSystem:GetVariableShowText(functionVariableIdCode, curValue, value, simplifyValue)
|
|
-- if functionVariableIdCode == FunctionVariableIdCode.XXXXXXXXXXXX then
|
|
-- TODO
|
|
-- end
|
|
if UnityUtils.GetObjct2Int(functionVariableIdCode) == FunctionVariableIdCode.WanYaoJuanNum then
|
|
return UIUtils.CSFormat(DataConfig.DataMessageString.Get("HellLayer"), value)
|
|
end
|
|
|
|
--最后的返回值,如有其它需要的返回值,请在上面实现
|
|
if simplifyValue then
|
|
local _curText = ""
|
|
if curValue > 1000000 then
|
|
if curValue % 1000000 == 0 then
|
|
_curText = string.format( "%dM", curValue // 1000000)
|
|
else
|
|
_curText = string.format( "%.2fM", curValue / 1000000)
|
|
end
|
|
elseif curValue > 1000 then
|
|
if curValue % 1000 == 0 then
|
|
_curText = string.format( "%dK", curValue // 1000)
|
|
else
|
|
_curText = string.format( "%.2fK", curValue / 1000)
|
|
end
|
|
else
|
|
_curText = tostring(curValue)
|
|
end
|
|
|
|
local _valueText = ""
|
|
if value > 1000000 then
|
|
if value % 1000000 == 0 then
|
|
_valueText = string.format( "%dM", value // 1000000)
|
|
else
|
|
_valueText = string.format( "%.2fM", value / 1000000)
|
|
end
|
|
elseif value > 1000 then
|
|
if value % 1000 == 0 then
|
|
_valueText = string.format( "%dM", value // 1000)
|
|
else
|
|
_valueText = string.format( "%.2fM", value / 1000)
|
|
end
|
|
else
|
|
_valueText = tostring(value)
|
|
end
|
|
return string.format( "%s/%s", _curText, _valueText)
|
|
end
|
|
return string.format( "%d/%d", curValue, value)
|
|
end
|
|
|
|
function LuaVariableSystem:GetVariableShowProgress(functionVariableIdCode, curValue, value)
|
|
-- if functionVariableIdCode == FunctionVariableIdCode.XXXXXXXXXXXX then
|
|
-- TODO
|
|
-- end
|
|
if UnityUtils.GetObjct2Int(functionVariableIdCode) == FunctionVariableIdCode.WanYaoJuanNum then
|
|
return curValue / value
|
|
end
|
|
|
|
--最后的返回值,如有其它需要的返回值,请在上面实现
|
|
return curValue / value
|
|
end
|
|
|
|
function LuaVariableSystem:IsVariableReach(functionVariableIdCode, curValue, value)
|
|
-- if functionVariableIdCode == FunctionVariableIdCode.XXXXXXXXXXXX then
|
|
-- TODO
|
|
-- end
|
|
if UnityUtils.GetObjct2Int(functionVariableIdCode) == FunctionVariableIdCode.WanYaoJuanNum then
|
|
return curValue >= value
|
|
end
|
|
|
|
--最后的返回值,如有其它需要的返回值,请在上面实现
|
|
return curValue >= value
|
|
end
|
|
|
|
function LuaVariableSystem:GetVariableValue(functionVariableIdCode)
|
|
-- if functionVariableIdCode == FunctionVariableIdCode.XXXXXXXXXXXX then
|
|
-- TODO
|
|
-- end
|
|
if functionVariableIdCode == FunctionVariableIdCode.WanYaoJuanNum then
|
|
--万妖卷 已通关 的层数,因此要 -1
|
|
local _towerData = GameCenter.CopyMapSystem:FindCopyDataByType(CopyMapTypeEnum.TowerCopy);
|
|
if _towerData and _towerData.CurLevel > 0 then
|
|
return _towerData.CurLevel - 1
|
|
end
|
|
return -1
|
|
elseif functionVariableIdCode == FunctionVariableIdCode.SkillCountLevel then
|
|
--技能总等级达到X级
|
|
return GameCenter.PlayerSkillSystem:GetOverallLevel()
|
|
end
|
|
|
|
--最后的返回值,如有其它需要的返回值,请在上面实现
|
|
return -1
|
|
end
|
|
|
|
return LuaVariableSystem
|