186 lines
4.1 KiB
Lua
186 lines
4.1 KiB
Lua
BuffTable = {};
|
|
|
|
---@class EBuffTypeInfo
|
|
---@field AddHealth_Quick int32
|
|
---@field AddHealth_Slow int32
|
|
---@field AddSpeed int32
|
|
---@field AddBodySize int32
|
|
---@field AddHealthMax int32
|
|
---@field ReduceHealth_Quick int32
|
|
---@field ReduceHealthMax int32
|
|
---@field ReduceSpeed int32
|
|
---@field SmallBody int32
|
|
---@field AddJump int32
|
|
---@field ReduceJump int32
|
|
BuffTable.EBuffType = {
|
|
AddHealth_Quick = 1,
|
|
AddHealth_Slow = 2,
|
|
AddSpeed = 3,
|
|
AddBodySize = 4,
|
|
AddHealthMax = 5,
|
|
ReduceHealth_Quick = 6,
|
|
ReduceHealthMax = 7,
|
|
ReduceSpeed = 8,
|
|
SmallBody = 9,
|
|
ReduceHealth_Slow = 10,
|
|
|
|
AddJump = 11,
|
|
ReduceJump = 12,
|
|
--AddBodySize_Slow = 13,
|
|
}
|
|
|
|
--- 当添加 Buff 是否是一直持有的
|
|
BuffTable.DurableAdd = true;
|
|
BuffTable.BuffChangeInterval = 1;
|
|
|
|
---@class BuffInfoItem
|
|
---@field Chinese string
|
|
---@field Rate float
|
|
---@field ContinueTime float
|
|
---@field Value float
|
|
|
|
---@type table<EBuffTypeInfo, BuffInfoItem>
|
|
BuffTable.BuffInfo = {
|
|
[BuffTable.EBuffType.AddHealth_Quick] = {
|
|
Chinese = "快速加血",
|
|
Rate = 10,
|
|
ContinueTime = 0,
|
|
Value = 20,
|
|
},
|
|
[BuffTable.EBuffType.AddHealth_Slow] = {
|
|
Chinese = "缓慢回血",
|
|
Rate = 15,
|
|
ContinueTime = 5,
|
|
Value = 3,
|
|
},
|
|
[BuffTable.EBuffType.ReduceHealth_Quick] = {
|
|
Chinese = "快速扣血",
|
|
Rate = 0,
|
|
ContinueTime = 0,
|
|
Value = 20,
|
|
},
|
|
[BuffTable.EBuffType.AddHealthMax] = {
|
|
Chinese = "增加最大生命值",
|
|
Rate = 50,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.AddSpeed] = {
|
|
Chinese = "加速",
|
|
Rate = 10,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.AddBodySize] = {
|
|
Chinese = "增大体型",
|
|
Rate = 50,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.ReduceHealthMax] = {
|
|
Chinese = "降低最大生命值",
|
|
Rate = 0,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.ReduceSpeed] = {
|
|
Chinese = "减速",
|
|
Rate = 0,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.SmallBody] = {
|
|
Chinese = "减小体型",
|
|
Rate = 0,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.ReduceHealth_Slow] = {
|
|
Chinese = "缓慢扣血",
|
|
Rate = 0,
|
|
ContinueTime = 5,
|
|
Value = 3,
|
|
},
|
|
[BuffTable.EBuffType.AddJump] = {
|
|
Chinese = "跳跃增强",
|
|
Rate = 10,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
[BuffTable.EBuffType.ReduceJump] = {
|
|
Chinese = "跳跃减弱",
|
|
Rate = 0,
|
|
ContinueTime = 0,
|
|
Value = 0.1,
|
|
},
|
|
}
|
|
|
|
---@type table<int32, int32>
|
|
BuffTable.BuffIdTable = {};
|
|
|
|
--- 初始化 BuffTable
|
|
function InitBuffTable()
|
|
BuffTable.LoadBuffIdTable()
|
|
end
|
|
|
|
---@param InIndex int32
|
|
function BuffTable.GetBuffName(InIndex)
|
|
for i, v in pairs(BuffTable.EBuffType) do
|
|
if InIndex == v then return i; end
|
|
end
|
|
return nil;
|
|
end
|
|
|
|
---@param BuffName string
|
|
function BuffTable.CheckBuffExist(BuffName)
|
|
return BuffTable.EBuffType[BuffName] ~= nil;
|
|
end
|
|
|
|
function BuffTable.LoadBuffIdTable()
|
|
BuffTable.BuffIdTable = {};
|
|
for i, v in pairs(BuffTable.EBuffType) do
|
|
BuffTable.BuffIdTable[#BuffTable.BuffIdTable + 1] = v;
|
|
end
|
|
end
|
|
|
|
---@type table<int32, any>
|
|
BuffTable.ValidBuffs = {};
|
|
BuffTable.ValidBuffCount = nil;
|
|
|
|
--- 获取可用的 Buff
|
|
function BuffTable.GetValidBuffIds()
|
|
BuffTable.ValidBuffs = {};
|
|
local Total = 0;
|
|
for i = 1, #BuffTable.BuffInfo do
|
|
local BuffInfo = BuffTable.BuffInfo[i]
|
|
if BuffInfo.Rate > 0 then
|
|
Total = Total + BuffInfo.Rate;
|
|
BuffTable.ValidBuffs[#BuffTable.ValidBuffs + 1] = {
|
|
Rate = BuffInfo.Rate;
|
|
Type = i;
|
|
};
|
|
end
|
|
end
|
|
BuffTable.ValidBuffCount = Total;
|
|
end
|
|
|
|
--- 随机选取一个 Buff
|
|
---@return EBuffType
|
|
function BuffTable.RandomBuff()
|
|
if table.isEmpty(BuffTable.ValidBuffs) then BuffTable.GetValidBuffIds(); end
|
|
local Num = math.random(BuffTable.ValidBuffCount)
|
|
for i, v in pairs(BuffTable.ValidBuffs) do
|
|
Num = Num - v.Rate;
|
|
if Num <= 0 then return v.Type; end
|
|
end
|
|
return 1;
|
|
end
|
|
|
|
---@param InBuffItem FBuffAction
|
|
---@param IsAdd bool
|
|
function BuffTable.ApplyBuff(InBuffItem, IsAdd)
|
|
if IsServer then
|
|
local Simple = 1;
|
|
if IsAdd == false then Simple = -1; end
|
|
end
|
|
end |