2023-07-14 19:35:33 +00:00
|
|
|
local type = type
|
|
|
|
local pairs = pairs
|
|
|
|
|
|
|
|
--[[
|
|
|
|
public class XKillZonePluginDb
|
|
|
|
{
|
|
|
|
public int Id;
|
|
|
|
/// <summary>
|
|
|
|
/// 等级索引
|
|
|
|
/// </summary>
|
|
|
|
public int LevelIndex;
|
|
|
|
}
|
|
|
|
]]
|
|
|
|
local Default = {
|
|
|
|
_Id = 0, --插件Id
|
|
|
|
_Level = -1, --等级
|
|
|
|
_Slot = 0, --穿戴槽位
|
|
|
|
}
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
---@class XKillZonePlugin
|
2023-07-14 19:35:33 +00:00
|
|
|
local XKillZonePlugin = XClass(nil, "XKillZonePlugin")
|
|
|
|
|
|
|
|
function XKillZonePlugin:Ctor(id)
|
|
|
|
self:Init(id)
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:Init(id)
|
|
|
|
for key, value in pairs(Default) do
|
|
|
|
if type(value) == "table" then
|
|
|
|
self[key] = {}
|
|
|
|
else
|
|
|
|
self[key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
self._Id = id
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:Reset()
|
|
|
|
for key, value in pairs(Default) do
|
|
|
|
if key ~= "_Id" then
|
|
|
|
if type(value) == "table" then
|
|
|
|
self[key] = {}
|
|
|
|
else
|
|
|
|
self[key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:UpdateData(info)
|
|
|
|
self._Level = info.LevelIndex and info.LevelIndex + 1 or self._Level
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:GetLevel()
|
|
|
|
return self._Level
|
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
--获取插件展示等级(包含未解锁/正常/最大等级)
|
2023-07-14 19:35:33 +00:00
|
|
|
local MaxLevelStr = CS.XTextManager.GetText("KillZonePlguinMaxLevelStr")
|
|
|
|
function XKillZonePlugin:GetShowLevelStr()
|
|
|
|
local level = self._Level
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
if self:IsLock() then
|
2023-07-14 19:35:33 +00:00
|
|
|
level = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if level == XKillZoneConfigs.GetPluginMaxLevel(self._Id) then
|
|
|
|
return MaxLevelStr
|
|
|
|
end
|
|
|
|
|
|
|
|
return tostring(level)
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:PutOn(slot)
|
|
|
|
self._Slot = slot
|
|
|
|
end
|
|
|
|
|
|
|
|
function XKillZonePlugin:TakeOff()
|
|
|
|
self._Slot = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
--是否未解锁
|
|
|
|
function XKillZonePlugin:IsLock()
|
|
|
|
return self:GetLevel() < 0
|
|
|
|
end
|
|
|
|
|
|
|
|
--是否达到最大等级
|
|
|
|
function XKillZonePlugin:IsMaxLevel()
|
|
|
|
return self:GetLevel() == XKillZoneConfigs.GetPluginMaxLevel(self._Id)
|
|
|
|
end
|
|
|
|
|
|
|
|
--获取升级消耗
|
|
|
|
function XKillZonePlugin:GetLevelUpCost()
|
|
|
|
local itemId, itemCount = XKillZoneConfigs.GetPluginLevelUpCost(self._Id, self._Level + 1)
|
|
|
|
return itemId, itemCount
|
|
|
|
end
|
|
|
|
|
|
|
|
return XKillZonePlugin
|