132 lines
4.2 KiB
Lua
132 lines
4.2 KiB
Lua
|
---@class BP_DisappearFloorManager_C:AActor
|
||
|
---@field DefaultSceneRoot USceneComponent
|
||
|
---@field FloorClass UClass
|
||
|
---@field FloorPointClass UClass
|
||
|
---@field BuffActorClass UClass
|
||
|
---@field BuffType TEnumAsByte<BuffEnum>
|
||
|
---@field SpawnBuffLayer TArray<int32>
|
||
|
---@field BuffQuantityPerLayer int32
|
||
|
---@field BuffCoolingTime float
|
||
|
--Edit Below--
|
||
|
local BP_DisappearFloorManager = {
|
||
|
AllFloors = {};
|
||
|
AllPickUpBuffs = {};
|
||
|
LastNotifyHealthTime = 0;
|
||
|
NotifyHealthDelayTime = 0.1;
|
||
|
NeedNotifyHealth = false;
|
||
|
UpdateFloorHealthList = {}
|
||
|
};
|
||
|
|
||
|
|
||
|
function BP_DisappearFloorManager:ReceiveBeginPlay()
|
||
|
self.SuperClass.ReceiveBeginPlay(self);
|
||
|
if UGCGameSystem.IsServer() then
|
||
|
local FloorPoints = GameplayStatics.GetAllActorsOfClass(self, self.FloorPointClass, {})
|
||
|
for i, v in pairs(FloorPoints) do
|
||
|
self:SpawnFloors(v)
|
||
|
for _, Layer in pairs(self.SpawnBuffLayer) do
|
||
|
self:SpawnBuff(v, Layer)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
--function BP_DisappearFloorManager:ReceiveTick(DeltaTime)
|
||
|
-- self.SuperClass.ReceiveTick(self, DeltaTime);
|
||
|
--end
|
||
|
|
||
|
|
||
|
|
||
|
function BP_DisappearFloorManager:SpawnFloors(SpawnPoint)
|
||
|
if SpawnPoint.Layer <= 0 then return end
|
||
|
|
||
|
-- 获取两六边形地板间隔
|
||
|
local FloorWidth = SpawnPoint.Radius * math.sqrt(3)
|
||
|
local ActorForward = self:GetActorForwardVector()
|
||
|
local ActorPos = SpawnPoint:K2_GetActorLocation()
|
||
|
local ActorRot = SpawnPoint:K2_GetActorRotation()
|
||
|
|
||
|
-- 中心生成一个
|
||
|
self:SpawnFloorFromPos(ActorPos, ActorRot, SpawnPoint.ResetTime)
|
||
|
|
||
|
|
||
|
-- 循环生成
|
||
|
for NowLayer = 1, SpawnPoint.Layer - 1 do
|
||
|
-- 6个边
|
||
|
for side = 0, 5 do
|
||
|
local NowDir = KismetMathLibrary.GreaterGreater_VectorRotator(ActorForward, {Roll = 0, Pitch = 0, Yaw = side * 60})
|
||
|
local MoveDir = KismetMathLibrary.GreaterGreater_VectorRotator(NowDir, {Roll = 0, Pitch = 0, Yaw = 120})
|
||
|
local NowSpawnPos = VectorHelper.MulNumber(NowDir, NowLayer * FloorWidth)
|
||
|
for MoveSpawnIndex = 0, NowLayer - 1 do
|
||
|
local TargetPos = VectorHelper.Add(VectorHelper.Add(NowSpawnPos, VectorHelper.MulNumber(MoveDir, MoveSpawnIndex * FloorWidth)), ActorPos)
|
||
|
self:SpawnFloorFromPos(TargetPos, ActorRot, SpawnPoint.ResetTime)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_DisappearFloorManager:SpawnBuff(SpawnPoint, Layer)
|
||
|
local Dis = SpawnPoint.Radius * math.sqrt(3) * (Layer - 1)
|
||
|
local Dir = SpawnPoint:GetActorForwardVector()
|
||
|
local Center = SpawnPoint:K2_GetActorLocation()
|
||
|
Center.Z = Center.Z + 30
|
||
|
for i = 0, self.BuffQuantityPerLayer - 1 do
|
||
|
Dir = KismetMathLibrary.GreaterGreater_VectorRotator(Dir, {Roll = 0, Pitch = 0, Yaw = i * 360. / self.BuffQuantityPerLayer})
|
||
|
local Pos = VectorHelper.Add(VectorHelper.MulNumber(Dir, Dis), Center)
|
||
|
local BuffActor = UGCGameSystem.SpawnActor(self, self.BuffActorClass, Pos, VectorHelper.RotZero(), VectorHelper.ScaleOne(), nil)
|
||
|
self.AllPickUpBuffs[#self.AllPickUpBuffs + 1] = BuffActor
|
||
|
BuffActor:SetCoolingTime(self.BuffCoolingTime)
|
||
|
BuffActor:SetBuffType(self.BuffType)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_DisappearFloorManager:SpawnFloorFromPos(Pos, ActorRot, ResetTime)
|
||
|
local Floor = UGCGameSystem.SpawnActor(self, self.FloorClass, Pos, ActorRot, VectorHelper.ScaleOne(), nil)
|
||
|
self.AllFloors[#self.AllFloors + 1] = Floor
|
||
|
Floor:SetID(#self.AllFloors)
|
||
|
Floor:SetResetFloorTime(ResetTime)
|
||
|
return Floor
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
function BP_DisappearFloorManager:SetAllFloorActive(IsActivate)
|
||
|
for i, v in pairs(self.AllFloors) do
|
||
|
v:SetIsActivate(IsActivate, true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
function BP_DisappearFloorManager:ReceiveEndPlay()
|
||
|
if UGCGameSystem.IsServer() then
|
||
|
for i, v in pairs(self.AllFloors) do
|
||
|
if UE.IsValid(v) then
|
||
|
v:K2_DestroyActor()
|
||
|
end
|
||
|
end
|
||
|
for i, v in pairs(self.AllPickUpBuffs) do
|
||
|
if UE.IsValid(v) then
|
||
|
v:K2_DestroyActor()
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
self.SuperClass.ReceiveEndPlay(self);
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
function BP_DisappearFloorManager:GetReplicatedProperties()
|
||
|
return
|
||
|
"AllFloors"
|
||
|
end
|
||
|
|
||
|
|
||
|
--[[
|
||
|
function BP_DisappearFloorManager:GetAvailableServerRPCs()
|
||
|
return
|
||
|
end
|
||
|
--]]
|
||
|
|
||
|
return BP_DisappearFloorManager;
|