75 lines
3.0 KiB
Lua
75 lines
3.0 KiB
Lua
---@class Launch_C:AActor
|
|
---@field P_bounce_Loop UParticleSystemComponent
|
|
---@field P_bounce UParticleSystemComponent
|
|
---@field TriggerBox UBoxComponent
|
|
---@field Cube UStaticMeshComponent
|
|
---@field ZSpeed FVector
|
|
---@field CDTime float
|
|
---@field IsAddBuff bool
|
|
---@field IsActivate bool
|
|
---@field DisableFaillingTime int32
|
|
---@field BouncingSound UAkEventObject
|
|
--Edit Below--
|
|
---@type Launch_C
|
|
local Launch = {};
|
|
function Launch:ReceiveBeginPlay()
|
|
sandbox.LogNormalDev(StringFormat_Dev("[Launch:ReceiveBeginPlay] IsServer[%s]", self:HasAuthority()))
|
|
Launch.SuperClass.ReceiveBeginPlay(self)
|
|
|
|
self.Jumpers = {}
|
|
self.SaveTime = 0
|
|
if self:HasAuthority() then
|
|
self.TriggerBox.OnComponentBeginOverlap:Add(self.OnBeginOverlap, self)
|
|
self.TriggerBox.OnComponentEndOverlap:Add(self.OnEndOverlap, self)
|
|
end
|
|
end
|
|
|
|
function Launch:OnBeginOverlap(OverlappedComp, Other, OtherComp, OtherBodyIndex, bFromSweep, SweepResult)
|
|
sandbox.LogNormalDev(StringFormat_Dev("[Launch:OnBeginOverlap] self=%s", GetObjectFullName_Dev(self)))
|
|
|
|
local GameState = GameplayStatics.GetGameState(self)
|
|
local CurrentServerWorldTimeSeconds = GameState:GetServerWorldTimeSeconds()
|
|
local AddSpeed = 0
|
|
local Character = Other.PlayerState:GetPlayerCharacter()
|
|
if(self.IsActivate) then
|
|
if(Character.CanJump) then
|
|
table.insert(self.Jumpers, Other)
|
|
end
|
|
|
|
if(CurrentServerWorldTimeSeconds - self.SaveTime >= self.CDTime) then
|
|
self.SaveTime = CurrentServerWorldTimeSeconds
|
|
for i = 1, #self.Jumpers, 1 do
|
|
local PlayerCharacter = self.Jumpers[i].PlayerState:GetPlayerCharacter()
|
|
if(self.IsAddBuff) then
|
|
PlayerCharacter:DisableFallingDamageForPerioud(self.DisableFaillingTime)
|
|
end
|
|
--考虑角色跳起来的情况
|
|
if PlayerCharacter.CharacterMovement.Velocity.Z < 0 then
|
|
AddSpeed = Vector.New(0, 0, self.ZSpeed.Z - PlayerCharacter.CharacterMovement.Velocity.Z)
|
|
self.Jumpers[i].CharacterMovement:AddImpulse(AddSpeed, true)
|
|
elseif PlayerCharacter.CharacterMovement.Velocity.Z == 0 then
|
|
self.Jumpers[i].CharacterMovement:AddImpulse(self.ZSpeed, true)
|
|
end
|
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "PlayDisappear")
|
|
end
|
|
end
|
|
table.remove(self.Jumpers)
|
|
end
|
|
end
|
|
|
|
function Launch:PlayDisappear()
|
|
sandbox.LogNormalDev("[Launch:PlayDisappear]")
|
|
local MyLocation = self.TriggerBox:K2_GetComponentLocation()
|
|
self.P_bounce:SetActive(true, true)
|
|
UGCSoundManagerSystem.PlaySoundAtLocation(self.BouncingSound, MyLocation)
|
|
end
|
|
|
|
function Launch:ReceiveEndPlay()
|
|
sandbox.LogNormalDev("[Launch:ReceiveEndPlay]")
|
|
if self:HasAuthority() then
|
|
self.TriggerBox.OnComponentBeginOverlap:Remove(self.OnBeginOverlap, self)
|
|
self.TriggerBox.OnComponentEndOverlap:Remove(self.OnEndOverlap, self)
|
|
end
|
|
end
|
|
return Launch;
|